mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 11:09:21 +01:00
Create Event.lua
This commit is contained in:
parent
2b68b4b4f9
commit
8f5e89a645
@ -2,8 +2,9 @@
|
|||||||
local event, handlers, interruptingKeysDown, lastInterrupt = {
|
local event, handlers, interruptingKeysDown, lastInterrupt = {
|
||||||
interruptingEnabled = true,
|
interruptingEnabled = true,
|
||||||
interruptingDelay = 1,
|
interruptingDelay = 1,
|
||||||
interruptingFunction = error,
|
defaultInterruptingFunction = function()
|
||||||
defaultInterruptingFunction = error,
|
error("interrupted", 0)
|
||||||
|
end,
|
||||||
interruptingKeyCodes = {
|
interruptingKeyCodes = {
|
||||||
[29] = true,
|
[29] = true,
|
||||||
[46] = true,
|
[46] = true,
|
||||||
@ -12,6 +13,8 @@ local event, handlers, interruptingKeysDown, lastInterrupt = {
|
|||||||
push = computer.pushSignal
|
push = computer.pushSignal
|
||||||
}, {}, {}, 0
|
}, {}, {}, 0
|
||||||
|
|
||||||
|
event.interruptingFunction = event.defaultInterruptingDFunction
|
||||||
|
|
||||||
local computerPullSignal, computerUptime, mathHuge, mathMin, skipSignalType = computer.pullSignal, computer.uptime, math.huge, math.min
|
local computerPullSignal, computerUptime, mathHuge, mathMin, skipSignalType = computer.pullSignal, computer.uptime, math.huge, math.min
|
||||||
|
|
||||||
--------------------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------------------
|
||||||
@ -106,7 +109,8 @@ function event.pull(preferredTimeout)
|
|||||||
|
|
||||||
if shouldInterrupt and uptime - lastInterrupt > event.interruptingDelay then
|
if shouldInterrupt and uptime - lastInterrupt > event.interruptingDelay then
|
||||||
lastInterrupt = uptime
|
lastInterrupt = uptime
|
||||||
event.interruptingFunction("interrupted", 0)
|
|
||||||
|
event.interruptingFunction()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user