diff options
author | Jeija <norrepli@gmail.com> | 2012-08-13 20:17:45 +0200 |
---|---|---|
committer | Jeija <norrepli@gmail.com> | 2012-08-13 20:17:45 +0200 |
commit | 00ce2540c22340ed02135d74c6d70a35757e8deb (patch) | |
tree | 24f5ee80cf20e3eb2a9a303a52ead63ff685fecd /mesecons_delayer | |
parent | 24c50571f788a2d946ee905dd295124affc88d8b (diff) | |
download | mesecons-00ce2540c22340ed02135d74c6d70a35757e8deb.tar mesecons-00ce2540c22340ed02135d74c6d70a35757e8deb.tar.gz mesecons-00ce2540c22340ed02135d74c6d70a35757e8deb.tar.bz2 mesecons-00ce2540c22340ed02135d74c6d70a35757e8deb.tar.xz mesecons-00ce2540c22340ed02135d74c6d70a35757e8deb.zip |
New effector system, effectors have to be registered with mesecon:register_effector(onstate, offstate, rules, function get_rules) rules and function get_rules are optional. You don't have to specify both onstate and offstate (required for e.g. removestone)
Diffstat (limited to 'mesecons_delayer')
-rw-r--r-- | mesecons_delayer/init.lua | 78 |
1 files changed, 34 insertions, 44 deletions
diff --git a/mesecons_delayer/init.lua b/mesecons_delayer/init.lua index 469704f..c732a17 100644 --- a/mesecons_delayer/init.lua +++ b/mesecons_delayer/init.lua @@ -115,55 +115,45 @@ end) mesecon.delayer_update = function(pos, node) if string.find(node.name, "mesecons_delayer:delayer_off")~=nil then - local input_rules = mesecon.delayer_get_input_rules(node.param2)[1] - np = {x = pos.x + input_rules.x, y = pos.y + input_rules.y, z = pos.z + input_rules.z} - - if mesecon:is_power_on(np) then - local time = 0 - if node.name=="mesecons_delayer:delayer_off_1" then - minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_1", param2=node.param2}) - time=0.1 - end - if node.name=="mesecons_delayer:delayer_off_2" then - minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_2", param2=node.param2}) - time=0.3 - end - if node.name=="mesecons_delayer:delayer_off_3" then - minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_3", param2=node.param2}) - time=0.5 - end - if node.name=="mesecons_delayer:delayer_off_4" then - minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_4", param2=node.param2}) - time=1 - end - minetest.after(time, mesecon.delayer_turnon, {pos=pos, param2=node.param2}) + local time = 0 + if node.name=="mesecons_delayer:delayer_off_1" then + minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_1", param2=node.param2}) + time=0.1 end + if node.name=="mesecons_delayer:delayer_off_2" then + minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_2", param2=node.param2}) + time=0.3 + end + if node.name=="mesecons_delayer:delayer_off_3" then + minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_3", param2=node.param2}) + time=0.5 + end + if node.name=="mesecons_delayer:delayer_off_4" then + minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_4", param2=node.param2}) + time=1 + end + minetest.after(time, mesecon.delayer_turnon, {pos=pos, param2=node.param2}) end if string.find(node.name, "mesecons_delayer:delayer_on")~=nil then - local input_rules = mesecon.delayer_get_input_rules(node.param2)[1] - np = {x = pos.x + input_rules.x, y = pos.y + input_rules.y, z = pos.z + input_rules.z} - - if not mesecon:is_power_on(np) then - local time = 0 - if node.name=="mesecons_delayer:delayer_on_1" then - minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_1", param2=node.param2}) - time=0.1 - end - if node.name=="mesecons_delayer:delayer_on_2" then - minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_2", param2=node.param2}) - time=0.3 - end - if node.name=="mesecons_delayer:delayer_on_3" then - minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_3", param2=node.param2}) - time=0.5 - end - if node.name=="mesecons_delayer:delayer_on_4" then - minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_4", param2=node.param2}) - time=1 - end - minetest.after(time, mesecon.delayer_turnoff, {pos=pos, param2=node.param2}) + local time = 0 + if node.name=="mesecons_delayer:delayer_on_1" then + minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_1", param2=node.param2}) + time=0.1 + end + if node.name=="mesecons_delayer:delayer_on_2" then + minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_2", param2=node.param2}) + time=0.3 + end + if node.name=="mesecons_delayer:delayer_on_3" then + minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_3", param2=node.param2}) + time=0.5 + end + if node.name=="mesecons_delayer:delayer_on_4" then + minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_4", param2=node.param2}) + time=1 end + minetest.after(time, mesecon.delayer_turnoff, {pos=pos, param2=node.param2}) end end |