Hi ywang,
The reason why the core mod signals are not using the API is because they still have the old "right click toggle green/red" behavior when they are not assigned to anything. This needs to stay for the foreseeable future. In the long term I would like to remove the core signals from the core mod, keeping them around in an optional external mod then for those who need compatibility.
Hi Jürgen,
I applied the patch. Thanks for your contribution.
Regards,
Orwell
Currently a signal assigned to a TCB will always show the signalling form
even when AUX1 is held.
---
advtrains/signals.lua | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
It seems like Advtrains already has an API for showing the correct
signal form: advtrains.interlocking.signal.on_rightclick (from
_interlocking/signal_api.lua). This is already used by other signal
packs (Ks, JP, MUC) but not the ones in the core mod. IMO it would be
better to use this directly if this is available, so something like:
if advtrains.interlocking then
return advtrains.interlocking.signal.on_rightclick(...)
end
-- Fallback code for when interlocking is not available ...
Alternatively. it seems like we could just swap the first two cases so
that the IP form is checked for first and then the signaling form.
(Side note for orwell: when I wrote the signaling code for new-ks2 I had
the idea of eventually moving it - possibly also _interlocking - into
the core mod. IMO there isn't any reason to keep them as separate mods
at this point, especially with the signal packs depending on _interlocking.)
diff --git a/advtrains/signals.lua b/advtrains/signals.lua
index 2b7362e..35e118c 100644
--- a/advtrains/signals.lua+++ b/advtrains/signals.lua
@@ -83,7 +83,7 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
on_rightclick=function(pos, node, player)
local pname = player:get_player_name()
local sigd = advtrains.interlocking and advtrains.interlocking.db.get_sigd_for_signal(pos)
- if sigd then+ if sigd and not player:get_player_control().aux1 then advtrains.interlocking.show_signalling_form(sigd, pname)
elseif advtrains.interlocking and player:get_player_control().aux1 then
advtrains.interlocking.show_ip_form(pos, pname)
@@ -141,7 +141,7 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
on_rightclick=function(pos, node, player)
local pname = player:get_player_name()
local sigd = advtrains.interlocking and advtrains.interlocking.db.get_sigd_for_signal(pos)
- if sigd then+ if sigd and not player:get_player_control().aux1 then advtrains.interlocking.show_signalling_form(sigd, pname)
elseif advtrains.interlocking and player:get_player_control().aux1 then
advtrains.interlocking.show_ip_form(pos, pname)
@@ -213,7 +213,7 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
on_rightclick=function(pos, node, player)
local pname = player:get_player_name()
local sigd = advtrains.interlocking and advtrains.interlocking.db.get_sigd_for_signal(pos)
- if sigd then+ if sigd and not player:get_player_control().aux1 then advtrains.interlocking.show_signalling_form(sigd, pname)
elseif advtrains.interlocking and player:get_player_control().aux1 then
advtrains.interlocking.show_ip_form(pos, pname)
--
2.30.2