diff options
author | webdesigner97 <Christian_D_97@gmx.de> | 2014-04-24 15:12:35 +0200 |
---|---|---|
committer | webdesigner97 <Christian_D_97@gmx.de> | 2014-04-24 15:12:35 +0200 |
commit | ddb4be140117fabf39a6d8162cda662b103e0712 (patch) | |
tree | f7f79750cdd69225cfa47b57154a0b4e3cd4746a /trafficlight | |
parent | 15c9df485d8211f89cd643bb0677c6c464254193 (diff) | |
download | roads-ddb4be140117fabf39a6d8162cda662b103e0712.tar roads-ddb4be140117fabf39a6d8162cda662b103e0712.tar.gz roads-ddb4be140117fabf39a6d8162cda662b103e0712.tar.bz2 roads-ddb4be140117fabf39a6d8162cda662b103e0712.tar.xz roads-ddb4be140117fabf39a6d8162cda662b103e0712.zip |
starting adding trafficlight commands
Diffstat (limited to 'trafficlight')
-rw-r--r-- | trafficlight/init.lua | 70 | ||||
-rw-r--r-- | trafficlight/pole.lua | 27 |
2 files changed, 85 insertions, 12 deletions
diff --git a/trafficlight/init.lua b/trafficlight/init.lua index 182a3a8..aee4353 100644 --- a/trafficlight/init.lua +++ b/trafficlight/init.lua @@ -18,6 +18,54 @@ streets.tlBox = { {-0.125,-0.3125,0.3125,-0.0625,-0.25,0.5}, --nodebox10 } +streets.rules_pole = +{ + {x= 0, y= 0, z=-1}, + {x= 1, y= 0, z= 0}, + {x=-1, y= 0, z= 0}, + {x= 0, y= 0, z= 1}, + {x= 1, y= 1, z= 0}, + {x= 1, y=-1, z= 0}, + {x=-1, y= 1, z= 0}, + {x=-1, y=-1, z= 0}, + {x= 0, y= 1, z= 1}, + {x= 0, y=-1, z= 1}, + {x= 0, y= 1, z=-1}, + {x= 0, y=-1, z=-1}, + {x= 0, y=-1, z= 0}, + {x= 0, y= 1, z= 0} +} + +streets.on_digiline_receive = function(pos, node, channel, msg) + local setchan = minetest.get_meta(pos):get_string("channel") + if setchan ~= channel then + return + end + -- Tl states + if msg == "OFF" then + + elseif msg == "GREEN" then + + elseif msg == "RED" then + local fd = minetest.get_node(pos).param2 + minetest.set_node(pos, {name = "streets:trafficlight_top_red", param2 = fd}) + elseif msg == "WARN" then + + end +end + +minetest.register_node(":streets:digiline_distributor",{ + description = S("Digiline distributor"), + tiles = {"streets_lampcontroller_top.png","streets_lampcontroller_bottom.png","streets_lampcontroller_sides.png"}, + groups = {cracky = 1}, + digiline = { + receptor = {}, + effector = {}, + wire = { + rules = streets.rules_pole + } + } +}) minetest.register_node(":streets:trafficlight_top_off",{ description = S("Trafficlight"), @@ -33,6 +81,23 @@ minetest.register_node(":streets:trafficlight_top_off",{ fixed = streets.tlBox }, tiles = {"streets_tl_bg.png","streets_tl_bg.png","streets_tl_bg.png","streets_tl_bg.png","streets_tl_bg.png","streets_tl_off.png"}, + digiline = { + receptor = {}, + effector = { + action = function(pos, node, channel, msg) + streets.on_digiline_receive(pos, node, channel, msg) + end + } + }, + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", "field[channel;Channel;${channel}]") + end, + on_receive_fields = function(pos, formname, fields, sender) + if (fields.channel) then + minetest.get_meta(pos):set_string("channel", fields.channel) + end + end, }) minetest.register_node(":streets:trafficlight_top_red",{ @@ -48,7 +113,6 @@ minetest.register_node(":streets:trafficlight_top_red",{ type = "fixed", fixed = streets.tlBox }, - pointable = false, light_source = 6, }) @@ -65,7 +129,6 @@ minetest.register_node(":streets:trafficlight_top_yellow",{ type = "fixed", fixed = streets.tlBox }, - pointable = false, light_source = 6, }) @@ -82,7 +145,6 @@ minetest.register_node(":streets:trafficlight_top_redyellow",{ type = "fixed", fixed = streets.tlBox }, - pointable = false, light_source = 6, }) @@ -99,7 +161,6 @@ minetest.register_node(":streets:trafficlight_top_green",{ type = "fixed", fixed = streets.tlBox }, - pointable = false, light_source = 6, }) @@ -119,6 +180,5 @@ minetest.register_node(":streets:trafficlight_top_warn",{ type = "fixed", fixed = streets.tlBox }, - pointable = false, light_source = 6, })
\ No newline at end of file diff --git a/trafficlight/pole.lua b/trafficlight/pole.lua index ab5e788..46d77aa 100644 --- a/trafficlight/pole.lua +++ b/trafficlight/pole.lua @@ -1,6 +1,20 @@ --[[ StreetsMod: inDev Trafficlights ]] +minetest.register_node(":digiline_vertical:wire", { + description = "Vertical digiline", + tiles = {"default_brick.png"}, + wield_image = "digiline_std_inv.png", + paramtype = "light", + digiline = + { + wire = + { + rules = streets.rules_pole + } + }, + groups = {dig_immediate = 3} +}) minetest.register_node(":streets:bigpole", { description = "Pole", paramtype = "light", @@ -11,16 +25,15 @@ minetest.register_node(":streets:bigpole", { node_box = { type = "fixed", fixed = { - {-0.15, -1.15, -0.15, 0.15, 1.15, 0.15} - } - }, - selection_box = { - type = "fixed", - fixed = { {-0.15, -0.5, -0.15, 0.15, 0.5, 0.15} } }, - on_place = minetest.rotate_node + on_place = minetest.rotate_node, + digiline = { + wire = { + rules = streets.rules_pole + } + } }) minetest.register_node(":streets:bigpole_edge", { drop = "streets:bigpole", |