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 = {
interruptingEnabled = true,
interruptingDelay = 1,
interruptingFunction = error,
defaultInterruptingFunction = error,
defaultInterruptingFunction = function()
error("interrupted", 0)
end,
interruptingKeyCodes = {
[29] = true,
[46] = true,
@ -12,6 +13,8 @@ local event, handlers, interruptingKeysDown, lastInterrupt = {
push = computer.pushSignal
}, {}, {}, 0
event.interruptingFunction = event.defaultInterruptingDFunction
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
lastInterrupt = uptime
event.interruptingFunction("interrupted", 0)
event.interruptingFunction()
end
end