summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2016-01-14 13:42:44 -0600
committercheapie <no-email-for-you@example.com>2016-01-14 13:43:30 -0600
commit425fefd4812356d5a356a6ec0edeefd066fa0616 (patch)
tree9d0d78b4e6af99cf4b05fcc981b24a216df2be24
parentbd608bcb020d224f51eb06c0965e583502a4f790 (diff)
downloadroads-425fefd4812356d5a356a6ec0edeefd066fa0616.tar
roads-425fefd4812356d5a356a6ec0edeefd066fa0616.tar.gz
roads-425fefd4812356d5a356a6ec0edeefd066fa0616.tar.bz2
roads-425fefd4812356d5a356a6ec0edeefd066fa0616.tar.xz
roads-425fefd4812356d5a356a6ec0edeefd066fa0616.zip
Make the lane control lights work and add a downward-pointing yellow arrow
-rw-r--r--infrastructure/advanced_lane_control_lights.lua60
-rw-r--r--infrastructure/textures/infrastructure_lane_control_lights_6.pngbin0 -> 4160 bytes
2 files changed, 36 insertions, 24 deletions
diff --git a/infrastructure/advanced_lane_control_lights.lua b/infrastructure/advanced_lane_control_lights.lua
index ff9d0f5..195f809 100644
--- a/infrastructure/advanced_lane_control_lights.lua
+++ b/infrastructure/advanced_lane_control_lights.lua
@@ -1,20 +1,6 @@
-- Lane control lights
-function lane_control_change(pos, node)
- local node = minetest.env:get_node(pos)
- if node.name == "infrastructure:lane_control_lights_1" then
- minetest.swap_node(pos, {name = "infrastructure:lane_control_lights_2", param2 = node.param2})
- elseif node.name == "infrastructure:lane_control_lights_2" then
- minetest.swap_node(pos, {name = "infrastructure:lane_control_lights_3", param2 = node.param2})
- elseif node.name == "infrastructure:lane_control_lights_3" then
- minetest.swap_node(pos, {name = "infrastructure:lane_control_lights_4", param2 = node.param2})
- elseif node.name == "infrastructure:lane_control_lights_4" then
- minetest.swap_node(pos, {name = "infrastructure:lane_control_lights_5", param2 = node.param2})
- elseif node.name == "infrastructure:lane_control_lights_5" then
- minetest.swap_node(pos, {name = "infrastructure:lane_control_lights_1", param2 = node.param2})
- end
-end
-for i = 1, 5 do
+for i = 1, 6 do
local groups = {}
if i == 1 then
groups = {cracky = 3}
@@ -35,6 +21,10 @@ for i = 1, 5 do
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
+ on_construct = function(pos)
+ local meta = minetest.get_meta(pos)
+ meta:set_string("formspec", "field[channel;Channel;${channel}]")
+ end,
groups = {cracky = 3, not_in_creative_inventory = (i == 1 and 0 or 1)},
light_source = TRAFFIC_LIGHTS_LIGHT_RANGE,
drop = "infrastructure:lane_control_lights_1",
@@ -63,16 +53,38 @@ for i = 1, 5 do
}
},
-
- on_punch = function(pos, node)
- lane_control_change(pos, node)
+ on_receive_fields = function(pos, formname, fields)
+ if (fields.channel) then
+ minetest.get_meta(pos):set_string("channel", fields.channel)
+ end
end,
-
- mesecons = {effector = {
- action_on = function (pos, node)
- lane_control_change(pos, node)
- end,
- }}
+ digiline = {
+ receptor = {},
+ effector = {
+ action = function(pos, node, channel, msg)
+ local setchan = minetest.get_meta(pos):get_string("channel")
+ if setchan ~= channel then
+ return
+ end
+ msg = msg:lower()
+ if (msg=="off") then
+ node.name = "infrastructure:lane_control_lights_1"
+ elseif (msg=="green") then
+ node.name = "infrastructure:lane_control_lights_3"
+ elseif (msg=="red") then
+ node.name = "infrastructure:lane_control_lights_2"
+ elseif (msg=="yellowleft") then
+ node.name = "infrastructure:lane_control_lights_5"
+ elseif (msg=="yellowright") then
+ node.name = "infrastructure:lane_control_lights_4"
+ elseif (msg=="yellow") then
+ node.name = "infrastructure:lane_control_lights_6"
+ end
+ minetest.set_node(pos,node)
+ minetest.get_meta(pos):set_string("channel",setchan)
+ end
+ }
+ }
})
end
diff --git a/infrastructure/textures/infrastructure_lane_control_lights_6.png b/infrastructure/textures/infrastructure_lane_control_lights_6.png
new file mode 100644
index 0000000..6e149d7
--- /dev/null
+++ b/infrastructure/textures/infrastructure_lane_control_lights_6.png
Binary files differ