Create Event.lua

This commit is contained in:
IgorTimofeev 2022-05-06 19:52:53 +03:00 committed by GitHub
parent 2b68b4b4f9
commit 8f5e89a645
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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