diff options
| author | Y. Wang <y5nw@protonmail.com> | 2026-04-14 22:03:16 +0000 |
|---|---|---|
| committer | orwell <orwell@bleipb.de> | 2026-07-08 22:16:17 +0200 |
| commit | 9ce8a356833ae5678df6fe8d168d684dd4e58c65 (patch) | |
| tree | e3d9df56e88de9095684b27ea67a32dc5fa948e8 /advtrains_line_automation | |
| parent | cb11b559fa55969298bfac654bc3000180dcf6e4 (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')
| -rw-r--r-- | advtrains_line_automation/line_functions.lua | 30 | ||||
| -rw-r--r-- | advtrains_line_automation/station_announcement.lua | 4 | ||||
| -rw-r--r-- | advtrains_line_automation/station_editor.lua | 4 |
3 files changed, 16 insertions, 22 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) diff --git a/advtrains_line_automation/station_announcement.lua b/advtrains_line_automation/station_announcement.lua index c075597..1875962 100644 --- a/advtrains_line_automation/station_announcement.lua +++ b/advtrains_line_automation/station_announcement.lua @@ -1157,7 +1157,7 @@ end local function get_start_by_linevar_def(cache, linevar_def) local result = cache[linevar_def.name] if result == nil then - result = al.get_line_description(linevar_def, {first_stop = true, last_stop = false, last_stop_prefix = ""}) + result = al.get_line_description(linevar_def, {first_stop = true, last_stop = false}) if result == "???" then result = "" end @@ -1169,7 +1169,7 @@ end local function get_destination_by_linevar_def(cache, linevar_def) local result = cache[linevar_def.name] if result == nil then - result = al.get_line_description(linevar_def, {first_stop = false, last_stop = true, last_stop_prefix = ""}) + result = al.get_line_description(linevar_def, {first_stop = false, last_stop = true}) if result == "???" then result = "" end diff --git a/advtrains_line_automation/station_editor.lua b/advtrains_line_automation/station_editor.lua index a456c7e..8de6919 100644 --- a/advtrains_line_automation/station_editor.lua +++ b/advtrains_line_automation/station_editor.lua @@ -582,7 +582,7 @@ local function get_all_linevars() for stn, stdata in pairs(advtrains.lines.stations) do for linevar, linevar_def in pairs(stdata.linevars or empty_table) do local line, stn = advtrains.lines.linevar_decompose(linevar) - local target_fs = F(advtrains.lines.get_line_description(linevar_def, {line_number = false, last_stop = true, last_stop_prefix = ""})) + local target_fs = F(advtrains.lines.get_line_description(linevar_def, {line_number = false, last_stop = true})) local status_fs if trains_by_linevar[linevar] ~= nil then status_fs = "#00ff00,"..S("in operation") @@ -612,7 +612,7 @@ end local function get_linevars_by_filter(stn_filter, track_filter) local result = {} local empty_table = {} - local line_description_options = {line_number = false, last_stop = true, last_stop_prefix = ""} + local line_description_options = {line_number = false, last_stop = true} local trains_by_linevar = advtrains.lines.get_trains_by_linevar() assert(stn_filter) if track_filter == "" then |
