summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2017-01-25 14:24:37 -0600
committercheapie <no-email-for-you@example.com>2017-01-25 14:24:37 -0600
commit0c270e76ef248202bd5edfdd1de2b7c4a83b7a1d (patch)
tree1c792b1239f75a331b3aff9d5f585a5acef1546e
parent87fa05ad6a9e76c477787393a4740b73a987b5a2 (diff)
downloadroads-0c270e76ef248202bd5edfdd1de2b7c4a83b7a1d.tar
roads-0c270e76ef248202bd5edfdd1de2b7c4a83b7a1d.tar.gz
roads-0c270e76ef248202bd5edfdd1de2b7c4a83b7a1d.tar.bz2
roads-0c270e76ef248202bd5edfdd1de2b7c4a83b7a1d.tar.xz
roads-0c270e76ef248202bd5edfdd1de2b7c4a83b7a1d.zip
Improve pedestrian signal reliability
-rw-r--r--trafficlight/init.lua16
1 files changed, 13 insertions, 3 deletions
diff --git a/trafficlight/init.lua b/trafficlight/init.lua
index 0754ebd..2b2038b 100644
--- a/trafficlight/init.lua
+++ b/trafficlight/init.lua
@@ -104,10 +104,20 @@ local function ped_on_flash_end(pos,record)
obj:remove()
end
end
- if not record then return end
+ if not record then
+ timer:stop()
+ return
+ end
local timer = minetest.get_node_timer(pos)
local meta = minetest.get_meta(pos)
- meta:set_int("flashtime",math.min(timer:get_elapsed(),99))
+ local lastflashtime = meta:get_int("lastflashtime")
+ local twoflashesago = meta:get_int("twoflashesago")
+ local flashtime = math.min(timer:get_elapsed(),99)
+ meta:set_int("twoflashesago",lastflashtime)
+ meta:set_int("lastflashtime",flashtime)
+ if math.abs(twoflashesago-lastflashtime) + math.abs(lastflashtime-flashtime) < 3 then
+ meta:set_int("flashtime",flashtime)
+ end
timer:stop()
end
@@ -1071,7 +1081,7 @@ minetest.register_entity(":streets:pedcountdown",{
physical = false,
collisionbox = {0,0,0,0,0,0},
visual = "upright_sprite",
- textures = {"streets_pl_number_9l.png^streets_pl_number_9r.png"}
+ textures = {"streets_pl_number_0l.png"}
})
minetest.register_abm({