diff options
author | Jeija <jeija@mesecons.net> | 2014-01-10 22:29:18 +0100 |
---|---|---|
committer | Jeija <jeija@mesecons.net> | 2014-01-10 22:33:40 +0100 |
commit | 2d004b19eaaac21b4a82fa4ba6736e5e7090041a (patch) | |
tree | 9ed04c52d4e7c977f843182c54e2429cd31463cc /mesecons_delayer/init.lua | |
parent | 3f76b77001512a7b71a8c81c181f78729c34e0d0 (diff) |
First draft of some kind of Action Queue (just like the globalstep queue in to_update), but more flexible and also including delay functionality (mesecon_delayer).
The queue is also saved to a file, so that when restarting mesecons, delayers resume to the state they had when the game shut down. Needs testing.
Diffstat (limited to 'mesecons_delayer/init.lua')
-rw-r--r-- | mesecons_delayer/init.lua | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/mesecons_delayer/init.lua b/mesecons_delayer/init.lua index a03737c..4ec0ebc 100644 --- a/mesecons_delayer/init.lua +++ b/mesecons_delayer/init.lua @@ -17,28 +17,18 @@ end -- Functions that are called after the delay time -local delayer_turnon = function(params) - local rules = delayer_get_output_rules(params.node) - mesecon:receptor_on(params.pos, rules) -end - -local delayer_turnoff = function(params) - local rules = delayer_get_output_rules(params.node) - mesecon:receptor_off(params.pos, rules) -end - local delayer_activate = function(pos, node) local def = minetest.registered_nodes[node.name] local time = def.delayer_time minetest.swap_node(pos, {name = def.delayer_onstate, param2=node.param2}) - minetest.after(time, delayer_turnon , {pos = pos, node = node}) + mesecon.queue:add_action(pos, "receptor_on", {rules=delayer_get_output_rules(node)}, time, nil) end local delayer_deactivate = function(pos, node) local def = minetest.registered_nodes[node.name] local time = def.delayer_time minetest.swap_node(pos, {name = def.delayer_offstate, param2=node.param2}) - minetest.after(time, delayer_turnoff, {pos = pos, node = node}) + mesecon.queue:add_action(pos, "receptor_off", {rules=delayer_get_output_rules(node)}, time, nil) end -- Register the 2 (states) x 4 (delay times) delayers |