diff options
author | orwell <orwell@bleipb.de> | 2025-09-07 12:18:06 +0200 |
---|---|---|
committer | orwell <orwell@bleipb.de> | 2025-09-07 12:18:06 +0200 |
commit | 8df0a9d75f372f1d325423b5cbdda5abda805050 (patch) | |
tree | fad8224f4a8fb51e3c0c0c28c8f039cb9b2a6ca5 /advtrains_line_automation | |
parent | bdd31c9db8fff919990f4be57e9497d8e0ebc67a (diff) | |
download | advtrains-8df0a9d75f372f1d325423b5cbdda5abda805050.tar.gz advtrains-8df0a9d75f372f1d325423b5cbdda5abda805050.tar.bz2 advtrains-8df0a9d75f372f1d325423b5cbdda5abda805050.zip |
More translations and fixestimetable
Diffstat (limited to 'advtrains_line_automation')
-rw-r--r-- | advtrains_line_automation/line_editor.lua | 17 | ||||
-rw-r--r-- | advtrains_line_automation/line_functions.lua | 38 | ||||
-rw-r--r-- | advtrains_line_automation/stoprail.lua | 13 |
3 files changed, 41 insertions, 27 deletions
diff --git a/advtrains_line_automation/line_editor.lua b/advtrains_line_automation/line_editor.lua index 530eb6e..0428035 100644 --- a/advtrains_line_automation/line_editor.lua +++ b/advtrains_line_automation/line_editor.lua @@ -156,7 +156,7 @@ local function get_formspec(custom_state) table.insert(formspec, ";font=mono;font_size=-4]".. "style[rc;font=mono]".. "tablecolumns[color;text,align=right;text;text,align=center;color;text,width=7;color;text]".. - "table[0.5,1.25;19,5;linevar;#ffffff,"..S("LINE,ROUTE,SM-CODE")..",#ffffff,"..S("OWNER")..",#ffffff,STAV") + "table[0.5,1.25;19,5;linevar;#ffffff,"..S("LINE,ROUTE,VAR.")..",#ffffff,"..S("OWNER")..",#ffffff,STAV") for _, linevar_def in ipairs(custom_state.linevars) do local lv_line, lv_stn, lv_rc = linevar_decompose(linevar_def.name) @@ -186,9 +186,9 @@ local function get_formspec(custom_state) table.insert(formspec, "button[10.5,0.3;3.5,0.75;delete;"..S("Delete Line").."]") end table.insert(formspec, "button_exit[18.75,0.3;0.75,0.75;close;X]".. - "field[0.5,7;1.25,0.75;line;linka:;"..F(custom_state.line).."]".. - "field[2,7;1.5,0.75;rc;sm.kód:;"..F(custom_state.rc).."]".. - "field[3.75,7;3,0.75;train_name;jméno vlaku:;"..F(custom_state.train_name).."]") + "field[0.5,7;1.25,0.75;line;"..S("Line:")..";"..F(custom_state.line).."]".. + "field[2,7;1.5,0.75;rc;"..S("Variant:")..";"..F(custom_state.rc).."]".. + "field[3.75,7;3,0.75;train_name;"..S("Dest. Display:")..";"..F(custom_state.train_name).."]") if pinfo.role ~= "admin" then table.insert(formspec, "label[7,6.75;"..S("Owner:").."\n") else @@ -779,9 +779,17 @@ local function show_editor_formspec(player, linevar_to_select) ch_core.show_formspec(player, "advtrains_line_automation:editor_linek", get_formspec(custom_state), formspec_callback, custom_state, {}) end +-- make line editor globally available +advtrains.lines.open_line_editor = show_editor_formspec + local function lp_formspec_callback(custom_state, player, formname, fields) if fields.back then show_editor_formspec(player, custom_state.selected_linevar) + elseif fields.update then + local selected_linevar_def = try_get_linevar_def(custom_state.selected_linevar) + if selected_linevar_def ~= nil then + show_last_passages_formspec(player, selected_linevar_def, custom_state.selected_linevar) + end end end @@ -853,6 +861,7 @@ show_last_passages_formspec = function(player, linevar_def, selected_linevar) end end table.insert(formspec, ";]".. + "button[13.75,0.3;1.75,0.75;update;"..S("Update").."]".. "button[17.75,0.3;1.75,0.75;back;"..S("Back").."]".. "tooltip[jizdy;Časové údaje jsou v sekundách železničního času.]") formspec = table.concat(formspec) diff --git a/advtrains_line_automation/line_functions.lua b/advtrains_line_automation/line_functions.lua index 8446740..ecf7616 100644 --- a/advtrains_line_automation/line_functions.lua +++ b/advtrains_line_automation/line_functions.lua @@ -137,7 +137,7 @@ local function line_start(train, stn, departure_rwtime, linevar) al.cancel_linevar(train) end local linevar_def = al.try_get_linevar_def(linevar, stn) - if linevar == nil or linevar_def.disabled then + if linevar == nil or linevar_def == nil or linevar_def.disabled then return false end ls.linevar = linevar @@ -496,13 +496,13 @@ function al.get_delay_description(line_status, linevar_def, rwtime) return { has_delay = true, delay = delay, - text = "zpoždění "..delay.." sekund", + text = "late "..delay.." seconds", } else return { has_delay = false, delay = delay, - text = "bez zpoždění", + text = "on time", } end end @@ -967,7 +967,7 @@ local function get_train_position(line_status, linevar_def, rwtime) local result = "„"..get_station_name(last_pos.stn).."“" local delay_info = al.get_delay_description(line_status, linevar_def, rwtime) if last_pos_info.type ~= "standing" then - result = result.." (před "..(rwtime - last_pos.rwtime).." sekundami)" + result = result.." ("..(rwtime - last_pos.rwtime).." seconds ago)" end if delay_info.has_delay ~= nil then result = result.." ("..delay_info.text..")" @@ -1292,19 +1292,19 @@ local function vlaky(param, past_trains_too) direction = get_station_name(direction_stop.stn) end local line = al.linevar_decompose(linevar_def.name) - local s = "("..train_id..") ["..line.."] směr „"..direction.."“, poloha: ".. + local s = "("..train_id..") ["..line.."] direction „"..direction.."“, location: ".. get_train_position(ls, linevar_def, rwtime) if results[train_id] ~= nil then - s = s.." ["..results[train_id].." cestující/ch]" + s = s.." ["..results[train_id].." passengers]" end table.insert(results, {key = linevar_def.name.."/"..ls.linevar_index, value = s}) end elseif past_trains_too and ls.linevar_past ~= nil and (train_line_prefix == nil or ls.linevar_past.line == param) then local age = rwtime - ls.linevar_past.arrival - local s = "("..train_id..") ["..ls.linevar_past.line.."] služební, poloha: ".. - get_station_name(ls.linevar_past.station).." (před "..age.." sekundami)" + local s = "("..train_id..") ["..ls.linevar_past.line.."] finished, location: ".. + get_station_name(ls.linevar_past.station).." ("..age.." seconds ago)" if results[train_id] ~= nil then - s = s.." ["..results[train_id].." cestující/ch]" + s = s.." ["..results[train_id].." passengers]" end table.insert(results, { key = string.format("%s/~/%s/%05d", ls.linevar_past.line, ls.linevar_past.station, age), @@ -1321,31 +1321,31 @@ end -- příkaz /vlaky local def = { - params = "[linka]", - description = "Vypíše všechny linkové vlaky na zadané lince (resp. na všech linkách)", + params = "[line]", + description = "List all trains on the given line (or all lines)", privs = {}, func = function(player_name, param) local result = vlaky(param, false) if #result == 0 then - return false, "Nenalezen žádný odpovídající vlak." + return false, "No matching train found." end - return true, "Nalezeno "..#result.." vlaků:\n- "..table.concat(result, "\n- ") + return true, "Listing "..#result.." trains:\n- "..table.concat(result, "\n- ") end, } -core.register_chatcommand("vlaky", def) +core.register_chatcommand("list_trains", def) def = { - params = "[linka]", - description = "Vypíše všechny linkové vlaky na zadané lince (resp. na všech linkách) a ty, které nedávno jízdu na lince ukončily", + params = "[line]", + description = "List all trains on the given line (or all lines) + trains that have recently completed the line", privs = {ch_registered_player = true}, func = function(player_name, param) local result = vlaky(param, true) if #result == 0 then - return false, "Nenalezen žádný odpovídající vlak." + return false, "No matching train found." end - return true, "Nalezeno "..#result.." vlaků:\n- "..table.concat(result, "\n- ") + return true, "Listing "..#result.." trains:\n- "..table.concat(result, "\n- ") end, } -core.register_chatcommand("vlaky+", def) +core.register_chatcommand("list_trains+", def) def = { -- params = "", diff --git a/advtrains_line_automation/stoprail.lua b/advtrains_line_automation/stoprail.lua index 81f103a..77c1dce 100644 --- a/advtrains_line_automation/stoprail.lua +++ b/advtrains_line_automation/stoprail.lua @@ -146,7 +146,8 @@ local function show_stoprailform(pos, player) get_stn_dropdown(player_to_stn_override[pname] or stdata.stn, pname_unless_admin).. "field[0.5,2.6;1.5,0.8;track;"..S("Track")..";"..minetest.formspec_escape(stdata.track).."]".. "tooltip[track;"..S("Track number, for informational purposes").."]".. - (advtrains.lines.open_station_editor ~= nil and "button[3.5,2.3;3.7,1.1;editstn;"..S("Station Editor").."]" or "") + (advtrains.lines.open_station_editor ~= nil and "button[2.3,2.6;2.5,0.8;editstn;"..S("Station Editor").."]" or "").. + (advtrains.lines.open_line_editor ~= nil and "button[4.8,2.6;2.5,0.8;editlines;"..S("Line Editor").."]" or "") if stdata.selector_ars then formspec = formspec .. "textarea[7.5,1.3;4,2.1;selector_ars;"..S("Selector for stop pos (ARS)")..";"..advtrains.interlocking.ars_to_text(stdata.selector_ars).."]".. "tooltip[selector_ars;"..S("Only trains matching these ARS rules will consider this stop rail as suitable timing point/stop position.\nAffects both timetabled and non-timetabled trains.\nExample: define a stop position for long trains (TL 30) and another for short trains (TL 0-30).").."]".. @@ -192,7 +193,7 @@ local function show_stoprailform(pos, player) -- TODO: interval and offset should be defined in the timetable, not here -- build list of available linevars (it is convenient that linevars are defined in the station) local avail_linevars = {} - local sel_linevar = 1 + local sel_linevar = 0 if stn and stn.linevars then for k,_ in pairs(stn.linevars) do table.insert(avail_linevars, k) @@ -201,7 +202,7 @@ local function show_stoprailform(pos, player) end if #avail_linevars > 0 then formspec = formspec .. - "dropdown[6.2,6.6;3.8,0.8;tt_begin_linevar;"..table.concat(avail_linevars)..";"..(sel_linevar or 1)..",false]" -- this dropdown NOT using indexing! + "dropdown[6.2,6.6;3.8,0.8;tt_begin_linevar;"..table.concat(avail_linevars, ",")..";"..(sel_linevar or 0)..",false]" -- this dropdown NOT using indexing! else formspec = formspec .. "label[6.2,6.6;"..S("No linevars\navailable!").."]" end @@ -255,7 +256,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end end - if fields.save or (fields.depmode and not fields.editstn) or fields.selector_ars_enable then -- must resend form when depmode dropdown is updated or the selector enable button is pressed) + if fields.save or (fields.depmode and not fields.editstn and not fields.editlines) or fields.selector_ars_enable then -- must resend form when depmode dropdown is updated or the selector enable button is pressed) local new_index = player_to_stn_override[pname] if new_index ~= nil then if new_index == 1 then @@ -343,6 +344,10 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) minetest.close_formspec(pname, formname) minetest.after(0.25, advtrains.lines.open_station_editor, player) return + elseif fields.editlines and advtrains.lines.open_line_editor ~= nil then + minetest.close_formspec(pname, formname) + minetest.after(0.25, advtrains.lines.open_line_editor, player) + return end -- if fields.save end -- if pos end) |