From 83c2b3b0e35ddf25e0b36e1bebb9e4128511d597 Mon Sep 17 00:00:00 2001 From: Christian Danscheid Date: Tue, 13 Aug 2013 20:26:19 +0200 Subject: Only switch state if it is different from the new one --- trafficlight/init.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/trafficlight/init.lua b/trafficlight/init.lua index a915b0e..c085dd9 100644 --- a/trafficlight/init.lua +++ b/trafficlight/init.lua @@ -63,25 +63,25 @@ minetest.register_node(":streets:trafficlight_bottom",{ -- Modify 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 -- cgit v1.2.3