aboutsummaryrefslogtreecommitdiff
path: root/advtrains_line_automation/line_functions.lua
diff options
context:
space:
mode:
authorY. Wang <y5nw@protonmail.com>2026-04-14 22:03:16 +0000
committerorwell <orwell@bleipb.de>2026-07-08 22:16:17 +0200
commit9ce8a356833ae5678df6fe8d168d684dd4e58c65 (patch)
treee3d9df56e88de9095684b27ea67a32dc5fa948e8 /advtrains_line_automation/line_functions.lua
parentcb11b559fa55969298bfac654bc3000180dcf6e4 (diff)
Refactor al.get_line_description and drop the last_stop_prefix option
The last_stop_prefix option appears to have been primarily a workaround for an implementation limitation of al.get_line_description.
Diffstat (limited to 'advtrains_line_automation/line_functions.lua')
-rw-r--r--advtrains_line_automation/line_functions.lua30
1 files changed, 12 insertions, 18 deletions
diff --git a/advtrains_line_automation/line_functions.lua b/advtrains_line_automation/line_functions.lua
index 0450fa4..8f69a00 100644
--- a/advtrains_line_automation/line_functions.lua
+++ b/advtrains_line_automation/line_functions.lua
@@ -343,7 +343,6 @@ function al.get_line_display(linevar_def)
return core.get_translated_string("", al.get_line_description(linevar_def, {
line_number = true,
last_stop = true,
- last_stop_prefix = "",
}))
end
@@ -352,7 +351,6 @@ end
line_number = bool or nil, -- zahrnout do popisu číslo linky? nil => false
first_stop = bool or nil, -- zahrnout do popisu název výchozí zastávky? nil => false
last_stop = bool or nil, -- zahrnout do popisu název cílové zastávky? nil => true
- last_stop_prefix = string or nil, -- text před název cílové zastávky; nil => "⇒ "
}
]]
function al.get_line_description(linevar_def, options)
@@ -362,29 +360,25 @@ function al.get_line_description(linevar_def, options)
return "???"
end
if options == nil then options = {} end
- local s1, s2, s3
+ local s1, s2 = "", ""
if options.line_number then
s1 = "["..line.."] "
- else
- s1 = ""
end
- if first_stn == last_stn and options.first_stop and (options.last_stop == nil or options.last_stop) then
- s2 = get_station_name(last_stn)
- s3 = " (okružní)"
- else
+ if options.last_stop == nil or options.last_stop then
+ local last_stn_description = get_station_name(last_stn)
if options.first_stop then
- s2 = get_station_name(first_stn).." "
- else
- s2 = ""
- end
- if options.last_stop == nil or options.last_stop then
- s3 = get_station_name(last_stn)
- s3 = (options.last_stop_prefix or "⇒ ")..s3
+ if first_stn == last_stn then
+ s2 = S("@1 (Ring line)", last_stn_description)
+ else
+ s2 = ("%s ⇒ %s"):format(get_station_name(first_stn), last_stn_description)
+ end
else
- s3 = ""
+ s2 = last_stn_description
end
+ elseif options.first_stop then
+ s2 = get_station_name(first_stn)
end
- return s1..s2..s3
+ return s1..s2
end
function al.get_stop_description(stop_data, next_stop_data)