summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwebdesigner97 <Christian_D_97@gmx.de>2014-04-24 19:14:30 +0200
committerwebdesigner97 <Christian_D_97@gmx.de>2014-04-24 19:14:30 +0200
commit09c1f038f50404b136ab746a04c93c0b63b78429 (patch)
tree0c7aa2341a2c2c39df0c5931a0a7b6331d71ba8a
parentc5d50c321a102b3fd90671279b523adaa4e7f0ed (diff)
downloadroads-09c1f038f50404b136ab746a04c93c0b63b78429.tar
roads-09c1f038f50404b136ab746a04c93c0b63b78429.tar.gz
roads-09c1f038f50404b136ab746a04c93c0b63b78429.tar.bz2
roads-09c1f038f50404b136ab746a04c93c0b63b78429.tar.xz
roads-09c1f038f50404b136ab746a04c93c0b63b78429.zip
small improvments
-rw-r--r--trafficlight/init.lua6
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)