diff options
author | orwell96 <orwell@bleipb.de> | 2018-10-25 22:49:30 +0200 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2018-10-25 22:49:30 +0200 |
commit | 6bb6c7d345ad285d0c5388b1daf83e67a7b466e6 (patch) | |
tree | fe3a182ae3bb52c0c813acd7f1d0531440210646 /advtrains_interlocking/demosignals.lua | |
parent | f007017aa4efc5c51bbfe7202235053a6ae8d50a (diff) | |
download | advtrains-6bb6c7d345ad285d0c5388b1daf83e67a7b466e6.tar.gz advtrains-6bb6c7d345ad285d0c5388b1daf83e67a7b466e6.tar.bz2 advtrains-6bb6c7d345ad285d0c5388b1daf83e67a7b466e6.zip |
Fix demo signals
Diffstat (limited to 'advtrains_interlocking/demosignals.lua')
-rw-r--r-- | advtrains_interlocking/demosignals.lua | 106 |
1 files changed, 61 insertions, 45 deletions
diff --git a/advtrains_interlocking/demosignals.lua b/advtrains_interlocking/demosignals.lua index c19b578..ab7a8b6 100644 --- a/advtrains_interlocking/demosignals.lua +++ b/advtrains_interlocking/demosignals.lua @@ -5,6 +5,42 @@ -- advtrains_signal=1 is meant for signals that do not implement set_aspect. +local setaspect = function(pos, node, asp) + if not asp.main.free then + advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_danger"}) + else + if asp.dst.free and asp.main.speed == -1 then + advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_free"}) + else + advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_slow"}) + end + end + local meta = minetest.get_meta(pos) + if meta then + meta:set_string("infotext", minetest.serialize(asp)) + end +end + +local suppasp = { + main = { + free = nil, + speed = {6, -1}, + }, + dst = { + free = nil, + speed = nil, + }, + shunt = { + free = false, + proceed_as_main = true, + }, + info = { + call_on = false, + dead_end = false, + w_speed = nil, + } +} + minetest.register_node("advtrains_interlocking:ds_danger", { description = "Demo signal at Danger", tiles = {"at_il_signal_asp_danger.png"}, @@ -15,21 +51,11 @@ minetest.register_node("advtrains_interlocking:ds_danger", { }, 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 + set_aspect = setaspect, + supported_aspects = suppasp, + get_aspect = function(pos, node) + return advtrains.interlocking.DANGER + end, }, on_rightclick = advtrains.interlocking.signal_rc_handler, can_dig = advtrains.interlocking.signal_can_dig, @@ -44,21 +70,16 @@ minetest.register_node("advtrains_interlocking:ds_free", { }, 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 + set_aspect = setaspect, + supported_aspects = suppasp, + get_aspect = function(pos, node) + return { + main = { + free = true, + speed = -1, + } + } + end, }, on_rightclick = advtrains.interlocking.signal_rc_handler, can_dig = advtrains.interlocking.signal_can_dig, @@ -73,21 +94,16 @@ minetest.register_node("advtrains_interlocking:ds_slow", { }, 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 + set_aspect = setaspect, + supported_aspects = suppasp, + get_aspect = function(pos, node) + return { + main = { + free = true, + speed = 6, + } + } + end, }, on_rightclick = advtrains.interlocking.signal_rc_handler, can_dig = advtrains.interlocking.signal_can_dig, |