diff options
-rw-r--r-- | infrastructure/advanced_lane_control_lights.lua | 60 | ||||
-rw-r--r-- | infrastructure/textures/infrastructure_lane_control_lights_6.png | bin | 0 -> 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 Binary files differnew file mode 100644 index 0000000..6e149d7 --- /dev/null +++ b/infrastructure/textures/infrastructure_lane_control_lights_6.png |