diff options
author | orwell <orwell@bleipb.de> | 2024-05-24 00:00:12 +0200 |
---|---|---|
committer | orwell <orwell@bleipb.de> | 2024-05-24 00:00:12 +0200 |
commit | f52653209aecb2310c1fb9598391c86113296f27 (patch) | |
tree | 2fba34771edf587e21a666ec0c59fce3d03ca937 /advtrains_interlocking | |
parent | eb029711534006f73624a64c30f7a8597209ceec (diff) | |
download | advtrains-f52653209aecb2310c1fb9598391c86113296f27.tar.gz advtrains-f52653209aecb2310c1fb9598391c86113296f27.tar.bz2 advtrains-f52653209aecb2310c1fb9598391c86113296f27.zip |
Fix working of the legacy signals under new system
Diffstat (limited to 'advtrains_interlocking')
-rw-r--r-- | advtrains_interlocking/database.lua | 2 | ||||
-rw-r--r-- | advtrains_interlocking/demosignals.lua | 97 | ||||
-rw-r--r-- | advtrains_interlocking/init.lua | 1 | ||||
-rw-r--r-- | advtrains_interlocking/signal_api.lua | 15 |
4 files changed, 10 insertions, 105 deletions
diff --git a/advtrains_interlocking/database.lua b/advtrains_interlocking/database.lua index e2df547..49ca13d 100644 --- a/advtrains_interlocking/database.lua +++ b/advtrains_interlocking/database.lua @@ -1006,7 +1006,7 @@ end function ildb.get_ip_signal_asp(pts, connid) local p = ildb.get_ip_signal(pts, connid) if p then - local asp = advtrains.interlocking.signal.get_aspect(p) + local asp = advtrains.interlocking.signal.get_aspect_info(p) if not asp then atlog("Clearing orphaned signal influence point", pts, "/", connid) ildb.clear_ip_signal(pts, connid) diff --git a/advtrains_interlocking/demosignals.lua b/advtrains_interlocking/demosignals.lua deleted file mode 100644 index de6926a..0000000 --- a/advtrains_interlocking/demosignals.lua +++ /dev/null @@ -1,97 +0,0 @@ --- Demonstration signals --- Those can display the 3 main aspects of Ks signals - --- Note that the group value of advtrains_signal is 2, which means "step 2 of signal capabilities" --- advtrains_signal=1 is meant for signals that do not implement set_aspect. - - -local setaspect = function(pos, node, asp) - if asp.main == 0 then - advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_danger"}) - else - if asp.dst ~= 0 and asp.main == -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 = {0, 6, -1}, - dst = {0, false}, - shunt = 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"}, - groups = { - cracky = 3, - advtrains_signal = 2, - save_in_at_nodedb = 1, - }, - advtrains = { - 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, - after_destruct = advtrains.interlocking.signal_after_dig, -}) -minetest.register_node("advtrains_interlocking:ds_free", { - description = "Demo signal at Free", - tiles = {"at_il_signal_asp_free.png"}, - groups = { - cracky = 3, - advtrains_signal = 2, - save_in_at_nodedb = 1, - }, - advtrains = { - set_aspect = setaspect, - supported_aspects = suppasp, - get_aspect = function(pos, node) - return { - main = -1, - } - end, - }, - on_rightclick = advtrains.interlocking.signal_rc_handler, - can_dig = advtrains.interlocking.signal_can_dig, - after_destruct = advtrains.interlocking.signal_after_dig, -}) -minetest.register_node("advtrains_interlocking:ds_slow", { - description = "Demo signal at Slow", - tiles = {"at_il_signal_asp_slow.png"}, - groups = { - cracky = 3, - advtrains_signal = 2, - save_in_at_nodedb = 1, - }, - advtrains = { - set_aspect = setaspect, - supported_aspects = suppasp, - get_aspect = function(pos, node) - return { - main = 6, - } - end, - }, - on_rightclick = advtrains.interlocking.signal_rc_handler, - can_dig = advtrains.interlocking.signal_can_dig, - after_destruct = advtrains.interlocking.signal_after_dig, -}) - diff --git a/advtrains_interlocking/init.lua b/advtrains_interlocking/init.lua index c397aa6..a4ddbad 100644 --- a/advtrains_interlocking/init.lua +++ b/advtrains_interlocking/init.lua @@ -17,7 +17,6 @@ local modpath = minetest.get_modpath(minetest.get_current_modname()) .. DIR_DELI dofile(modpath.."database.lua") dofile(modpath.."signal_api.lua") dofile(modpath.."signal_aspect_ui.lua") -dofile(modpath.."demosignals.lua") dofile(modpath.."train_sections.lua") dofile(modpath.."route_prog.lua") dofile(modpath.."routesetting.lua") diff --git a/advtrains_interlocking/signal_api.lua b/advtrains_interlocking/signal_api.lua index 7826d30..6f52816 100644 --- a/advtrains_interlocking/signal_api.lua +++ b/advtrains_interlocking/signal_api.lua @@ -272,14 +272,14 @@ local function cache_mainaspects(ndefat) end function signal.get_aspect_internal(pos, aspt) - if not aspt then - -- oh, no main aspect, nevermind - return signal.MASP_HALT, nil, nil - end atdebug("get_aspect_internal",pos,aspt) -- look aspect in nodedef local node = advtrains.ndb.get_node_or_nil(pos) local ndef = node and minetest.registered_nodes[node.name] + if not aspt then + -- oh, no main aspect, nevermind + return signal.MASP_HALT, nil, node, ndef + end local ndefat = ndef and ndef.advtrains if ndefat and ndefat.apply_aspect then -- only if signal defines main aspect and its set in aspt @@ -318,7 +318,9 @@ function signal.get_aspect_info(pos) local masp, remote, node, ndef = signal.get_aspect_internal(pos, aspt) -- call into ndef if ndef.advtrains and ndef.advtrains.get_aspect_info then - return ndef.advtrains.get_aspect_info(pos, masp) + local ai = ndef.advtrains.get_aspect_info(pos, masp) + atdebug(pos,"aspectinfo",ai) + return ai end end @@ -333,11 +335,12 @@ function signal.reapply_aspect(pts) -- get aspt local aspt = signal.aspects[pts] atdebug("reapply_aspect",advtrains.decode_pos(pts),"aspt",aspt) + local pos = advtrains.decode_pos(pts) if not aspt then + signal.notify_trains(pos) return -- oop, nothing to do end -- resolve mainaspect table by name - local pos = advtrains.decode_pos(pts) local masp, remote, node, ndef = signal.get_aspect_internal(pos, aspt) -- if we have remote, resolve remote local rem_masp, rem_aspi |