summaryrefslogtreecommitdiff
path: root/mesecons_luacontroller
diff options
context:
space:
mode:
Diffstat (limited to 'mesecons_luacontroller')
-rw-r--r--mesecons_luacontroller/init.lua31
1 files changed, 8 insertions, 23 deletions
diff --git a/mesecons_luacontroller/init.lua b/mesecons_luacontroller/init.lua
index f6a11f9..2cbebd6 100644
--- a/mesecons_luacontroller/init.lua
+++ b/mesecons_luacontroller/init.lua
@@ -168,19 +168,8 @@ end
-- Parsing and running --
-------------------------
--- Limit printing to prevent flooding
-local print_count = 0
-
local function safe_print(param)
- local to_print = dump(param, "")
- print_count = print_count + 1 + (#to_print / 64)
- for c in to_print:gmatch("\n") do
- print_count = print_count + 1
- end
- if print_count > 8 then
- error("Too much printing!")
- end
- print(to_print)
+ print(dump(param))
end
minetest.register_globalstep(function(dtime)
@@ -210,13 +199,12 @@ local function remove_functions(x)
return x
end
-
local function get_interrupt(pos)
-- iid = interrupt id
local function interrupt(time, iid)
if type(time) ~= "number" then return end
local luac_id = minetest.get_meta(pos):get_int("luac_id")
- mesecon.queue:add_action(pos, "LuaController interrupt", {iid, luac_id}, time, iid, 1)
+ mesecon.queue:add_action(pos, "lc_interrupt", {luac_id, iid}, time, iid, 1)
end
return interrupt
end
@@ -404,6 +392,12 @@ local function run(pos, event)
set_port_states(pos, env.port)
end
+mesecon.queue:add_function("lc_interrupt", function (pos, luac_id, iid)
+ -- There is no luacontroller anymore / it has been reprogrammed / replaced
+ if (minetest.get_meta(pos):get_int("luac_id") ~= luac_id) then return end
+ run(pos, {type="interrupt", iid = iid})
+end)
+
local function reset_meta(pos, code, errmsg)
local meta = minetest.get_meta(pos)
meta:set_string("code", code)
@@ -424,15 +418,6 @@ local function reset(pos)
end
-mesecon.queue:add_function("LuaController interrupt", function(pos, iid, luac_id)
- -- There is no LuaController anymore / it has been reprogrammed / replaced
- if minetest.get_meta(pos):get_int("luac_id") ~= luac_id then
- return
- end
- run(pos, {type="interrupt", iid = iid})
-end)
-
-
-----------------------
-- Node Registration --
-----------------------