aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking/demosignals.lua
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2018-06-19 19:50:11 +0200
committerorwell96 <orwell@bleipb.de>2018-06-19 19:50:11 +0200
commit65675664e3cdf3328b89b4bdc22cc07c21be3a56 (patch)
tree4519b5d3fd9f13c0f554eba7e88a7e3bcdc36616 /advtrains_interlocking/demosignals.lua
parent08ac0f9c05c4623a2783749b1dee2dafa234cee6 (diff)
downloadadvtrains-65675664e3cdf3328b89b4bdc22cc07c21be3a56.tar.gz
advtrains-65675664e3cdf3328b89b4bdc22cc07c21be3a56.tar.bz2
advtrains-65675664e3cdf3328b89b4bdc22cc07c21be3a56.zip
Interlocking: Create demo signals, signal API and model for TCB configurer node
Diffstat (limited to 'advtrains_interlocking/demosignals.lua')
-rw-r--r--advtrains_interlocking/demosignals.lua89
1 files changed, 89 insertions, 0 deletions
diff --git a/advtrains_interlocking/demosignals.lua b/advtrains_interlocking/demosignals.lua
new file mode 100644
index 0000000..8320afb
--- /dev/null
+++ b/advtrains_interlocking/demosignals.lua
@@ -0,0 +1,89 @@
+-- Demonstration signals
+-- Those can display the 3 main aspects of Ks signals
+
+
+minetest.register_node("advtrains_interlocking:ds_danger", {
+ description = "Demo signal at Danger",
+ tiles = {"at_il_signal_asp_danger.png"},
+ groups = {
+ cracky = 3,
+ advtrains_signal = 1,
+ save_in_at_nodedb = 1,
+ },
+ sounds = default.node_sound_stone_defaults(),
+ advtrains = {
+ set_aspect = function(pos, node, asp)
+ if asp.main.free then
+ if asp.dst.free and asp.main.speed > 50 then
+ advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_free"})
+ else
+ advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_slow"})
+ end
+ else
+ advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_danger"})
+ end
+ local meta = minetest.get_meta(pos)
+ if meta then
+ meta:set_string("infotext", minetest.serialize(asp))
+ end
+ end
+ },
+ on_rightclick = advtrains.interlocking.signal_rc_handler
+})
+minetest.register_node("advtrains_interlocking:ds_free", {
+ description = "Demo signal at Free",
+ tiles = {"at_il_signal_asp_free.png"},
+ groups = {
+ cracky = 3,
+ advtrains_signal = 1,
+ save_in_at_nodedb = 1,
+ },
+ sounds = default.node_sound_stone_defaults(),
+ advtrains = {
+ set_aspect = function(pos, node, asp)
+ if asp.main.free then
+ if asp.dst.free and asp.main.speed > 50 then
+ advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_free"})
+ else
+ advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_slow"})
+ end
+ else
+ advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_danger"})
+ end
+ local meta = minetest.get_meta(pos)
+ if meta then
+ meta:set_string("infotext", minetest.serialize(asp))
+ end
+ end
+ },
+ on_rightclick = advtrains.interlocking.signal_rc_handler
+})
+minetest.register_node("advtrains_interlocking:ds_slow", {
+ description = "Demo signal at Slow",
+ tiles = {"at_il_signal_asp_slow.png"},
+ groups = {
+ cracky = 3,
+ advtrains_signal = 1,
+ save_in_at_nodedb = 1,
+ },
+ sounds = default.node_sound_stone_defaults(),
+ advtrains = {
+ set_aspect = function(pos, node, asp)
+ if asp.main.free then
+ if asp.dst.free and asp.main.speed > 50 then
+ advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_free"})
+ else
+ advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_slow"})
+ end
+ else
+ advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_danger"})
+ end
+ local meta = minetest.get_meta(pos)
+ if meta then
+ meta:set_string("infotext", minetest.serialize(asp))
+ end
+ end
+ },
+ on_rightclick = advtrains.interlocking.signal_rc_handler
+})
+