Only switch state if it is different from the new one

master
Christian Danscheid 2013-08-13 20:26:19 +02:00
parent 1d6282707e
commit 83c2b3b0e3
1 changed files with 4 additions and 4 deletions

View File

@ -63,25 +63,25 @@ minetest.register_node(":streets:trafficlight_bottom",{
-- Modify <pos> to the top node of the trafficlight
pos.y = pos.y + 2
--
if msg == "red" then
if msg == "red" and state ~= "red" then
minetest.set_node(pos,{name = "streets:trafficlight_top_yellow",param2=facedir})
minetest.after(3,function(param)
minetest.set_node(pos,{name = "streets:trafficlight_top_red",param2=facedir})
end)
end
--
if msg == "green" then
if msg == "green" and state ~= "green" then
minetest.set_node(pos,{name = "streets:trafficlight_top_redyellow",param2=facedir})
minetest.after(3,function(param)
minetest.set_node(pos,{name = "streets:trafficlight_top_green",param2=facedir})
end)
end
--
if msg == "off" then
if msg == "off" and state ~= "off" then
minetest.set_node(pos,{name = "streets:trafficlight_top_off",param2=facedir})
end
--
if msg == "warn" then
if msg == "warn" and state ~= "warn" then
minetest.set_node(pos,{name = "streets:trafficlight_top_warn",param2=facedir})
end
end