diff options
Diffstat (limited to 'trafficlight')
-rw-r--r-- | trafficlight/init.lua | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/trafficlight/init.lua b/trafficlight/init.lua index b33154d..7e6051a 100644 --- a/trafficlight/init.lua +++ b/trafficlight/init.lua @@ -57,8 +57,14 @@ streets.tlSwitch = function(def) if not def.pos or not def.to or not streets.tlRythm[def.to] then return end + local meta = minetest.get_meta(def.pos) + -- Only switch if new state ~= current state + if "to" .. meta:get_string("state") == def.to then + return + end -- Switch the trafficlight for k, v in pairs(streets.tlRythm[def.to]) do + minetest.get_meta(def.pos):set_string("state", def.to:gsub("to", "")) minetest.after(v.pauseBefore, function() minetest.swap_node(def.pos, {name = v.name, param2 = minetest.get_node(def.pos).param2}) end) |