aboutsummaryrefslogtreecommitdiff
path: root/signals.lua
diff options
context:
space:
mode:
authororwell96 <mono96.mml@gmail.com>2016-09-13 18:05:59 +0200
committerorwell96 <mono96.mml@gmail.com>2016-09-13 18:05:59 +0200
commitc4a26de487091b95a891d739a89656cacba109d4 (patch)
treef3c567fc0beb51aec7a003a9f4077a782f3bd9bf /signals.lua
parenta93fb4345e084a0fc67656b85084d9841a3c5ec9 (diff)
downloadadvtrains-c4a26de487091b95a891d739a89656cacba109d4.tar.gz
advtrains-c4a26de487091b95a891d739a89656cacba109d4.tar.bz2
advtrains-c4a26de487091b95a891d739a89656cacba109d4.zip
various improvements on signals and bumpers
Diffstat (limited to 'signals.lua')
-rw-r--r--signals.lua128
1 files changed, 72 insertions, 56 deletions
diff --git a/signals.lua b/signals.lua
index 803b1a7..8be65e0 100644
--- a/signals.lua
+++ b/signals.lua
@@ -1,60 +1,76 @@
--advtrains by orwell96
--signals.lua
-
for r,f in pairs({on="off", off="on"}) do
- minetest.register_node("advtrains:retrosignal_"..r, {
- drawtype = "mesh",
- paramtype="light",
- paramtype2="facedir",
- walkable = false,
- selection_box = {
- type = "fixed",
- fixed = {-1/4, -1/2, -1/4, 1/4, 2, 1/4},
- },
- mesh = "advtrains_retrosignal_"..r..".b3d",
- tiles = {"advtrains_retrosignal.png"},
- description="Lampless Signal ("..r..")",
- on_rightclick=switchfunc,
- sunlight_propagates=true,
- groups = {
- choppy=3,
- not_blocking_trains=1
- },
- mesecons = {effector = {
- ["action_"..f] = function (pos, node)
- minetest.swap_node(pos, {name = "advtrains:retrosignal_"..f, param2 = node.param2})
- end
- }},
- on_rightclick=function(pos, node, clicker)
- minetest.swap_node(pos, {name = "advtrains:retrosignal_"..f, param2 = node.param2})
- end,
- })
- minetest.register_node("advtrains:signal_"..r, {
- drawtype = "mesh",
- paramtype="light",
- paramtype2="facedir",
- walkable = false,
- selection_box = {
- type = "fixed",
- fixed = {-1/4, -1/2, -1/4, 1/4, 2, 1/4},
- },
- mesh = "advtrains_signal.b3d",
- tiles = {"advtrains_signal_"..r..".png"},
- description="Signal ("..r..")",
- on_rightclick=switchfunc,
- groups = {
- choppy=3,
- not_blocking_trains=1
- },
- light_source = 1,
- sunlight_propagates=true,
- mesecons = {effector = {
- ["action_"..f] = function (pos, node)
- minetest.swap_node(pos, {name = "advtrains:signal_"..f, param2 = node.param2})
- end
- }},
- on_rightclick=function(pos, node, clicker)
- minetest.swap_node(pos, {name = "advtrains:signal_"..f, param2 = node.param2})
- end,
- })
+
+ advtrains.trackplacer.register_tracktype("advtrains:retrosignal", "")
+ advtrains.trackplacer.register_tracktype("advtrains:signal", "")
+
+ for rotid, rotation in ipairs({"", "_30", "_45", "_60"}) do
+ local crea=1
+ if rotid==1 and r=="off" then crea=0 end
+
+ minetest.register_node("advtrains:retrosignal_"..r..rotation, {
+ drawtype = "mesh",
+ paramtype="light",
+ paramtype2="facedir",
+ walkable = false,
+ selection_box = {
+ type = "fixed",
+ fixed = {-1/4, -1/2, -1/4, 1/4, 2, 1/4},
+ },
+ mesh = "advtrains_retrosignal_"..r..rotation..".b3d",
+ tiles = {"advtrains_retrosignal.png"},
+ inventory_image="advtrains_retrosignal_inv.png",
+ drop="advtrains:retrosignal_off",
+ description="Lampless Signal ("..r..rotation..")",
+ on_rightclick=switchfunc,
+ sunlight_propagates=true,
+ groups = {
+ choppy=3,
+ not_blocking_trains=1,
+ not_in_creative_inventory=crea,
+ },
+ mesecons = {effector = {
+ ["action_"..f] = function (pos, node)
+ minetest.swap_node(pos, {name = "advtrains:retrosignal_"..f..rotation, param2 = node.param2})
+ end
+ }},
+ on_rightclick=function(pos, node, clicker)
+ minetest.swap_node(pos, {name = "advtrains:retrosignal_"..f..rotation, param2 = node.param2})
+ end,
+ })
+ advtrains.trackplacer.add_worked("advtrains:retrosignal", r, rotation, nil)
+ minetest.register_node("advtrains:signal_"..r..rotation, {
+ drawtype = "mesh",
+ paramtype="light",
+ paramtype2="facedir",
+ walkable = false,
+ selection_box = {
+ type = "fixed",
+ fixed = {-1/4, -1/2, -1/4, 1/4, 2, 1/4},
+ },
+ mesh = "advtrains_signal"..rotation..".b3d",
+ tiles = {"advtrains_signal_"..r..".png"},
+ inventory_image="advtrains_signal_inv.png",
+ drop="advtrains:signal_off",
+ description="Signal ("..r..rotation..")",
+ on_rightclick=switchfunc,
+ groups = {
+ choppy=3,
+ not_blocking_trains=1,
+ not_in_creative_inventory=crea,
+ },
+ light_source = 1,
+ sunlight_propagates=true,
+ mesecons = {effector = {
+ ["action_"..f] = function (pos, node)
+ minetest.swap_node(pos, {name = "advtrains:signal_"..f..rotation, param2 = node.param2})
+ end
+ }},
+ on_rightclick=function(pos, node, clicker)
+ minetest.swap_node(pos, {name = "advtrains:signal_"..f..rotation, param2 = node.param2})
+ end,
+ })
+ advtrains.trackplacer.add_worked("advtrains:signal", r, rotation, nil)
+ end
end