summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2017-01-17 18:45:43 -0600
committercheapie <no-email-for-you@example.com>2017-01-17 18:45:43 -0600
commit9751b4853ea6dbaf820b2f8cdb75cfd31b3cc46e (patch)
tree906fbeeb3aab3412018c207c76db61e262a9aed4
parentca83b3e5010274dbe0d65e8cd7ea75fc82a5bdad (diff)
downloadroads-9751b4853ea6dbaf820b2f8cdb75cfd31b3cc46e.tar
roads-9751b4853ea6dbaf820b2f8cdb75cfd31b3cc46e.tar.gz
roads-9751b4853ea6dbaf820b2f8cdb75cfd31b3cc46e.tar.bz2
roads-9751b4853ea6dbaf820b2f8cdb75cfd31b3cc46e.tar.xz
roads-9751b4853ea6dbaf820b2f8cdb75cfd31b3cc46e.zip
Add countdown pedestrian signals
-rw-r--r--trafficlight/init.lua89
-rw-r--r--trafficlight/textures/streets_pl_number_0l.pngbin0 -> 572 bytes
-rw-r--r--trafficlight/textures/streets_pl_number_0r.pngbin0 -> 615 bytes
-rw-r--r--trafficlight/textures/streets_pl_number_1l.pngbin0 -> 601 bytes
-rw-r--r--trafficlight/textures/streets_pl_number_1r.pngbin0 -> 602 bytes
-rw-r--r--trafficlight/textures/streets_pl_number_2l.pngbin0 -> 610 bytes
-rw-r--r--trafficlight/textures/streets_pl_number_2r.pngbin0 -> 610 bytes
-rw-r--r--trafficlight/textures/streets_pl_number_3l.pngbin0 -> 606 bytes
-rw-r--r--trafficlight/textures/streets_pl_number_3r.pngbin0 -> 610 bytes
-rw-r--r--trafficlight/textures/streets_pl_number_4l.pngbin0 -> 614 bytes
-rw-r--r--trafficlight/textures/streets_pl_number_4r.pngbin0 -> 620 bytes
-rw-r--r--trafficlight/textures/streets_pl_number_5l.pngbin0 -> 603 bytes
-rw-r--r--trafficlight/textures/streets_pl_number_5r.pngbin0 -> 621 bytes
-rw-r--r--trafficlight/textures/streets_pl_number_6l.pngbin0 -> 608 bytes
-rw-r--r--trafficlight/textures/streets_pl_number_6r.pngbin0 -> 618 bytes
-rw-r--r--trafficlight/textures/streets_pl_number_7l.pngbin0 -> 607 bytes
-rw-r--r--trafficlight/textures/streets_pl_number_7r.pngbin0 -> 620 bytes
-rw-r--r--trafficlight/textures/streets_pl_number_8l.pngbin0 -> 608 bytes
-rw-r--r--trafficlight/textures/streets_pl_number_8r.pngbin0 -> 611 bytes
-rw-r--r--trafficlight/textures/streets_pl_number_9l.pngbin0 -> 605 bytes
-rw-r--r--trafficlight/textures/streets_pl_number_9r.pngbin0 -> 613 bytes
-rw-r--r--trafficlight/textures/streets_pl_number_template.pngbin0 -> 669 bytes
-rw-r--r--trafficlight/textures/streets_pl_walk.pngbin628 -> 630 bytes
23 files changed, 89 insertions, 0 deletions
diff --git a/trafficlight/init.lua b/trafficlight/init.lua
index b842d11..b64af8a 100644
--- a/trafficlight/init.lua
+++ b/trafficlight/init.lua
@@ -84,6 +84,25 @@ streets.tlDigilineRules = {
{x= 0, y= 1, z= 0}
}
+local function ped_on_flash_start(pos)
+ local timer = minetest.get_node_timer(pos)
+ timer:set(99,0)
+end
+
+local function ped_on_flash_end(pos,record)
+ local objs = minetest.get_objects_inside_radius(pos,1.5)
+ for _,obj in pairs(objs) do
+ if obj:get_luaentity() and obj:get_luaentity().name == "streets:pedcountdown" then
+ obj:remove()
+ end
+ end
+ if not record then 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))
+ timer:stop()
+end
+
streets.tlSwitch = function(pos,to)
if not pos or not to then
return
@@ -100,6 +119,9 @@ streets.on_digiline_receive = function(pos, node, channel, msg)
local name = minetest.get_node(pos).name
if msg == "OFF" then
if name:find("pedlight") then
+ if name == "streets:pedlight_top_flashingdontwalk" then
+ ped_on_flash_end(pos,false)
+ end
streets.tlSwitch(pos,"streets:pedlight_top_off")
elseif name:find("extender_left") then
streets.tlSwitch(pos,"streets:trafficlight_top_extender_left_off")
@@ -118,6 +140,9 @@ streets.on_digiline_receive = function(pos, node, channel, msg)
end
elseif msg == "GREEN" then
if name:find("pedlight") then
+ if name == "streets:pedlight_top_flashingdontwalk" then
+ ped_on_flash_end(pos,false)
+ end
streets.tlSwitch(pos,"streets:pedlight_top_walk")
elseif name:find("extender_left") then
streets.tlSwitch(pos,"streets:trafficlight_top_extender_left_green")
@@ -136,6 +161,9 @@ streets.on_digiline_receive = function(pos, node, channel, msg)
end
elseif msg == "RED" then
if name:find("pedlight") then
+ if name == "streets:pedlight_top_flashingdontwalk" then
+ ped_on_flash_end(pos,true)
+ end
streets.tlSwitch(pos,"streets:pedlight_top_dontwalk")
elseif name:find("extender_left") then
streets.tlSwitch(pos,"streets:trafficlight_top_extender_left_off")
@@ -154,6 +182,9 @@ streets.on_digiline_receive = function(pos, node, channel, msg)
end
elseif msg == "WARN" then
if name:find("pedlight") then
+ if name ~= "streets:pedlight_top_flashingdontwalk" then
+ ped_on_flash_start(pos)
+ end
streets.tlSwitch(pos,"streets:pedlight_top_flashingdontwalk")
elseif name:find("extender_left") then
streets.tlSwitch(pos,"streets:trafficlight_top_extender_left_off")
@@ -172,6 +203,9 @@ streets.on_digiline_receive = function(pos, node, channel, msg)
end
elseif msg == "FLASHYELLOW" then
if name:find("pedlight") then
+ if name ~= "streets:pedlight_top_flashingdontwalk" then
+ ped_on_flash_start(pos)
+ end
streets.tlSwitch(pos,"streets:pedlight_top_flashingdontwalk")
elseif name:find("extender_left") then
streets.tlSwitch(pos,"streets:trafficlight_top_extender_left_flashyellow")
@@ -190,6 +224,9 @@ streets.on_digiline_receive = function(pos, node, channel, msg)
end
elseif msg == "YELLOW" then
if name:find("pedlight") then
+ if name ~= "streets:pedlight_top_flashingdontwalk" then
+ ped_on_flash_start(pos)
+ end
streets.tlSwitch(pos,"streets:pedlight_top_flashingdontwalk")
elseif name:find("extender_left") then
streets.tlSwitch(pos,"streets:trafficlight_top_extender_left_yellow")
@@ -208,6 +245,9 @@ streets.on_digiline_receive = function(pos, node, channel, msg)
end
elseif msg == "FLASHRED" then
if name:find("pedlight") then
+ if name ~= "streets:pedlight_top_flashingdontwalk" then
+ ped_on_flash_start(pos)
+ end
streets.tlSwitch(pos,"streets:pedlight_top_flashingdontwalk")
elseif name:find("extender_left") then
streets.tlSwitch(pos,"streets:trafficlight_top_extender_left_off")
@@ -893,6 +933,8 @@ minetest.register_node(":streets:trafficlight_top_extender_right_green",{
end,
})
+
+
minetest.register_node(":streets:pedlight_top_off",{
description = streets.S("Pedestrian Light"),
drawtype="nodebox",
@@ -1003,6 +1045,53 @@ minetest.register_node(":streets:pedlight_top_flashingdontwalk",{
},
})
+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"}
+})
+
+minetest.register_abm({
+ label = "Update pedestrian countdown time display",
+ nodenames = {"streets:pedlight_top_flashingdontwalk"},
+ interval = 1,
+ chance = 1,
+ catch_up = false,
+ action = function(pos,node)
+ local meta = minetest.get_meta(pos)
+ local timer = minetest.get_node_timer(pos)
+ local totaltime = meta:get_int("flashtime")
+ local timesofar = timer:get_elapsed()
+ local timeleft = math.max(0,totaltime-timesofar)
+ local objs = minetest.get_objects_inside_radius(pos,1.5)
+ for _,obj in pairs(objs) do
+ if obj:get_luaentity() and obj:get_luaentity().name == "streets:pedcountdown" then
+ obj:remove()
+ end
+ end
+ local backdir = minetest.facedir_to_dir(node.param2)
+ local frontdir = vector.multiply(backdir,-1)
+ local entpos = vector.add(vector.multiply(frontdir,-0.495),pos)
+ local entity = minetest.add_entity(entpos,"streets:pedcountdown")
+ local yaw = 0
+ if backdir.z == -1 then
+ yaw = math.pi
+ elseif backdir.x == 1 then
+ yaw = math.pi / 2
+ elseif backdir.x == -1 then
+ yaw = math.pi / -2
+ end
+ --Circles are hard...
+ entity:setyaw(yaw)
+
+ local ldigit = math.floor(timeleft/10)
+ local rdigit = timeleft % 10
+ local tex = string.format("streets_pl_number_%01dl.png^streets_pl_number_%01dr.png",ldigit,rdigit)
+ entity:set_properties({textures={tex}})
+ end
+})
+
for _,i in pairs({"","_left","_right"}) do
minetest.register_node(":streets:trafficlight_top"..i.."_off",{
diff --git a/trafficlight/textures/streets_pl_number_0l.png b/trafficlight/textures/streets_pl_number_0l.png
new file mode 100644
index 0000000..99fc263
--- /dev/null
+++ b/trafficlight/textures/streets_pl_number_0l.png
Binary files differ
diff --git a/trafficlight/textures/streets_pl_number_0r.png b/trafficlight/textures/streets_pl_number_0r.png
new file mode 100644
index 0000000..6f9b143
--- /dev/null
+++ b/trafficlight/textures/streets_pl_number_0r.png
Binary files differ
diff --git a/trafficlight/textures/streets_pl_number_1l.png b/trafficlight/textures/streets_pl_number_1l.png
new file mode 100644
index 0000000..e35735a
--- /dev/null
+++ b/trafficlight/textures/streets_pl_number_1l.png
Binary files differ
diff --git a/trafficlight/textures/streets_pl_number_1r.png b/trafficlight/textures/streets_pl_number_1r.png
new file mode 100644
index 0000000..b878ae6
--- /dev/null
+++ b/trafficlight/textures/streets_pl_number_1r.png
Binary files differ
diff --git a/trafficlight/textures/streets_pl_number_2l.png b/trafficlight/textures/streets_pl_number_2l.png
new file mode 100644
index 0000000..d439aa9
--- /dev/null
+++ b/trafficlight/textures/streets_pl_number_2l.png
Binary files differ
diff --git a/trafficlight/textures/streets_pl_number_2r.png b/trafficlight/textures/streets_pl_number_2r.png
new file mode 100644
index 0000000..dd9b4be
--- /dev/null
+++ b/trafficlight/textures/streets_pl_number_2r.png
Binary files differ
diff --git a/trafficlight/textures/streets_pl_number_3l.png b/trafficlight/textures/streets_pl_number_3l.png
new file mode 100644
index 0000000..bdab896
--- /dev/null
+++ b/trafficlight/textures/streets_pl_number_3l.png
Binary files differ
diff --git a/trafficlight/textures/streets_pl_number_3r.png b/trafficlight/textures/streets_pl_number_3r.png
new file mode 100644
index 0000000..da7de9a
--- /dev/null
+++ b/trafficlight/textures/streets_pl_number_3r.png
Binary files differ
diff --git a/trafficlight/textures/streets_pl_number_4l.png b/trafficlight/textures/streets_pl_number_4l.png
new file mode 100644
index 0000000..91d1ff4
--- /dev/null
+++ b/trafficlight/textures/streets_pl_number_4l.png
Binary files differ
diff --git a/trafficlight/textures/streets_pl_number_4r.png b/trafficlight/textures/streets_pl_number_4r.png
new file mode 100644
index 0000000..5468b00
--- /dev/null
+++ b/trafficlight/textures/streets_pl_number_4r.png
Binary files differ
diff --git a/trafficlight/textures/streets_pl_number_5l.png b/trafficlight/textures/streets_pl_number_5l.png
new file mode 100644
index 0000000..4d21bbd
--- /dev/null
+++ b/trafficlight/textures/streets_pl_number_5l.png
Binary files differ
diff --git a/trafficlight/textures/streets_pl_number_5r.png b/trafficlight/textures/streets_pl_number_5r.png
new file mode 100644
index 0000000..9992ed9
--- /dev/null
+++ b/trafficlight/textures/streets_pl_number_5r.png
Binary files differ
diff --git a/trafficlight/textures/streets_pl_number_6l.png b/trafficlight/textures/streets_pl_number_6l.png
new file mode 100644
index 0000000..92f64be
--- /dev/null
+++ b/trafficlight/textures/streets_pl_number_6l.png
Binary files differ
diff --git a/trafficlight/textures/streets_pl_number_6r.png b/trafficlight/textures/streets_pl_number_6r.png
new file mode 100644
index 0000000..ba84f54
--- /dev/null
+++ b/trafficlight/textures/streets_pl_number_6r.png
Binary files differ
diff --git a/trafficlight/textures/streets_pl_number_7l.png b/trafficlight/textures/streets_pl_number_7l.png
new file mode 100644
index 0000000..9328d86
--- /dev/null
+++ b/trafficlight/textures/streets_pl_number_7l.png
Binary files differ
diff --git a/trafficlight/textures/streets_pl_number_7r.png b/trafficlight/textures/streets_pl_number_7r.png
new file mode 100644
index 0000000..444ce49
--- /dev/null
+++ b/trafficlight/textures/streets_pl_number_7r.png
Binary files differ
diff --git a/trafficlight/textures/streets_pl_number_8l.png b/trafficlight/textures/streets_pl_number_8l.png
new file mode 100644
index 0000000..9a78cd8
--- /dev/null
+++ b/trafficlight/textures/streets_pl_number_8l.png
Binary files differ
diff --git a/trafficlight/textures/streets_pl_number_8r.png b/trafficlight/textures/streets_pl_number_8r.png
new file mode 100644
index 0000000..727afad
--- /dev/null
+++ b/trafficlight/textures/streets_pl_number_8r.png
Binary files differ
diff --git a/trafficlight/textures/streets_pl_number_9l.png b/trafficlight/textures/streets_pl_number_9l.png
new file mode 100644
index 0000000..4830e0f
--- /dev/null
+++ b/trafficlight/textures/streets_pl_number_9l.png
Binary files differ
diff --git a/trafficlight/textures/streets_pl_number_9r.png b/trafficlight/textures/streets_pl_number_9r.png
new file mode 100644
index 0000000..dabea2a
--- /dev/null
+++ b/trafficlight/textures/streets_pl_number_9r.png
Binary files differ
diff --git a/trafficlight/textures/streets_pl_number_template.png b/trafficlight/textures/streets_pl_number_template.png
new file mode 100644
index 0000000..41ae2f1
--- /dev/null
+++ b/trafficlight/textures/streets_pl_number_template.png
Binary files differ
diff --git a/trafficlight/textures/streets_pl_walk.png b/trafficlight/textures/streets_pl_walk.png
index 392f024..4a79e54 100644
--- a/trafficlight/textures/streets_pl_walk.png
+++ b/trafficlight/textures/streets_pl_walk.png
Binary files differ