cut set_gate in half

This commit is contained in:
Kyle 2012-09-01 18:26:15 -07:00
parent 9af83593ac
commit dc3fc4deb5
1 changed files with 15 additions and 22 deletions

View File

@ -87,31 +87,24 @@ function set_gate(pos, on)
gate = get_gate(pos) gate = get_gate(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.env:get_meta(pos)
local rules = {{x=1, y=0, z=0}} local rules = {{x=1, y=0, z=0}}
if on then if on ~= gate_state(pos) then
if not gate_state(pos) then yc_heat(meta)
yc_heat(meta) minetest.after(0.5, yc_cool, meta)
minetest.after(0.5, yc_cool, meta) if yc_overheat(meta) then
if yc_overheat(meta) then pop_gate(pos)
pop_gate(pos) else
heat = meta:get_int("heat")
if on then
onoff = "_on"
else else
heat = meta:get_int("heat") onoff = "_off"
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)
end end
end minetest.env:add_node(pos, {name="mesecons_gates:"..gate..onoff})
else local meta2 = minetest.env:get_meta(pos)
if gate_state(pos) then meta2:set_int("heat", heat)
yc_heat(meta) if on then
minetest.after(0.5, yc_cool, meta) mesecon:receptor_on(pos, rules)
if yc_overheat(meta) then
pop_gate(pos)
else 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) mesecon:receptor_off(pos, rules)
end end
end end