summaryrefslogtreecommitdiff
path: root/mesecons_gates
diff options
context:
space:
mode:
authorKyle <kyle.kylina@gmail.com>2012-09-01 18:26:15 -0700
committerKyle <kyle.kylina@gmail.com>2012-09-01 18:26:15 -0700
commitdc3fc4deb5e6b4d68a10799fc623176f996bcc24 (patch)
tree631c5cff40ec0c7377187175be07f2f1ca203dc3 /mesecons_gates
parent9af83593ace4f035e5eee257ee4ff84d80ba8f39 (diff)
downloadmesecons-dc3fc4deb5e6b4d68a10799fc623176f996bcc24.tar
mesecons-dc3fc4deb5e6b4d68a10799fc623176f996bcc24.tar.gz
mesecons-dc3fc4deb5e6b4d68a10799fc623176f996bcc24.tar.bz2
mesecons-dc3fc4deb5e6b4d68a10799fc623176f996bcc24.tar.xz
mesecons-dc3fc4deb5e6b4d68a10799fc623176f996bcc24.zip
cut set_gate in half
Diffstat (limited to 'mesecons_gates')
-rw-r--r--mesecons_gates/init.lua37
1 files changed, 15 insertions, 22 deletions
diff --git a/mesecons_gates/init.lua b/mesecons_gates/init.lua
index b58e0bc..27719a4 100644
--- a/mesecons_gates/init.lua
+++ b/mesecons_gates/init.lua
@@ -87,31 +87,24 @@ function set_gate(pos, on)
gate = get_gate(pos)
local meta = minetest.env:get_meta(pos)
local rules = {{x=1, y=0, z=0}}
- if on then
- if not gate_state(pos) then
- yc_heat(meta)
- minetest.after(0.5, yc_cool, meta)
- if yc_overheat(meta) then
- pop_gate(pos)
+ if on ~= gate_state(pos) then
+ yc_heat(meta)
+ minetest.after(0.5, yc_cool, meta)
+ if yc_overheat(meta) then
+ pop_gate(pos)
+ else
+ heat = meta:get_int("heat")
+ if on then
+ onoff = "_on"
else
- heat = meta:get_int("heat")
- minetest.env:add_node(pos, {name="mesecons_gates:"..gate.."_on"})
- local meta2 = minetest.env:get_meta(pos)
- meta2:set_int("heat", heat)
- mesecon:receptor_on(pos, rules)
+ onoff = "_off"
end
- end
- else
- if gate_state(pos) then
- yc_heat(meta)
- minetest.after(0.5, yc_cool, meta)
- if yc_overheat(meta) then
- pop_gate(pos)
+ minetest.env:add_node(pos, {name="mesecons_gates:"..gate..onoff})
+ local meta2 = minetest.env:get_meta(pos)
+ meta2:set_int("heat", heat)
+ if on then
+ mesecon:receptor_on(pos, rules)
else
- heat = meta:get_int("heat")
- minetest.env:add_node(pos, {name="mesecons_gates:"..gate.."_off"})
- local meta2 = minetest.env:get_meta(pos)
- meta2:set_int("heat", heat)
mesecon:receptor_off(pos, rules)
end
end