From 6fd845baec0f5aa8b7cdee1adf8d05061a643242 Mon Sep 17 00:00:00 2001 From: orwell Date: Thu, 23 May 2024 00:58:24 +0200 Subject: Connect the ropes, start on making the UI work --- advtrains_signals_ks/init.lua | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'advtrains_signals_ks/init.lua') diff --git a/advtrains_signals_ks/init.lua b/advtrains_signals_ks/init.lua index 67e0fec..abfb194 100755 --- a/advtrains_signals_ks/init.lua +++ b/advtrains_signals_ks/init.lua @@ -50,15 +50,18 @@ end local applyaspectf_main = function(rot) return function(pos, node, main_aspect, dst_aspect, dst_aspect_info) + if not main_aspect then + -- halt aspect, set red and don't do anything further + advtrains.ndb.swap_node(pos, {name="advtrains_signals_ks:hs_danger_"..rot, param2 = node.param2}) + setzs3v(pos, nil, rot) + return + end -- set zs3 signal to show speed according to main_aspect setzs3(pos, main_aspect.zs3, rot) -- select appropriate lamps based on mainaspect and dst if main_aspect.shunt then advtrains.ndb.swap_node(pos, {name="advtrains_signals_ks:hs_shunt_"..rot, param2 = node.param2}) setzs3v(pos, nil, rot) - elseif main_aspect.halt then - advtrains.ndb.swap_node(pos, {name="advtrains_signals_ks:hs_danger_"..rot, param2 = node.param2}) - setzs3v(pos, nil, rot) else if not dst_aspect_info or not dst_aspect_info.main @@ -128,7 +131,8 @@ local mainaspects_main = { local applyaspectf_ra = function(rot) -- we get here the full main_aspect table return function(pos, node, main_aspect, dst_aspect, dst_aspect_info) - if main_aspect.shunt then + if main_aspect then + -- any main aspect is fine, there's only one anyway advtrains.ndb.swap_node(pos, {name="advtrains_signals_ks:ra_shuntd_"..rot, param2 = node.param2}) else advtrains.ndb.swap_node(pos, {name="advtrains_signals_ks:ra_danger_"..rot, param2 = node.param2}) @@ -144,11 +148,6 @@ local mainaspects_shunt = { description = "Shunt", shunt = true, }, - { - name = "halt", - description = "Halt", - halt = true, - }, } for _, rtab in ipairs({ @@ -225,9 +224,9 @@ for _, rtab in ipairs({ apply_aspect = applyaspectf_main(rot), get_aspect_info = afunc, }, - on_rightclick = advtrains.interlocking.signal_rc_handler, - can_dig = advtrains.interlocking.signal_can_dig, - after_dig_node = advtrains.interlocking.signal_after_dig, + on_rightclick = advtrains.interlocking.signal.on_rightclick, + can_dig = advtrains.interlocking.signal.can_dig, + after_dig_node = advtrains.interlocking.signal.after_dig, }) -- rotatable by trackworker --TODO add rotation using trackworker -- cgit v1.2.3