summaryrefslogtreecommitdiff
path: root/trafficlight
diff options
context:
space:
mode:
authorChristian Danscheid <Christian_D_97@gmx.de>2013-08-12 10:37:13 +0200
committerChristian Danscheid <Christian_D_97@gmx.de>2013-08-12 10:37:13 +0200
commitc994ac532695a214881bd3ee47842db65700fe0a (patch)
tree13130207b0aeb1c1c7b411c18e194f5c8f30eed2 /trafficlight
parent8f7101f92c4412159bf93b529dd449bfe9552e11 (diff)
downloadroads-c994ac532695a214881bd3ee47842db65700fe0a.tar
roads-c994ac532695a214881bd3ee47842db65700fe0a.tar.gz
roads-c994ac532695a214881bd3ee47842db65700fe0a.tar.bz2
roads-c994ac532695a214881bd3ee47842db65700fe0a.tar.xz
roads-c994ac532695a214881bd3ee47842db65700fe0a.zip
Prepared digiline listening code
Diffstat (limited to 'trafficlight')
-rw-r--r--trafficlight/init.lua20
1 files changed, 19 insertions, 1 deletions
diff --git a/trafficlight/init.lua b/trafficlight/init.lua
index d7b093b..bec4410 100644
--- a/trafficlight/init.lua
+++ b/trafficlight/init.lua
@@ -29,13 +29,31 @@ minetest.register_node(":streets:trafficlight_bottom",{
minetest.chat_send_player(placer:get_player_name(),"Not enough vertical space! The traffic light has a height of 3 blocks.")
minetest.remove_node(pos)
end
+ --
+ pos.y = pos.y - 2
+ local meta = minetest.get_meta(pos)
+ meta:set_string("formspec", "field[channel;Channel;${channel}]")
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
pos.y = pos.y + 1
minetest.remove_node(pos)
pos.y = pos.y + 1
minetest.remove_node(pos)
- end
+ end,
+ on_receive_fields = function(pos, formname, fields, sender)
+ minetest.env:get_meta(pos):set_string("channel", fields.channel)
+ end,
+ digiline = {
+ receptor = {},
+ effector = {
+ action = function(pos,node,channel,msg)
+ local setchannel = minetest.get_meta(pos):get_string("channel")
+ if channel == setchannel then
+ -- Trafficlight code goes here
+ end
+ end
+ }
+ }
})
minetest.register_node(":streets:trafficlight_middle",{