mirror of
https://github.com/minetest-mods/mesecons.git
synced 2024-09-27 23:00:29 +02:00
Move get_interrupt under the conditional
This commit is contained in:
parent
d62b9eae05
commit
2b9c4ffaee
|
@ -266,8 +266,20 @@ local function remove_functions(x)
|
|||
return x
|
||||
end
|
||||
|
||||
-- The setting affects API so is not intended to be changeable at runtime
|
||||
local get_interrupt
|
||||
if mesecon.setting("luacontroller_lightweight_interrupts", false) then
|
||||
-- use node timer
|
||||
get_interrupt = function(pos, itbl, send_warning)
|
||||
return (function(time)
|
||||
if type(time) ~= "number" then return end
|
||||
table.insert(itbl, function() minetest.get_node_timer(pos):start(time) end)
|
||||
end)
|
||||
end
|
||||
else
|
||||
-- use global action queue
|
||||
-- itbl: Flat table of functions to run after sandbox cleanup, used to prevent various security hazards
|
||||
local function get_interrupt(pos, itbl, send_warning)
|
||||
get_interrupt = function(pos, itbl, send_warning)
|
||||
-- iid = interrupt id
|
||||
local function interrupt(time, iid)
|
||||
-- NOTE: This runs within string metatable sandbox, so don't *rely* on anything of the form (""):y
|
||||
|
@ -282,13 +294,7 @@ local function get_interrupt(pos, itbl, send_warning)
|
|||
iid = remove_functions(iid)
|
||||
local msg_ser = minetest.serialize(iid)
|
||||
if #msg_ser <= mesecon.setting("luacontroller_interruptid_maxlen", 256) then
|
||||
if mesecon.setting("luacontroller_lightweight_interrupts", false) then
|
||||
-- use node timer
|
||||
minetest.get_node_timer(pos):start(time)
|
||||
else
|
||||
-- use global action queue
|
||||
mesecon.queue:add_action(pos, "lc_interrupt", {luac_id, iid}, time, iid, 1)
|
||||
end
|
||||
else
|
||||
send_warning("An interrupt ID was too large!")
|
||||
end
|
||||
|
@ -296,7 +302,7 @@ local function get_interrupt(pos, itbl, send_warning)
|
|||
end
|
||||
return interrupt
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Given a message object passed to digiline_send, clean it up into a form
|
||||
-- which is safe to transmit over the network and compute its "cost" (a very
|
||||
|
|
|
@ -24,6 +24,10 @@ mesecon.luacontroller_digiline_maxlen (Digiline message size limit) int 50000 10
|
|||
mesecon.luacontroller_maxevents (Controller execution time limit) int 10000 1000 100000
|
||||
mesecon.luacontroller_memsize (Controller memory limit) int 100000 10000 1000000
|
||||
|
||||
# Use node timer for interrupts (runs in active blocks only).
|
||||
# IID is ignored and at most one interrupt may be queued if this setting is enabled.
|
||||
mesecon.luacontroller_lightweight_interrupts (Lightweight interrupts) bool false
|
||||
|
||||
|
||||
[mesecons_movestones]
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user