aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororwell96 <mono96.mml@gmail.com>2017-02-03 14:14:45 +0100
committerorwell96 <mono96.mml@gmail.com>2017-02-03 14:14:45 +0100
commitf74ef2a45693f89537e44e92fcee971b78a2f513 (patch)
treee1a58e2687130219a6f41f16f36c76586c063c8c
parent82efe2e773e5c8d18e948811ef3d9d1df1c95157 (diff)
downloadadvtrains-f74ef2a45693f89537e44e92fcee971b78a2f513.tar.gz
advtrains-f74ef2a45693f89537e44e92fcee971b78a2f513.tar.bz2
advtrains-f74ef2a45693f89537e44e92fcee971b78a2f513.zip
add wallmounted light signal
-rw-r--r--advtrains/advtrains/models/advtrains_signal_wall_l.b3dbin0 -> 40514 bytes
-rw-r--r--advtrains/advtrains/models/advtrains_signal_wall_r.b3dbin0 -> 40514 bytes
-rw-r--r--advtrains/advtrains/signals.lua114
-rw-r--r--advtrains/advtrains/textures/advtrains_signal_wall_off.pngbin0 -> 3056 bytes
-rw-r--r--advtrains/advtrains/textures/advtrains_signal_wall_on.pngbin0 -> 3043 bytes
-rw-r--r--assets/signal_wall.blendbin0 -> 512620 bytes
-rw-r--r--assets/signal_wall.blend1bin0 -> 512620 bytes
-rw-r--r--assets/signal_wall.pngbin0 -> 107155 bytes
8 files changed, 114 insertions, 0 deletions
diff --git a/advtrains/advtrains/models/advtrains_signal_wall_l.b3d b/advtrains/advtrains/models/advtrains_signal_wall_l.b3d
new file mode 100644
index 0000000..b1bcbcf
--- /dev/null
+++ b/advtrains/advtrains/models/advtrains_signal_wall_l.b3d
Binary files differ
diff --git a/advtrains/advtrains/models/advtrains_signal_wall_r.b3d b/advtrains/advtrains/models/advtrains_signal_wall_r.b3d
new file mode 100644
index 0000000..cf26389
--- /dev/null
+++ b/advtrains/advtrains/models/advtrains_signal_wall_r.b3d
Binary files differ
diff --git a/advtrains/advtrains/signals.lua b/advtrains/advtrains/signals.lua
index b475d3c..cdf610e 100644
--- a/advtrains/advtrains/signals.lua
+++ b/advtrains/advtrains/signals.lua
@@ -1,5 +1,33 @@
--advtrains by orwell96
--signals.lua
+
+--this code /should/ work but does not.
+local mrules_wallsignal_l, mrules_wallsignal_r
+if mesecon then
+ mrules_wallsignal_l = function(node, isright)
+ local rules = mesecon.rules.buttonlike
+ if node.param2 == 1 then
+ rules=mesecon.rotate_rules_left(rules)
+ elseif node.param2 == 2 then
+ rules=mesecon.rotate_rules_right(mesecon.rotate_rules_right(rules))
+ elseif node.param2 == 3 then
+ rules=mesecon.rotate_rules_right(rules)
+ end
+ return rules
+ end
+ mrules_wallsignal_r = function(node)
+ local rules = mesecon.rules.buttonlike
+ if node.param2 == 3 then
+ rules=mesecon.rotate_rules_left(rules)
+ elseif node.param2 == 0 then
+ rules=mesecon.rotate_rules_right(mesecon.rotate_rules_right(rules))
+ elseif node.param2 == 1 then
+ rules=mesecon.rotate_rules_right(rules)
+ end
+ return rules
+ end
+end
+
for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red", als="green"}}) do
advtrains.trackplacer.register_tracktype("advtrains:retrosignal", "")
@@ -32,6 +60,7 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
save_in_nodedb=1,
},
mesecons = {effector = {
+ rules=advtrains.meseconrules,
["action_"..f.as] = function (pos, node)
advtrains.ndb.swap_node(pos, {name = "advtrains:retrosignal_"..f.as..rotation, param2 = node.param2})
end
@@ -65,6 +94,7 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
light_source = 1,
sunlight_propagates=true,
mesecons = {effector = {
+ rules=advtrains.meseconrules,
["action_"..f.as] = function (pos, node)
advtrains.ndb.swap_node(pos, {name = "advtrains:signal_"..f.as..rotation, param2 = node.param2})
end
@@ -83,4 +113,88 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
})
advtrains.trackplacer.add_worked("advtrains:signal", r, rotation, nil)
end
+
+ local crea=1
+ if r=="off" then crea=0 end
+
+ --tunnel signals. no rotations.
+ minetest.register_node("advtrains:signal_wall_l_"..r, {
+ drawtype = "mesh",
+ paramtype="light",
+ paramtype2="facedir",
+ walkable = false,
+ selection_box = {
+ type = "fixed",
+ fixed = {-1/2, -1/2, -1/4, 0, 1/2, 1/4},
+ },
+ mesh = "advtrains_signal_wall_l.b3d",
+ tiles = {"advtrains_signal_wall_"..r..".png"},
+ drop="advtrains:signal_wall_l_off",
+ description=attrans("Wallmounted Signal, left"),
+ groups = {
+ choppy=3,
+ not_blocking_trains=1,
+ not_in_creative_inventory=crea,
+ save_in_nodedb=1,
+ },
+ light_source = 1,
+ sunlight_propagates=true,
+ mesecons = {effector = {
+ mrules_wallsignal_l,
+ ["action_"..f.as] = function (pos, node)
+ advtrains.ndb.swap_node(pos, {name = "advtrains:signal_wall_l_"..f.as, param2 = node.param2})
+ end
+ }},
+ luaautomation = {
+ getstate = f.ls,
+ setstate = function(pos, node, newstate)
+ if newstate == f.als then
+ advtrains.ndb.swap_node(pos, {name = "advtrains:signal_wall_l_"..f.as, param2 = node.param2})
+ end
+ end,
+ },
+ on_rightclick=function(pos, node, clicker)
+ advtrains.ndb.swap_node(pos, {name = "advtrains:signal_wall_l_"..f.as, param2 = node.param2})
+ end,
+ })
+ minetest.register_node("advtrains:signal_wall_r_"..r, {
+ drawtype = "mesh",
+ paramtype="light",
+ paramtype2="facedir",
+ walkable = false,
+ selection_box = {
+ type = "fixed",
+ fixed = {0, -1/2, -1/4, 1/2, 1/2, 1/4},
+ },
+ mesh = "advtrains_signal_wall_r.b3d",
+ tiles = {"advtrains_signal_wall_"..r..".png"},
+ drop="advtrains:signal_wall_r_off",
+ description=attrans("Wallmounted Signal, right"),
+ groups = {
+ choppy=3,
+ not_blocking_trains=1,
+ not_in_creative_inventory=crea,
+ save_in_nodedb=1,
+ },
+ light_source = 1,
+ sunlight_propagates=true,
+ mesecons = {effector = {
+ rules = mrules_wallsignal_r,
+ ["action_"..f.as] = function (pos, node)
+ advtrains.ndb.swap_node(pos, {name = "advtrains:signal_wall_r_"..f.as, param2 = node.param2})
+ end
+ }},
+ luaautomation = {
+ getstate = f.ls,
+ setstate = function(pos, node, newstate)
+ if newstate == f.als then
+ advtrains.ndb.swap_node(pos, {name = "advtrains:signal_wall_r_"..f.as, param2 = node.param2})
+ end
+ end,
+ },
+ on_rightclick=function(pos, node, clicker)
+ advtrains.ndb.swap_node(pos, {name = "advtrains:signal_wall_r_"..f.as, param2 = node.param2})
+ end,
+ })
+
end
diff --git a/advtrains/advtrains/textures/advtrains_signal_wall_off.png b/advtrains/advtrains/textures/advtrains_signal_wall_off.png
new file mode 100644
index 0000000..3e7b1e1
--- /dev/null
+++ b/advtrains/advtrains/textures/advtrains_signal_wall_off.png
Binary files differ
diff --git a/advtrains/advtrains/textures/advtrains_signal_wall_on.png b/advtrains/advtrains/textures/advtrains_signal_wall_on.png
new file mode 100644
index 0000000..b628c7e
--- /dev/null
+++ b/advtrains/advtrains/textures/advtrains_signal_wall_on.png
Binary files differ
diff --git a/assets/signal_wall.blend b/assets/signal_wall.blend
new file mode 100644
index 0000000..6927aa5
--- /dev/null
+++ b/assets/signal_wall.blend
Binary files differ
diff --git a/assets/signal_wall.blend1 b/assets/signal_wall.blend1
new file mode 100644
index 0000000..ecfff2d
--- /dev/null
+++ b/assets/signal_wall.blend1
Binary files differ
diff --git a/assets/signal_wall.png b/assets/signal_wall.png
new file mode 100644
index 0000000..db954ce
--- /dev/null
+++ b/assets/signal_wall.png
Binary files differ