diff --git a/mesecons_luacontroller/init.lua b/mesecons_luacontroller/init.lua index 50a6747..1929d22 100644 --- a/mesecons_luacontroller/init.lua +++ b/mesecons_luacontroller/init.lua @@ -316,6 +316,11 @@ if mesecon.setting("luacontroller_lightweight_interrupts", false) then get_interrupt = function(pos, itbl, send_warning) return (function(time, iid) if type(time) ~= "number" then error("Delay must be a number") end + local mintime = mesecon.setting("luacontroller_minimum_interrupt", 1) + if time < mintime then + send_warning("Delay is too short (using "..mintime..")" ) + time = mintime + end if iid ~= nil then send_warning("Interrupt IDs are disabled on this server") end table.insert(itbl, function() minetest.get_node_timer(pos):start(time) end) end) @@ -329,6 +334,11 @@ else -- NOTE: This runs within string metatable sandbox, so don't *rely* on anything of the form (""):y -- Hence the values get moved out. Should take less time than original, so totally compatible if type(time) ~= "number" then error("Delay must be a number") end + local mintime = mesecon.setting("luacontroller_minimum_interrupt", 1) + if time < mintime then + send_warning("Delay is too short (using "..mintime..")" ) + time = mintime + end table.insert(itbl, function () -- Outside string metatable sandbox, can safely run this now local luac_id = minetest.get_meta(pos):get_int("luac_id") diff --git a/settingtypes.txt b/settingtypes.txt index 5627440..88dfbeb 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -23,6 +23,7 @@ mesecon.luacontroller_string_rep_max (string:rep result length limit) int 64000 mesecon.luacontroller_digiline_maxlen (Digiline message size limit) int 50000 1000 1000000 mesecon.luacontroller_maxevents (Controller execution time limit) int 10000 1000 100000 mesecon.luacontroller_memsize (Controller memory limit) int 100000 10000 1000000 +mesecon.luacontroller_minimum_interrupt (Minimum interrupt time) float 1 0.1 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.