aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--advtrains_interlocking/signal_api.lua11
-rw-r--r--advtrains_signals_japan/init.lua5
-rwxr-xr-xadvtrains_signals_muc_ubahn/init.lua8
3 files changed, 18 insertions, 6 deletions
diff --git a/advtrains_interlocking/signal_api.lua b/advtrains_interlocking/signal_api.lua
index ae8f6fa..9989907 100644
--- a/advtrains_interlocking/signal_api.lua
+++ b/advtrains_interlocking/signal_api.lua
@@ -85,12 +85,11 @@ ndef.advtrains = {
-- name: A unique key to identify the main aspect. Might be required by some code.
-- description: Text shown in UI dropdown
-- Node can set any other fields at its discretion. They are not touched.
- -- Note: Pure distant signals (that cannot show halt) should NOT have a main_aspects table.
- -- For these signals no main aspect selection UI is shown and they cannot be startpoint of a route
+ -- Note: Pure distant signals should set one main aspect, and set the "pure_distant = true" field
apply_aspect = function(pos, node, main_aspect, rem_aspect, rem_aspinfo)
-- set the node to show the desired aspect
-- called by advtrains when this signal's aspect group or the remote signal's aspect changes
- -- main_aspect is never nil, but can be one of the special aspects { halt = true } or { default = true }
+ -- main_aspect is never nil, but can be the special aspect { name = "_halt", halt = true }
-- MAY return the aspect_info. If it returns nil then get_aspect_info will be queried at a later point.
get_aspect_info(pos, main_aspect)
-- Returns the aspect info table (main, shunt, dst etc.)
@@ -104,6 +103,12 @@ ndef.advtrains = {
-- distant: if more than one distant signal is before a main signal, only the last one is assigned (but any number of distant_repeater signals are allowed)
-- main_distant: Combination of main and distant - like "main", but additionally gets assigned to the next main like a "distant"
-- end: like main, but signifies that it marks an end of track and trains cannot continue further. (currently no practical implications above main)
+ pure_distant = true / false
+ -- If true, this signal is assumed to be a pure distant signal (its halt aspect is rather "expect halt" and it cannot show a true "stop here")
+ -- The following special behavior applies when this signal is assigned to a TCB: When a train passes the signal, the aspect is not reset to the
+ -- halt aspect and it continues to announce the remote signal's aspect (like in real life)
+ -- Typically such signals have one main aspect, their appearance depends almost exclusively on their remote signal and the halt aspect is the same as
+ -- the aspect shown when the main aspect is set but the remote signal is at halt.
}
== Nomenclature ==
diff --git a/advtrains_signals_japan/init.lua b/advtrains_signals_japan/init.lua
index a659410..1140b6b 100644
--- a/advtrains_signals_japan/init.lua
+++ b/advtrains_signals_japan/init.lua
@@ -415,7 +415,7 @@ for _, rtab in ipairs {
apply_aspect = function(pos, node, main_aspect, rem_aspect, rem_aspinfo)
local asp_name = main_aspect and main_aspect.name or "danger"
-- if this signal is clear and remote signal is restrictive (<= 10) then degrade to caution aspect
- if not main_aspect or main_aspect.name == "halt" then
+ if not main_aspect or main_aspect.halt then
asp_name = "danger"
elseif main_aspect.name == "clear" and rem_aspinfo and rem_aspinfo.main and rem_aspinfo.main >= 0 and rem_aspinfo.main <= 10 then
asp_name = "caution"
@@ -423,6 +423,9 @@ for _, rtab in ipairs {
advtrains.ndb.swap_node(pos, {name="advtrains_signals_japan:"..sigtype.."_"..asp_name.."_"..rot, param2 = node.param2})
end,
get_aspect_info = function(pos, main_aspect)
+ if main_aspect.halt then
+ return { main = 0 } -- generic halt
+ end
return {
main = main_aspect.main,
proceed_as_main = true,
diff --git a/advtrains_signals_muc_ubahn/init.lua b/advtrains_signals_muc_ubahn/init.lua
index 17ecac2..182a3dc 100755
--- a/advtrains_signals_muc_ubahn/init.lua
+++ b/advtrains_signals_muc_ubahn/init.lua
@@ -20,6 +20,9 @@ local mainaspects = {
{ name = "hp2", description = "Hp2: Reduced Speed" },
{ name = "hp3", description = "Hp3: Shunt" },
}
+local dstaspects = {
+ { name = "vr1", description = "Vr1: Expect Full speed" },
+}
local function applyaspect_main(loc)
return function(pos, node, main_aspect, rem_aspect, rem_aspinfo)
@@ -38,7 +41,7 @@ end
local function applyaspect_distant(loc)
return function(pos, node, main_aspect, rem_aspect, rem_aspinfo)
local ma_node = "vr0" -- show expect stop by default
- if not main_aspect.halt and rem_aspinfo and (not rem_aspinfo.main or rem_aspinfo.main>12 or rem_aspinfo.main==-1) then
+ if not main_aspect.halt and (not rem_aspinfo or not rem_aspinfo.main or rem_aspinfo.main>12 or rem_aspinfo.main==-1) then
ma_node = "vr1" -- show free when dst is at least 12
end
advtrains.ndb.swap_node(pos, {name = "advtrains_signals_muc_ubahn:signal_wall_"..loc.."_"..ma_node, param2 = node.param2})
@@ -74,8 +77,9 @@ for r,f in pairs(all_sigs) do
after_dig_node = advtrains.interlocking.signal.after_dig,
-- new signal API
advtrains = {
- main_aspects = not f.distant and mainaspects, -- main aspects only for main
+ main_aspects = f.distant and dstaspects or mainaspects, -- main aspects only for main
apply_aspect = f.distant and applyaspect_distant(loc) or applyaspect_main(loc),
+ pure_distant = f.distant,
get_aspect_info = function() return f.asp end,
route_role = f.distant and "distant" or "main"
},