summaryrefslogtreecommitdiff
path: root/streets/trafficlight/old2new.lua
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2016-04-01 20:02:19 -0400
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2016-04-01 21:09:33 -0400
commitda66780a569712c23ae4f2996cfb4608a9f9d69d (patch)
tree217556029a78bc23ad4564720afc86de97228a04 /streets/trafficlight/old2new.lua
parent615b22df4d423aded3613db7716943a2f389b047 (diff)
downloaddreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar
dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar.gz
dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar.bz2
dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar.xz
dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.zip
copy all standard Dreambuilder mods in from the old subgame
(exactly as last supplied there, updates to these mods will follow later)
Diffstat (limited to 'streets/trafficlight/old2new.lua')
-rw-r--r--streets/trafficlight/old2new.lua58
1 files changed, 58 insertions, 0 deletions
diff --git a/streets/trafficlight/old2new.lua b/streets/trafficlight/old2new.lua
new file mode 100644
index 0000000..51ba9f3
--- /dev/null
+++ b/streets/trafficlight/old2new.lua
@@ -0,0 +1,58 @@
+--[[
+ StreetsMod: Convert old trafficlights
+]]
+minetest.register_node(":streets:trafficlight_bottom", {
+ diggable = false,
+ pointable = false,
+ drawtype = "airlike",
+ description = "I'm an old node, please drop me",
+ groups = {not_in_creative_inventory = 1}
+})
+minetest.register_abm({
+ nodenames = {"streets:trafficlight_bottom"},
+ interval = 1,
+ chance = 1,
+ action = function(pos, node)
+ minetest.log("action", "Converting trafficlight at position " .. minetest.pos_to_string(pos))
+ -- Replace controller with distributor
+ pos.y = pos.y - 2
+ minetest.set_node(pos, {name = "streets:digiline_distributor"})
+ -- Change bottom pole
+ pos.y = pos.y + 2
+ minetest.set_node(pos, {name = "streets:bigpole", param2 = 2})
+ -- Change middle pole
+ pos.y = pos.y + 1
+ minetest.set_node(pos, {name = "streets:bigpole", param2 = 2})
+ -- Change the top
+ pos.y = pos.y + 1
+ local fd = minetest.get_node(pos).param2
+ local ch = minetest.get_meta(pos):get_string("channel")
+ minetest.set_node(pos, {name = "streets:bigpole", param2 = 2})
+ -- Place new top
+ if fd == 1 then
+ minetest.set_node({x = pos.x - 1, y = pos.y, z = pos.z}, {name = "streets:trafficlight_top_warn", param2 = fd})
+ local meta = minetest.get_meta({x = pos.x - 1, y = pos.y, z = pos.z})
+ meta:set_string("channel", ch)
+ meta:set_string("state", "warn")
+ meta:set_string("formspec", "field[channel;Channel;${channel}]")
+ elseif fd == 2 then
+ minetest.set_node({x = pos.x, y = pos.y, z = pos.z + 1}, {name = "streets:trafficlight_top_warn", param2 = fd})
+ local meta = minetest.get_meta({x = pos.x, y = pos.y, z = pos.z + 1})
+ meta:set_string("channel", ch)
+ meta:set_string("state", "warn")
+ meta:set_string("formspec", "field[channel;Channel;${channel}]")
+ elseif fd == 3 then
+ minetest.set_node({x = pos.x + 1, y = pos.y, z = pos.z}, {name = "streets:trafficlight_top_warn", param2 = fd})
+ local meta = minetest.get_meta({x = pos.x + 1, y = pos.y, z = pos.z})
+ meta:set_string("channel", ch)
+ meta:set_string("state", "warn")
+ meta:set_string("formspec", "field[channel;Channel;${channel}]")
+ elseif fd == 0 then
+ minetest.set_node({x = pos.x, y = pos.y, z = pos.z - 1}, {name = "streets:trafficlight_top_warn", param2 = fd})
+ local meta = minetest.get_meta({x = pos.x, y = pos.y, z = pos.z - 1})
+ meta:set_string("channel", ch)
+ meta:set_string("state", "warn")
+ meta:set_string("formspec", "field[channel;Channel;${channel}]")
+ end
+ end
+}) \ No newline at end of file