aboutsummaryrefslogtreecommitdiff
path: root/advtrains_line_automation
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains_line_automation')
-rw-r--r--advtrains_line_automation/ch_functions.lua669
-rw-r--r--advtrains_line_automation/init.lua14
-rw-r--r--advtrains_line_automation/line_editor.lua864
-rw-r--r--advtrains_line_automation/line_functions.lua1350
-rw-r--r--advtrains_line_automation/locale/advtrains_line_automation.de.po1273
-rw-r--r--advtrains_line_automation/locale/advtrains_line_automation.fr.po1549
-rw-r--r--advtrains_line_automation/locale/advtrains_line_automation.pot735
-rw-r--r--advtrains_line_automation/locale/advtrains_line_automation.zh_CN.po1193
-rw-r--r--advtrains_line_automation/locale/advtrains_line_automation.zh_TW.po1193
-rw-r--r--advtrains_line_automation/mod.conf2
-rw-r--r--advtrains_line_automation/models/advtrains_tuber.obj150
-rw-r--r--advtrains_line_automation/models/license.txt5
-rw-r--r--advtrains_line_automation/railwaytime.lua413
-rw-r--r--advtrains_line_automation/scheduler.lua20
-rw-r--r--advtrains_line_automation/station_announcement.lua1583
-rw-r--r--advtrains_line_automation/station_editor.lua1069
-rw-r--r--advtrains_line_automation/stoprail.lua388
-rw-r--r--advtrains_line_automation/structs.md190
-rw-r--r--advtrains_line_automation/textures/advtrains_dtrack_shared_stop.pngbin3306 -> 7559 bytes
-rw-r--r--advtrains_line_automation/textures/advtrains_line_automation_jrad.pngbin0 -> 2516 bytes
-rw-r--r--advtrains_line_automation/textures/advtrains_line_automation_white_pixel.pngbin0 -> 82 bytes
-rw-r--r--advtrains_line_automation/time_table.lua95
22 files changed, 12517 insertions, 238 deletions
diff --git a/advtrains_line_automation/ch_functions.lua b/advtrains_line_automation/ch_functions.lua
new file mode 100644
index 0000000..5a2c46f
--- /dev/null
+++ b/advtrains_line_automation/ch_functions.lua
@@ -0,0 +1,669 @@
+--advtrains_line_automation
+
+-- Functions from Cesky Hvozd utility libraries which are used in the code integrated from Singularis are now provided here.
+
+--[[
+Jednoduchá funkce, která vyhodnotí condition jako podmínku
+a podle výsledku vrátí buď true_result, nebo false_result.
+]]
+local function ifthenelse(condition, true_result, false_result)
+ if condition then
+ return true_result
+ else
+ return false_result
+ end
+end
+
+local utf8_sort_cache = {}
+local ch_core = {}
+
+-- gives various info about a player. we return only what is relevant outside CH
+function ch_core.normalize_player(player_name_or_player)
+ local arg_type = type(player_name_or_player)
+ local player_name, player
+ if arg_type == "string" then
+ player_name = player_name_or_player
+ elseif arg_type == "number" then
+ player_name = tostring(player_name_or_player)
+ elseif (arg_type == "table" or arg_type == "userdata") and type(player_name_or_player.get_player_name) == "function" then
+ player_name = player_name_or_player:get_player_name()
+ if type(player_name) ~= "string" then
+ player_name = ""
+ else
+ if minetest.is_player(player_name_or_player) then
+ player = player_name_or_player
+ end
+ end
+ else
+ player_name = ""
+ end
+ if player_name == "" then
+ return {role = "none", player_name = "", viewname = "", privs = {}}
+ end
+ local privs = minetest.get_player_privs(player_name)
+ return {
+ role = "default",
+ player_name = player_name,
+ viewname = player_name,
+ privs = privs,
+ player = player or minetest.get_player_by_name(player_name),
+ }
+end
+
+-- == UTF8 helpers == --
+
+local utf8_charlen = {}
+for i = 1, 191, 1 do
+ -- 1 to 127 => jednobajtové znaky
+ -- 128 až 191 => nejsou dovoleny jako první bajt (=> vrátit 1 bajt)
+ utf8_charlen[i] = 1
+end
+for i = 192, 223, 1 do
+ utf8_charlen[i] = 2
+end
+for i = 224, 239, 1 do
+ utf8_charlen[i] = 3
+end
+for i = 240, 247, 1 do
+ utf8_charlen[i] = 4
+end
+for i = 248, 255, 1 do
+ utf8_charlen[i] = 1 -- neplatné UTF-8
+end
+
+local utf8_sort_data_1 = {
+ ["\x20"] = "\x20", -- < >
+ ["\x21"] = "\x21", -- <!>
+ ["\x22"] = "\x22", -- <">
+ ["\x23"] = "\x23", -- <#>
+ ["\x25"] = "\x24", -- <%>
+ ["\x26"] = "\x25", -- <&>
+ ["\x27"] = "\x26", -- <'>
+ ["\x28"] = "\x27", -- <(>
+ ["\x29"] = "\x28", -- <)>
+ ["\x2a"] = "\x29", -- <*>
+ ["\x2b"] = "\x2a", -- <+>
+ ["\x2c"] = "\x2b", -- <,>
+ ["\x2d"] = "\x2c", -- <->
+ ["\x2e"] = "\x2d", -- <.>
+ ["\x2f"] = "\x2e", -- </>
+ ["\x3a"] = "\x2f", -- <:>
+ ["\x3b"] = "\x30", -- <;>
+ ["\x3c"] = "\x31", -- <<>
+ ["\x3d"] = "\x32", -- <=>
+ ["\x3e"] = "\x33", -- <>>
+ ["\x3f"] = "\x34", -- <?>
+ ["\x40"] = "\x35", -- <@>
+ ["\x5b"] = "\x36", -- <[>
+ ["\x5c"] = "\x37", -- <\>
+ ["\x5d"] = "\x38", -- <]>
+ ["\x5e"] = "\x39", -- <^>
+ ["\x5f"] = "\x3a", -- <_>
+ ["\x60"] = "\x3b", -- <`>
+ ["\x7b"] = "\x3c", -- <{>
+ ["\x7c"] = "\x3d", -- <|>
+ ["\x7d"] = "\x3e", -- <}>
+ ["\x7e"] = "\x3f", -- <~>
+ ["\x24"] = "\x40", -- <$>
+ ["\x61"] = "\x41", -- <a>
+ ["\x41"] = "\x42", -- <A>
+ ["\x62"] = "\x47", -- <b>
+ ["\x42"] = "\x48", -- <B>
+ ["\x64"] = "\x4d", -- <d>
+ ["\x44"] = "\x4e", -- <D>
+ ["\x65"] = "\x51", -- <e>
+ ["\x45"] = "\x52", -- <E>
+ ["\x66"] = "\x57", -- <f>
+ ["\x46"] = "\x58", -- <F>
+ ["\x67"] = "\x59", -- <g>
+ ["\x47"] = "\x5a", -- <G>
+ ["\x68"] = "\x5b", -- <h>
+ ["\x48"] = "\x5c", -- <H>
+ ["\x69"] = "\x61", -- <i>
+ ["\x49"] = "\x62", -- <I>
+ ["\x6a"] = "\x65", -- <j>
+ ["\x4a"] = "\x66", -- <J>
+ ["\x6b"] = "\x67", -- <k>
+ ["\x4b"] = "\x68", -- <K>
+ ["\x6c"] = "\x69", -- <l>
+ ["\x4c"] = "\x6a", -- <L>
+ ["\x6d"] = "\x6f", -- <m>
+ ["\x4d"] = "\x70", -- <M>
+ ["\x6e"] = "\x71", -- <n>
+ ["\x4e"] = "\x72", -- <N>
+ ["\x6f"] = "\x75", -- <o>
+ ["\x4f"] = "\x76", -- <O>
+ ["\x70"] = "\x7b", -- <p>
+ ["\x50"] = "\x7c", -- <P>
+ ["\x71"] = "\x7d", -- <q>
+ ["\x51"] = "\x7e", -- <Q>
+ ["\x72"] = "\x7f", -- <r>
+ ["\x52"] = "\x80", -- <R>
+ ["\x73"] = "\x85", -- <s>
+ ["\x53"] = "\x86", -- <S>
+ ["\x74"] = "\x89", -- <t>
+ ["\x54"] = "\x8a", -- <T>
+ ["\x75"] = "\x8d", -- <u>
+ ["\x55"] = "\x8e", -- <U>
+ ["\x76"] = "\x93", -- <v>
+ ["\x56"] = "\x94", -- <V>
+ ["\x77"] = "\x95", -- <w>
+ ["\x57"] = "\x96", -- <W>
+ ["\x78"] = "\x97", -- <x>
+ ["\x58"] = "\x98", -- <X>
+ ["\x79"] = "\x99", -- <y>
+ ["\x59"] = "\x9a", -- <Y>
+ ["\x7a"] = "\x9d", -- <z>
+ ["\x5a"] = "\x9e", -- <Z>
+ ["\x30"] = "\xa1", -- <0>
+ ["\x31"] = "\xa2", -- <1>
+ ["\x32"] = "\xa3", -- <2>
+ ["\x33"] = "\xa4", -- <3>
+ ["\x34"] = "\xa5", -- <4>
+ ["\x35"] = "\xa6", -- <5>
+ ["\x36"] = "\xa7", -- <6>
+ ["\x37"] = "\xa8", -- <7>
+ ["\x38"] = "\xa9", -- <8>
+ ["\x39"] = "\xaa", -- <9>
+}
+
+local utf8_sort_data_2 = {
+ ["\xc3\xa1"] = "\x43", -- <á>
+ ["\xc3\x81"] = "\x44", -- <Á>
+ ["\xc3\xa4"] = "\x45", -- <ä>
+ ["\xc3\x84"] = "\x46", -- <Ä>
+ ["\xc4\x8d"] = "\x4b", -- <č>
+ ["\xc4\x8c"] = "\x4c", -- <Č>
+ ["\xc4\x8f"] = "\x4f", -- <ď>
+ ["\xc4\x8e"] = "\x50", -- <Ď>
+ ["\xc3\xa9"] = "\x53", -- <é>
+ ["\xc3\x89"] = "\x54", -- <É>
+ ["\xc4\x9b"] = "\x55", -- <ě>
+ ["\xc4\x9a"] = "\x56", -- <Ě>
+ ["\x63\x68"] = "\x5d", -- <ch>
+ ["\x63\x48"] = "\x5e", -- <cH>
+ ["\x43\x68"] = "\x5f", -- <Ch>
+ ["\x43\x48"] = "\x60", -- <CH>
+ ["\xc3\xad"] = "\x63", -- <í>
+ ["\xc3\x8d"] = "\x64", -- <Í>
+ ["\xc4\xba"] = "\x6b", -- <ĺ>
+ ["\xc4\xb9"] = "\x6c", -- <Ĺ>
+ ["\xc4\xbe"] = "\x6d", -- <ľ>
+ ["\xc4\xbd"] = "\x6e", -- <Ľ>
+ ["\xc5\x88"] = "\x73", -- <ň>
+ ["\xc5\x87"] = "\x74", -- <Ň>
+ ["\xc3\xb3"] = "\x77", -- <ó>
+ ["\xc3\x93"] = "\x78", -- <Ó>
+ ["\xc3\xb4"] = "\x79", -- <ô>
+ ["\xc3\x94"] = "\x7a", -- <Ô>
+ ["\xc5\x95"] = "\x81", -- <ŕ>
+ ["\xc5\x94"] = "\x82", -- <Ŕ>
+ ["\xc5\x99"] = "\x83", -- <ř>
+ ["\xc5\x98"] = "\x84", -- <Ř>
+ ["\xc5\xa1"] = "\x87", -- <š>
+ ["\xc5\xa0"] = "\x88", -- <Š>
+ ["\xc5\xa5"] = "\x8b", -- <ť>
+ ["\xc5\xa4"] = "\x8c", -- <Ť>
+ ["\xc3\xba"] = "\x8f", -- <ú>
+ ["\xc3\x9a"] = "\x90", -- <Ú>
+ ["\xc5\xaf"] = "\x91", -- <ů>
+ ["\xc5\xae"] = "\x92", -- <Ů>
+ ["\xc3\xbd"] = "\x9b", -- <ý>
+ ["\xc3\x9d"] = "\x9c", -- <Ý>
+ ["\xc5\xbe"] = "\x9f", -- <ž>
+ ["\xc5\xbd"] = "\xa0", -- <Ž>
+}
+
+local utf8_sort_data_3 = {
+ ["\x63"] = "\x49", -- <c>
+ ["\x43"] = "\x4a", -- <C>
+}
+
+--[[
+Vrátí počet UTF-8 znaků řetězce.
+]]
+function ch_core.utf8_length(s)
+ if s == "" then
+ return 0
+ end
+ local i, byte, bytes, chars
+ i = 1
+ chars = 0
+ bytes = string.len(s)
+ while i <= bytes do
+ byte = string.byte(s, i)
+ if byte < 192 then
+ i = i + 1
+ else
+ i = i + utf8_charlen[byte]
+ end
+ chars = chars + 1
+ end
+ return chars
+end
+
+--[[
+Začne v řetězci `s` na fyzickém indexu `i` a bude se posouvat o `seek`
+UTF-8 znaků doprava (pro záporný počet doleva); vrátí výsledný index
+(na první bajt znaku), nebo nil, pokud posun přesáhl začátek,
+resp. konec řetězce.
+]]
+function ch_core.utf8_seek(s, i, seek)
+ local bytes = string.len(s)
+ if i < 1 or i > bytes then
+ return nil
+ end
+ local b
+ if seek > 0 then
+ while true do
+ b = string.byte(s, i)
+ if b < 192 then
+ i = i + 1
+ else
+ i = i + utf8_charlen[b]
+ end
+ if i > bytes then
+ return nil
+ end
+ seek = seek - 1
+ if seek == 0 then
+ return i
+ end
+ end
+ elseif seek < 0 then
+ while true do
+ i = i - 1
+ if i < 1 then
+ return nil
+ end
+ b = string.byte(s, i)
+ if b < 128 or b >= 192 then
+ -- máme další znak
+ seek = seek + 1
+ if seek == 0 then
+ return i
+ end
+ end
+ end
+ else
+ return i
+ end
+end
+
+--[[
+ Je-li řetězec s delší než max_chars znaků, vrátí jeho prvních max_chars znaků
+ + "...", jinak vrátí původní řetězec.
+]]
+function ch_core.utf8_truncate_right(s, max_chars, dots_string)
+ local i = ch_core.utf8_seek(s, 1, max_chars)
+ if i then
+ return s:sub(1, i - 1) .. (dots_string or "...")
+ else
+ return s
+ end
+end
+
+--[[
+Rozdělí řetězec na pole neprázdných podřetězců o stanovené maximální délce
+v UTF-8 znacích; v každé části vynechává mezery na začátku a na konci části;
+přednostně dělí v místech mezer. Pro prázdný řetězec
+(nebo řetězec tvořený jen mezerami) vrací prázdné pole.
+]]
+function ch_core.utf8_wrap(s, max_chars, options)
+ local i = 1 -- index do vstupního řetězce s
+ local s_bytes = string.len(s)
+ local result = {} -- výstupní pole
+ local r_text = "" -- výstupní řetězec
+ local r_chars = 0 -- počet UTF-8 znaků v řetězci r
+ local r_sp_begin -- index první mezery v poslední sekvenci mezer v r_text
+ local r_sp_end -- index poslední mezery v poslední sekvenci mezer v r_text
+ local b -- kód prvního bajtu aktuálního znaku
+ local c_bytes -- počet bajtů aktuálního znaku
+
+ -- options
+ local allow_empty_lines, max_result_lines, line_separator
+ if options then
+ allow_empty_lines = options.allow_empty_lines -- true or false
+ max_result_lines = options.max_result_lines -- nil or number
+ line_separator = options.line_separator -- nil or string
+ end
+
+ while i <= s_bytes do
+ b = string.byte(s, i)
+ -- print("byte["..i.."] = "..b.." ("..s:sub(i, i)..") r_sp = ("..(r_sp_begin or "nil")..".."..(r_sp_end or "nil")..")")
+ if r_chars > 0 or (b ~= 32 and (b ~= 10 or allow_empty_lines)) then -- na začátku řádky ignorovat mezery
+ if b < 192 then
+ c_bytes = 1
+ else
+ c_bytes = utf8_charlen[b]
+ end
+ -- vložit do r další znak (není-li to konec řádky)
+ if b ~= 10 then
+ r_text = r_text..s:sub(i, i + c_bytes - 1)
+ r_chars = r_chars + 1
+
+ if b == 32 then
+ -- znak je mezera
+ if r_sp_begin then
+ if r_sp_end then
+ -- začátek nové skupiny mezer (už nějaká byla)
+ r_sp_begin = string.len(r_text)
+ r_sp_end = nil
+ end
+ elseif not r_sp_end then
+ -- začátek první skupiny mezer (ještě žádná nebyla)
+ r_sp_begin = string.len(r_text)
+ end
+ else
+ -- znak není mezera ani konec řádky
+ if r_sp_begin and not r_sp_end then
+ r_sp_end = string.len(r_text) - c_bytes -- uzavřít skupinu mezer
+ end
+ end
+ end
+
+ if r_chars >= max_chars or b == 10 then
+ -- dosažen maximální počet znaků nebo znak \n => uzavřít řádku
+ if line_separator and #result > 0 then
+ result[#result] = result[#result]..line_separator
+ end
+ if r_chars < max_chars or not r_sp_begin then
+ -- žádné mezery => tvrdé dělení
+ table.insert(result, r_text)
+ r_text = ""
+ r_chars = 0
+ r_sp_begin, r_sp_end = nil, nil
+ elseif not r_sp_end then
+ -- průběžná skupina mezer => rozdělit zde
+ table.insert(result, r_text:sub(1, r_sp_begin - 1))
+ r_text = ""
+ r_chars = 0
+ r_sp_begin, r_sp_end = nil, nil
+ else
+ -- byla skupina mezer => rozdělit tam
+ table.insert(result, r_text:sub(1, r_sp_begin - 1))
+ r_text = r_text:sub(r_sp_end + 1, -1)
+ r_chars = ch_core.utf8_length(r_text)
+ r_sp_begin, r_sp_end = nil, nil
+ if r_chars > 0 and b == 10 then
+ i = i - c_bytes -- read this \n-byte again
+ end
+ end
+ if max_result_lines and #result >= max_result_lines then
+ return result -- skip reading other lines
+ end
+ end
+ i = i + c_bytes
+ else
+ i = i + 1
+ end
+ end
+ if r_chars > 0 then
+ if line_separator and #result > 0 then
+ result[#result] = result[#result]..line_separator
+ end
+ if r_sp_begin and not r_sp_end then
+ -- průběžná skupina mezer
+ table.insert(result, r_text:sub(1, r_sp_begin - 1))
+ else
+ table.insert(result, r_text)
+ end
+ end
+ return result
+end
+function ch_core.utf8_radici_klic(s, store_to_cache)
+ local result = utf8_sort_cache[s]
+ if not result then
+ local i = 1
+ local l = s:len()
+ local c, k
+ result = {}
+ while i <= l do
+ c = s:sub(i, i)
+ k = utf8_sort_data_1[c]
+ if k then
+ table.insert(result, k)
+ i = i + 1
+ else
+ k = utf8_sort_data_2[s:sub(i, i + 1)]
+ if k then
+ table.insert(result, k)
+ i = i + 2
+ else
+ k = utf8_sort_data_3[c]
+ table.insert(result, k or c)
+ i = i + 1
+ end
+ end
+ end
+ result = table.concat(result)
+ if store_to_cache then
+ utf8_sort_cache[s] = result
+ end
+ end
+ return result
+end
+
+function ch_core.utf8_mensi_nez(a, b, store_to_cache)
+ a = ch_core.utf8_radici_klic(a, store_to_cache)
+ b = ch_core.utf8_radici_klic(b, store_to_cache)
+ return a < b
+end
+
+-- == CH Formspec library == --
+
+-- API:
+-- ch_core.show_formspec(player_or_player_name, formname, formspec, formspec_callback, custom_state, options)
+-- local function formspec_callback(custom_state, player, formname, fields)
+
+--[[
+ player_name => {
+ callback = function,
+ custom_state = ...,
+ formname = string,
+ object_id = int,
+ }
+]]
+local formspec_states = {}
+local formspec_states_next_id = 1
+
+local function def_to_string(label, defitem, separator)
+ if defitem == nil then
+ return ""
+ end
+ local t = type(defitem)
+ if t == "string" then
+ return label.."["..defitem.."]"
+ elseif t == "number" or t == "bool" then
+ return label.."["..tostring(defitem).."]"
+ elseif t == "table" then
+ if #defitem == 0 then
+ return label.."[]"
+ else
+ t = {}
+ for i = 1, #defitem do
+ t[i] = tostring(defitem[i])
+ end
+ t[1] = label.."["..t[1]
+ t[#t] = t[#t].."]"
+ return table.concat(t, separator)
+ end
+ else
+ return ""
+ end
+end
+
+--[[
+ Sestaví záhlaví formspecu. Dovolené klíče jsou:
+ -- formspec_version
+ -- size
+ -- position
+ -- anchor
+ -- padding
+ -- no_prepend (bool)
+ -- listcolors
+ -- bgcolor
+ -- background
+ -- background9
+ -- set_focus
+ -- auto_background (speciální, vylučuje se s background a background9)
+]]
+function ch_core.formspec_header(def)
+ local result, size_element
+
+ if def.size ~= nil then
+ if type(def.size) ~= "table" then
+ error("def.size must be a table or nil!")
+ end
+ local s = def.size
+ size_element = {"size["..tostring(s[1])}
+ for i = 2, #s - 1, 1 do
+ size_element[i] = tostring(s[i])
+ end
+ size_element[#s] = tostring(s[#s]).."]"
+ size_element = table.concat(size_element, ",")
+ else
+ size_element = ""
+ end
+
+ result = {
+ def_to_string("formspec_version", def.formspec_version, ""), -- 1
+ size_element, -- 2
+ def_to_string("position", def.position, ","), -- 3
+ def_to_string("anchor", def.anchor, ","), -- 4
+ def_to_string("padding", def.padding, ","), -- 5
+ ifthenelse(def.no_prepend == true, "no_prepend[]", ""), -- 6
+ def_to_string("listcolors", def.listcolors, ";"), -- 7
+ def_to_string("bgcolor", def.bgcolor, ";"), -- 8
+ def_to_string("background", def.background, ";"), -- 9
+ def_to_string("background9", def.background9, ";"), -- 10
+ def_to_string("set_focus", def.set_focus, ";"), -- 11
+ }
+ if not def.background and not def.background9 and def.formspec_version ~= nil and def.formspec_version > 1 then
+ if def.auto_background == true then
+ if result[7] == "" then
+ -- colors according to Technic Chests:
+ result[7] = "listcolors[#7b7b7b;#909090;#000000;#6e823c;#ffffff]"
+ end
+ --result[10] = "background9[0,0;1,1;ch_core_formspec_bg.png;true;16]"
+ -- result[9] = "background[0,0;"..fsw..","..fsh..";ch_core_formspec_bg.png]"
+ end
+ end
+ return table.concat(result)
+end
+
+--[[
+ Má-li daná postava zobrazen daný formspec, uzavře ho a vrátí true.
+ Jinak vrátí false.
+ Je-li call_callback true, nastavený callback se před uzavřením zavolá
+ s fields = {quit = "true"} a jeho návratová hodnota bude odignorována.
+]]
+function ch_core.close_formspec(player_name_or_player, formname, call_callback)
+ if formname == nil or formname == "" then
+ return false -- formname invalid
+ end
+ local p = ch_core.normalize_player(player_name_or_player)
+ if p.player == nil then
+ return false -- player invalid or not online
+ end
+ local formspec_state = formspec_states[p.player_name]
+ if formspec_state == nil or formspec_state.formname ~= formname then
+ return false -- formspec not open or the formname is different
+ end
+ if call_callback then
+ formspec_state.callback(formspec_state.custom_state, p.player, formname, {quit = "true"})
+ end
+ minetest.close_formspec(p.player_name, formname)
+ if formspec_states[p.player_name] ~= nil and formspec_states[p.player_name].object_id == formspec_state.object_id then
+ formspec_states[p.player_name] = nil
+ end
+ return true
+end
+
+--[[
+ Zobrazí hráči/ce formulář a nastaví callback pro jeho obsluhu.
+ Callback nemusí být zavolán v nestandardních situacích jako
+ v případě odpojení klienta.
+]]
+function ch_core.show_formspec(player_name_or_player, formname, formspec, callback, custom_state, options)
+ local p = ch_core.normalize_player(player_name_or_player)
+ if p.player == nil then return false end -- player invalid or not online
+
+ if formname == nil or formname == "" then
+ -- generate random formname
+ formname = "ch_core:"..minetest.sha1(tostring(bit.bxor(minetest.get_us_time(), math.random(1, 1099511627775))), false)
+ end
+
+ local id = formspec_states_next_id
+ formspec_states_next_id = id + 1
+ formspec_states[p.player_name] = {
+ callback = callback or function(...) return end,
+ custom_state = custom_state,
+ formname = formname,
+ object_id = id,
+ }
+
+ minetest.show_formspec(p.player_name, formname, formspec)
+ return formname
+end
+
+--[[
+ Aktualizuje již zobrazený formspec. Vrátí true v případě úspěchu.
+ formspec_or_function může být buď řetězec, nebo funkce, která bude
+ pro získání řetězce zavolána s parametry: (player_name, formname, custom_state).
+ Pokud nevrátí řetězec, update_formspec skončí a vrátí false.
+]]
+function ch_core.update_formspec(player_name_or_player, formname, formspec_or_function)
+ if formname == nil or formname == "" then
+ return false -- formname invalid
+ end
+ local p = ch_core.normalize_player(player_name_or_player)
+ if p.player == nil then
+ return false -- player invalid or not online
+ end
+ local formspec_state = formspec_states[p.player_name]
+ if formspec_state == nil or formspec_state.formname ~= formname then
+ return false -- formspec not open or the formname is different
+ end
+ local t = type(formspec_or_function)
+ local formspec
+ if t == "string" then
+ formspec = formspec_or_function
+ elseif t == "function" then
+ formspec = formspec_or_function(p.player_name, formname, formspec_state.custom_state)
+ if type(formspec) ~= "string" then
+ return false
+ end
+ else
+ return false -- invalid formspec argument
+ end
+ minetest.show_formspec(p.player_name, formname, formspec)
+ return true
+end
+
+local function on_player_receive_fields(player, formname, fields)
+ local player_name = assert(player:get_player_name())
+ local formspec_state = formspec_states[player_name]
+ if formspec_state == nil then
+ return -- formspec not by ch_core
+ end
+ if formspec_state.formname ~= formname then
+ minetest.log("warning", player_name..": received fields of form "..(formname or "nil").." when "..(formspec_state.formname or "nil").." was expected")
+ formspec_states[player_name] = nil
+ return
+ end
+ local result = formspec_state.callback(formspec_state.custom_state, player, formname, fields, {}) -- custom_state, player, formname, fields
+ if type(result) == "string" then
+ -- string => show as formspec
+ formspec_states[player_name] = formspec_state
+ minetest.show_formspec(player_name, formname, result)
+ elseif fields ~= nil and fields.quit == "true" and formspec_states[player_name] ~= nil and formspec_states[player_name].object_id == formspec_state.object_id then
+ formspec_states[player_name] = nil
+ end
+ return true
+end
+minetest.register_on_player_receive_fields(on_player_receive_fields)
+
+
+-- set into place
+advtrains.lines.ch_core = ch_core
diff --git a/advtrains_line_automation/init.lua b/advtrains_line_automation/init.lua
index 7b758bc..8bc7ee4 100644
--- a/advtrains_line_automation/init.lua
+++ b/advtrains_line_automation/init.lua
@@ -18,10 +18,21 @@ advtrains.lines = {
local modpath = minetest.get_modpath(minetest.get_current_modname()) .. DIR_DELIM
+-- ask engine for translator instance, this will load the translation files
+advtrains.lines.translate = core.get_translator("advtrains_line_automation")
+
+-- Get current translator
+local S = advtrains.lines.translate
+
+dofile(modpath.."ch_functions.lua")
dofile(modpath.."railwaytime.lua")
+dofile(modpath.."line_functions.lua")
+dofile(modpath.."line_editor.lua")
dofile(modpath.."scheduler.lua")
+dofile(modpath.."station_editor.lua")
dofile(modpath.."stoprail.lua")
-
+--dofile(modpath.."station_announcement.lua") -- not yet working
+dofile(modpath.."time_table.lua")
function advtrains.lines.load(data)
if data then
@@ -45,3 +56,4 @@ function advtrains.lines.step(dtime)
advtrains.lines.rwt.step(dtime)
advtrains.lines.sched.run()
end
+
diff --git a/advtrains_line_automation/line_editor.lua b/advtrains_line_automation/line_editor.lua
new file mode 100644
index 0000000..2854fb7
--- /dev/null
+++ b/advtrains_line_automation/line_editor.lua
@@ -0,0 +1,864 @@
+local def
+local F = minetest.formspec_escape
+local ch_core = advtrains.lines.ch_core
+local S = advtrains.lines.translate
+--[[
+Jednoduchá funkce, která vyhodnotí condition jako podmínku
+a podle výsledku vrátí buď true_result, nebo false_result.
+]]
+local function ifthenelse(condition, true_result, false_result)
+ if condition then
+ return true_result
+ else
+ return false_result
+ end
+end
+-- Singularis-Merge: Emulate certain ch functionality
+local function prihlasovaci_na_zobrazovaci(prihlasovaci)
+ return prihlasovaci -- no-op. On CH used to colorize the name to reflect the rank of the player
+end
+
+local max_stations = 60
+
+local MODE_NORMAL = 0 -- normální zastávka (výchozí nebo mezilehlá)
+local MODE_REQUEST_STOP = 1 -- zastávka na znamení (mezilehlá)
+local MODE_HIDDEN = 2 -- skrytá zastávka (výchozí nebo mezilehlá)
+local MODE_DISABLED = 3 -- vypnutá zastávka (mezilehlá nebo koncová)
+local MODE_FINAL = 4 -- koncová zastávka (linka zde jízdu končí)
+local MODE_FINAL_HIDDEN = 5 -- koncová zastávka skrytá
+local MODE_FINAL_CONTINUE = 6 -- koncová zastávka (vlak pokračuje jako jiná linka)
+
+local color_red = core.get_color_escape_sequence("#ff0000")
+local color_green = core.get_color_escape_sequence("#00ff00")
+
+local cancel_linevar = assert(advtrains.lines.cancel_linevar)
+local get_last_passages = assert(advtrains.lines.get_last_passages)
+local get_line_description = assert(advtrains.lines.get_line_description)
+local linevar_decompose = assert(advtrains.lines.linevar_decompose)
+local try_get_linevar_def = assert(advtrains.lines.try_get_linevar_def)
+
+local show_last_passages_formspec -- forward declaration
+
+local function check_rights(pinfo, owner)
+ if pinfo.role == "new" or pinfo.role == "none" then
+ return false
+ end
+ if owner == nil or pinfo.role == "admin" or pinfo.player_name == owner then
+ return true
+ end
+ return false
+end
+
+local function get_stn_from_linevar(linevar)
+ local line, stn = linevar_decompose(linevar)
+ return ifthenelse(line ~= nil, stn, nil)
+end
+
+local function add_linevar(stn, linevar_def)
+ local station = advtrains.lines.stations[stn]
+ if station == nil then
+ return false, "Chybná stanice!"
+ end
+ local linevars = station.linevars
+ if linevars == nil then
+ linevars = {}
+ station.linevars = linevars
+ end
+ if linevars[linevar_def.name] ~= nil then
+ return false, "Nemohu přidat, varianta linky '"..linevar_def.name.."' již existuje."
+ end
+ linevars[linevar_def.name] = linevar_def
+ return true, nil
+end
+
+local function same_stops(stops1, stops2)
+ assert(stops1)
+ assert(stops2)
+ if #stops1 ~= #stops2 then
+ return false
+ end
+ for i, stop in ipairs(stops1) do
+ if stop.stn ~= stops2[i].stn then
+ return false
+ end
+ end
+ return true
+end
+
+local function replace_linevar(stn, linevar_def)
+ local station = advtrains.lines.stations[stn]
+ if station == nil or station.linevars == nil then
+ return false, S("No such station")
+ end
+ local linevar = assert(linevar_def.name)
+ local linevars = station.linevars
+ local old_linevar_def = linevars[linevar]
+ if old_linevar_def == nil then
+ return false, S("Cannot replace, because lineval @1 does not yet exist", linevar)
+ end
+ linevars[linevar] = linevar_def
+ local restart_count = 0
+ if not same_stops(old_linevar_def.stops, linevar_def.stops) then
+ -- změnily se zastávky, musíme restartovat vlaky:
+ for train_id, train in pairs(advtrains.trains) do
+ local ls = train.line_status
+ if ls ~= nil and ls.linevar == linevar then
+ core.log("action", "Train "..train_id.." restarted from index "..ls.linevar_index.." due to replacement of linevar '"..linevar.."'.")
+ ls.linevar_index = 1
+ restart_count = restart_count + 1
+ end
+ end
+ end
+ if restart_count > 0 then
+ return true, S("@1 trains restarted due to changes", restart_count)
+ else
+ return true, nil
+ end
+end
+
+local function delete_linevar(stn, linevar)
+ local station = advtrains.lines.stations[stn]
+ if station == nil or station.linevars == nil then
+ return false, S("No such station")
+ end
+ local linevars = station.linevars
+ if linevars[assert(linevar)] == nil then
+ return false, S("Cannot delete, because lineval @1 does not yet exist", linevar)
+ end
+ linevars[linevar] = nil
+ for train_id, train in pairs(advtrains.trains) do
+ local ls = train.line_status
+ if ls ~= nil and ls.linevar == linevar then
+ core.log("action", "Train "..train_id.." removed from deleted linevar '"..linevar.."'.")
+ cancel_linevar(train)
+ end
+ end
+ return true, nil
+end
+
+local function get_formspec(custom_state)
+ local pinfo = ch_core.normalize_player(assert(custom_state.player_name))
+ if pinfo.player == nil then
+ minetest.log("error", "Expected player not in game!")
+ return ""
+ end
+
+ local selection_index_raw = custom_state.selection_index
+ local selection_index = selection_index_raw or 1
+ local formspec = {
+ ch_core.formspec_header({formspec_version = 6, size = {20, 16}, auto_background = true}),
+ "label[0.5,0.6;"..S("Line Editor").."]"..
+ "style[s01_pos",
+ }
+ for i = 2, max_stations do
+ table.insert(formspec, string.format(",s%02d_pos", i))
+ end
+ 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,VAR.")..",#ffffff,"..S("OWNER")..",#ffffff,STATUS")
+
+ for _, linevar_def in ipairs(custom_state.linevars) do
+ local lv_line, lv_stn, lv_rc = linevar_decompose(linevar_def.name)
+ local color = ifthenelse(linevar_def.disabled, "#cccccc", "#ffffff")
+ table.insert(formspec,
+ ","..color..","..F(lv_line)..","..F(get_line_description(linevar_def, {first_stop = true, last_stop = true}))..
+ ","..F(lv_rc)..","..ifthenelse(linevar_def.owner == pinfo.player_name, "#00ff00", color)..",")
+ table.insert(formspec, F(prihlasovaci_na_zobrazovaci(linevar_def.owner)))
+ table.insert(formspec, ","..color..",")
+ if linevar_def.disabled then
+ table.insert(formspec, "vypnutá")
+ end
+ end
+ if selection_index_raw ~= nil then
+ table.insert(formspec, ";"..selection_index.."]")
+ else
+ table.insert(formspec, ";]")
+ end
+ if pinfo.role ~= "new" then
+ table.insert(formspec, "button[14.5,0.3;3.5,0.75;create;"..S("New Line...").."]")
+ end
+ local has_rights_to_open_variant =
+ pinfo.role == "admin" or selection_index == 1 or
+ pinfo.player_name == custom_state.linevars[selection_index - 1].owner
+
+ if selection_index > 1 and has_rights_to_open_variant then
+ 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;"..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
+ table.insert(formspec, "field[7,7;4,0.75;owner;"..S("Owner:")..";")
+ end
+ table.insert(formspec, F(custom_state.owner).."]"..
+ "checkbox[11.25,7.25;disable_linevar;"..S("Disable")..";"..custom_state.disable_linevar.."]"..
+ "field[13.5,7;3,0.75;continues;"..S("Continues:")..";"..F(custom_state.continues).."]")
+
+ if custom_state.message ~= "" then
+ table.insert(formspec, "label[0.5,8.25;"..F(custom_state.message).."]")
+ end
+ if selection_index > 1 then
+ table.insert(formspec, "button[5,15;4.5,0.75;last_passages;"..S("Last passages").."]"..
+ "tooltip[last_passages;Zobrazí přehled časů několika posledních jízd na dané variantě linky.]")
+ end
+ if has_rights_to_open_variant then
+ table.insert(formspec, "button[10,15;4.5,0.75;save;"..
+ ifthenelse(custom_state.compiled_linevar == nil, S("Verify/Save").."]", S("Save changes").."]"))
+ end
+ table.insert(formspec, "button[15,15.25;4,0.5;reset;"..S("Reset changes").."]")
+ table.insert(formspec, "tooltip[line;"..
+ S("Line designation. Must not be empty. This identifies a certain line.").."]"..
+ "tooltip[rc;"..S("Line variant code. Optional, can be used to identify different variants of a line (e.g. branches).").."]"..
+ "tooltip[train_name;"..S("Optional field, name of the line as used in departure displays and on timetables.").."]"..
+ "tooltip[disable_linevar;"..S("Check to disable the timetable.\nA disabled timetable will not be used for new trains, trains already on the line will finish it.").."]")
+
+ table.insert(formspec, "container[0,8.75]"..
+ "label[0.5,0.25;"..S("Dep.").."]"..
+ "label[2,0.25;"..S("St.Time").."]"..
+ "label[3.5,0.25;"..S("Station Code").."]"..
+ "label[6.25,0.25;"..S("Mode").."]"..
+ "label[11,0.25;"..S("Track").."]"..
+ "label[12.5,0.25;"..S("Position").."]"..
+ "scrollbaroptions[min=0;max=550;arrows=show]"..
+ "scrollbar[19,0.5;0.5,5.5;vertical;evl_scroll;"..custom_state.evl_scroll.."]"..
+ "scroll_container[0.5,0.5;18.5,5.5;evl_scroll;vertical]"..
+ "box[0,0;20,70;#00808040]") -- box[] = pozadí
+
+ -- výchozí zastávka:
+ table.insert(formspec,
+ "label[0.1,0.4;0]"..
+ "field[1.5,0;1.25,0.75;s01_wait;;"..F(custom_state.stops[1].wait).."]"..
+ "field[3,0;2.5,0.75;s01_stn;;"..F(custom_state.stops[1].stn).."]"..
+ "dropdown[5.75,0;4.5,0.75;s01_mode;"..S("Normal")..","..S("Hidden (normal)")..";"..custom_state.stops[1].mode..";true]"..
+ "field[10.5,0;1.25,0.75;s01_track;;"..F(custom_state.stops[1].track).."]"..
+ "field[12,0;3,0.75;s01_pos;;"..F(custom_state.stops[1].pos).."]"..
+ "label[15.25,0.4;"..F(custom_state.stops[1].label).."]")
+
+ -- ostatní zastávky:
+ local y_base, y_scale = 0, 1
+ for i = 2, max_stations do
+ local stop = custom_state.stops[i]
+ local n
+ if i < 10 then
+ n = "0"..i
+ else
+ n = tostring(i)
+ end
+ local y = string.format("%f", y_base + (i - 1) * y_scale)
+ local y2 = string.format("%f", y_base + (i - 1) * y_scale + 0.4) -- for a label
+ table.insert(formspec,
+ "field[0,"..y..";1.25,0.75;s"..n.."_dep;;"..F(stop.dep).."]"..
+ "field[1.5,"..y..";1.25,0.75;s"..n.."_wait;;"..F(stop.wait).."]"..
+ "field[3,"..y..";2.5,0.75;s"..n.."_stn;;"..F(stop.stn).."]"..
+ "dropdown[5.75,"..y..";4.5,0.75;s"..n..
+ "_mode;"..S("Normal")..","..S("Request Stop (experimental)")..","..S("Hidden")..","..S("Inactive")..","..S("Terminus")..","..S("Terminus (hidden)")..","..
+ S("Terminus (continuing)")..";"..stop.mode..";true]"..
+ "field[10.5,"..y..";1.25,0.75;s"..n.."_track;;"..F(stop.track).."]"..
+ "field[12,"..y..";3,0.75;s"..n.."_pos;;"..F(stop.pos).."]"..
+ "label[15.25,"..y2..";"..F(stop.label).."]")
+ end
+
+ table.insert(formspec,
+ "scroll_container_end[]"..
+ "tooltip[0,0;1.5,1;"..S("Departure: Time (in seconds) after the start of the timetable at which the train departs from this station.\nIt is used to calculate delays. Stations on the line are sorted by their departure time.\nSet this field empty to delete a station from the timetable.").."]"..
+ "tooltip[1.5,0;1.5,1;"..S("Stop time: Minimum time (in seconds) for which the train stops at the station before departing.").."]"..
+ "tooltip[3.5,0;2.75,1;"..S("Station code: The code of the station to stop/pass.").."]"..
+ "tooltip[6.25,0;4.75,1;"..S("Stop mode:\nNormal - Train stops and departs after the stop time\nRequest stop - Train stops when the 'stop request' button is pressed\nHidden - like Normal, but is not shown in passenger timetable\nInactive - passes without stopping\nTerminus - Train stops and ends the timetable operation\nTerminus (hidden) - like Terminus, but will not appear in the passenger timetable\nTerminus (continuing) - Train will continue as timetable configured in the stop rail at the terminus location").."]"..
+ "container_end[]")
+
+ -- if pinfo.role ~= "new" then
+ return table.concat(formspec)
+end
+
+local mode_from_formspec_map = {MODE_NORMAL, MODE_REQUEST_STOP, MODE_HIDDEN, MODE_DISABLED, MODE_FINAL, MODE_FINAL_HIDDEN, MODE_FINAL_CONTINUE}
+local mode_to_formspec_map = table.key_value_swap(mode_from_formspec_map)
+
+local function mode_to_formspec(i, raw_mode)
+ if i == 1 then
+ return ifthenelse(raw_mode ~= nil and raw_mode == MODE_HIDDEN, 2, 1)
+ elseif raw_mode == nil then
+ return 1
+ else
+ return mode_to_formspec_map[raw_mode] or 1
+ end
+end
+
+local function mode_from_formspec(i, fs_mode)
+ if i == 1 then
+ return ifthenelse(fs_mode == 2, MODE_HIDDEN, nil)
+ else
+ local result = mode_from_formspec_map[fs_mode]
+ return ifthenelse(result ~= nil and result ~= MODE_NORMAL, result, nil)
+ end
+end
+
+local function custom_state_set_selection_index(custom_state, new_selection_index)
+ -- this will also refresh stops and resets the changes
+ assert(custom_state.player_name)
+ assert(custom_state.linevars)
+ assert(new_selection_index)
+ local current_linevar = custom_state.linevars[new_selection_index - 1]
+ custom_state.selection_index = new_selection_index or 1
+ local stops = custom_state.stops
+ if stops == nil then
+ stops = {}
+ custom_state.stops = stops
+ end
+ local linevar_stops
+ if current_linevar ~= nil then
+ linevar_stops = current_linevar.stops
+ else
+ linevar_stops = {}
+ end
+
+ for i = 1, max_stations do
+ local stop = linevar_stops[i]
+ if stop ~= nil then
+ stops[i] = {
+ dep = tostring(assert(stop.dep)),
+ wait = tostring(stop.wait or 10),
+ stn = assert(stop.stn),
+ mode = mode_to_formspec(i, stop.mode),
+ track = stop.track or "",
+ pos = stop.pos or "",
+ label = "",
+ }
+ else
+ stops[i] = {
+ dep = ifthenelse(i == 1, "0", ""),
+ wait = "10",
+ stn = "",
+ mode = 1,
+ track = "",
+ pos = "",
+ label = "",
+ }
+ end
+ end
+ if current_linevar ~= nil then
+ local lv_line, lv_stn, lv_rc = linevar_decompose(current_linevar.name)
+ custom_state.line = lv_line or ""
+ custom_state.rc = lv_rc or ""
+ custom_state.train_name = current_linevar.train_name or ""
+ custom_state.owner = assert(current_linevar.owner)
+ custom_state.disable_linevar = ifthenelse(current_linevar.disabled, "true", "false")
+ custom_state.continues = current_linevar.continue_line or ""
+ if custom_state.continues ~= "" then
+ custom_state.continues = custom_state.continues.."/"..(current_linevar.continue_rc or "")
+ end
+ else
+ custom_state.line = ""
+ custom_state.rc = ""
+ custom_state.train_name = ""
+ custom_state.owner = custom_state.player_name
+ custom_state.disable_linevar = "false"
+ custom_state.continues = ""
+ end
+ custom_state.owner = prihlasovaci_na_zobrazovaci(custom_state.owner)
+ custom_state.compiled_linevar = nil
+ custom_state.evl_scroll = 0
+ custom_state.message = ""
+end
+
+local function num_transform(s)
+ local prefix = s:match("^([0-9]+)/")
+ if prefix == nil then
+ return s
+ end
+ return string.format(" %020d%s", tonumber(prefix) or 0, s:sub(#prefix, -1))
+end
+
+local function linevars_sorter(a, b)
+ return num_transform(a.name) < num_transform(b.name)
+end
+
+local function custom_state_refresh_linevars(custom_state, linevar_to_select)
+ assert(custom_state.player_name)
+ local linevars = {}
+ for _, stdata in pairs(advtrains.lines.stations) do
+ if stdata.linevars ~= nil then
+ for _, linevar_def in pairs(stdata.linevars) do
+ table.insert(linevars, linevar_def)
+ end
+ end
+ end
+ table.sort(linevars, linevars_sorter)
+ custom_state.selection_index = nil
+ custom_state.linevars = linevars
+ custom_state.compiled_linevar = nil
+ if linevar_to_select ~= nil then
+ for i, linevar_def in ipairs(linevars) do
+ if linevar_def.name == linevar_to_select then
+ custom_state_set_selection_index(custom_state, i + 1)
+ return true
+ end
+ end
+ return false
+ end
+end
+
+local function custom_state_compile_linevar(custom_state)
+ local stations = advtrains.lines.stations
+ local line = assert(custom_state.line)
+ local stn = assert(custom_state.stops[1].stn)
+ local rc = assert(custom_state.rc)
+ local train_name = assert(custom_state.train_name)
+ local owner = assert(custom_state.owner)
+ local stops = {}
+ if line == "" then
+ return false, S("Line name must not be empty!")
+ elseif line:find("[/|\\]") then
+ return false, S("Line name must not contain characters '/', '|' or '\\'!")
+ elseif line:len() > 256 then
+ return false, S("Line name must not exceed 256 characters!")
+ elseif stn == "" then
+ return false, S("Starting station code must not be empty!")
+ elseif rc:find("[/|\\]") then
+ return false, S("Routing code must not contain '/', '|' or '\\'!")
+ elseif owner == "" then
+ return false, S("Line owner must not be empty!")
+ elseif train_name:len() > 256 then
+ return false, S("Train name must not exceed 256 characters!")
+ elseif custom_state.continues:len() - custom_state.continues:gsub("/", ""):len() > 1 then
+ return false, S("Field 'Continuation' must contain maximum 1 '/'!")
+ end
+ -- Zkontrolovat zastávky:
+ local errcount = 0
+ local finalcount = 0
+ local dep_to_index = {}
+ for i, stop in ipairs(assert(custom_state.stops)) do
+ local good_label
+ stop.label = ""
+ if stop.dep == "" then
+ -- přeskočit
+ elseif not stop.dep:match("^[0-9][0-9]*$") then
+ errcount = errcount + 1
+ stop.label = color_red..S("Incorrect departure time format!")
+ elseif tonumber(stop.dep) < 0 or tonumber(stop.dep) > 3600 then
+ errcount = errcount + 1
+ stop.label = color_red..S("Departure time must lie within 0-3600 seconds!")
+ elseif dep_to_index[tonumber(stop.dep)] ~= nil then
+ errcount = errcount + 1
+ stop.label = color_red..S("Duplicate departure time!")
+ else
+ dep_to_index[tonumber(stop.dep)] = i
+ if stop.stn == "" or stations[stop.stn] == nil or stations[stop.stn].name == nil then
+ errcount = errcount + 1
+ stop.label = color_red..S("Unknown station code!")
+ elseif stop.stn:find("[/|\\]") then
+ errcount = errcount + 1
+ stop.label = color_red..S("Station code must not contain '/', '|' or '\\'!")
+ elseif stop.track:len() > 16 then
+ errcount = errcount + 1
+ stop.label = color_red..S("Line name must not exceed 16 characters!")
+ elseif stop.pos ~= "" and not stop.pos:match("^[-0-9][0-9]*,[-0-9][0-9]*,[-0-9][0-9]*$") then
+ errcount = errcount + 1
+ stop.label = color_red..S("Incorrect format for stop position!")
+ elseif stop.pos:len() > 22 then
+ errcount = errcount + 1
+ stop.label = color_red..S("Stop position must not exceed 22 characters!")
+ else
+ -- v pořádku:
+ local new_stop = {
+ stn = stop.stn,
+ dep = tonumber(stop.dep),
+ }
+ local new_mode = mode_from_formspec(i, stop.mode)
+ if new_mode ~= nil then
+ new_stop.mode = new_mode
+ if i > 1 and (new_mode == MODE_FINAL or new_mode == MODE_FINAL_CONTINUE or new_mode == MODE_FINAL_HIDDEN) then
+ finalcount = finalcount + 1
+ end
+ end
+ if stop.pos ~= "" then
+ new_stop.pos = stop.pos
+ end
+ if stop.track ~= "" then
+ new_stop.track = stop.track
+ end
+ local new_wait = tonumber(stop.wait)
+ if new_wait ~= nil and new_wait == math.floor(new_wait) and new_wait >= 0 and new_wait <= 3600 then
+ new_stop.wait = new_wait
+ end
+ table.insert(stops, new_stop)
+ if stop.stn ~= "" then
+ stop.label = color_green.."= "..assert(stations[stop.stn].name)
+ end
+ end
+ end
+ end
+ if errcount > 0 then
+ return false, S("@1 errors while checking line setup!", errcount)
+ end
+ if finalcount == 0 then
+ return false, S("Line setup must contain at least 1 terminus stop!")
+ end
+ table.sort(stops, function(a, b) return a.dep < b.dep end)
+
+ local index_vychozi, index_cil
+ for i, stop in ipairs(stops) do
+ local mode = stop.mode or MODE_NORMAL
+ if mode ~= MODE_DISABLED and mode ~= MODE_HIDDEN and mode ~= MODE_FINAL_HIDDEN then
+ if index_vychozi == nil then
+ index_vychozi = i
+ end
+ index_cil = i
+ end
+ if mode == MODE_FINAL or mode == MODE_FINAL_CONTINUE or mode == MODE_FINAL_HIDDEN then
+ break
+ end
+ end
+
+ custom_state.compiled_linevar = {
+ name = line.."/"..stops[1].stn.."/"..rc,
+ owner = owner, -- ch_core.jmeno_na_prihlasovaci(owner),
+ stops = stops,
+ continue_line = "",
+ continue_rc = "",
+ index_vychozi = index_vychozi,
+ index_cil = index_cil,
+ }
+ if train_name ~= "" then
+ custom_state.compiled_linevar.train_name = train_name
+ end
+ if custom_state.disable_linevar == "true" then
+ custom_state.compiled_linevar.disabled = true
+ end
+ local continues_split = custom_state.continues:find("/")
+ if continues_split == nil then
+ custom_state.compiled_linevar.continue_line = custom_state.continues
+ else
+ custom_state.compiled_linevar.continue_line = custom_state.continues:sub(1, continues_split - 1)
+ custom_state.compiled_linevar.continue_rc = custom_state.continues:sub(continues_split + 1, -1)
+ end
+ return true, nil
+end
+
+local function formspec_callback(custom_state, player, formname, fields)
+ local reload_stations, update_formspec = false, false
+ -- print("DEBUG: "..dump2({custom_state = custom_state, formname = formname, fields = fields}))
+
+ if fields.quit then
+ return
+ end
+ -- scrollbar:
+ if fields.evl_scroll then
+ local event = core.explode_scrollbar_event(fields.evl_scroll)
+ if event.type == "CHG" then
+ custom_state.evl_scroll = event.value
+ end
+ end
+ -- checkbox:
+ if fields.disable_linevar then
+ custom_state.disable_linevar = fields.disable_linevar
+ end
+ -- dropdowns:
+ for i = 1, max_stations do
+ local id = string.format("s%02d_mode", i)
+ local n = tonumber(fields[id])
+ if n ~= nil then
+ custom_state.stops[i].mode = n
+ end
+ end
+ -- fields:
+ for _, key in ipairs({"line", "rc", "train_name", "owner", "continues"}) do
+ if fields[key] then
+ custom_state[key] = fields[key]
+ end
+ end
+ for i, stop in ipairs(custom_state.stops) do
+ local prefix = string.format("s%02d_", i)
+ for _, key in ipairs({"dep", "wait", "stn", "track", "pos"}) do
+ local value = fields[prefix..key]
+ if value then
+ stop[key] = value
+ end
+ end
+ end
+ -- selection:
+ if fields.linevar then
+ local event = core.explode_table_event(fields.linevar)
+ if event.type == "CHG" or event.type == "DCL" then
+ custom_state_set_selection_index(custom_state, assert(tonumber(event.row)))
+ update_formspec = true
+ end
+ end
+
+ -- buttons:
+ if fields.create then
+ custom_state_set_selection_index(custom_state, 1)
+ update_formspec = true
+ elseif fields.reset then
+ custom_state_set_selection_index(custom_state, custom_state.selection_index or 1)
+ update_formspec = true
+ elseif fields.save then
+ local pinfo = ch_core.normalize_player(player)
+ if pinfo.role == "new" or pinfo.role == "none" then
+ core.log("error", "Access violation in line editor caused by '"..pinfo.player_name.."'!")
+ return -- access violation!
+ end
+ if custom_state.compiled_linevar == nil then
+ -- zkontrolovat a skompilovat
+ local success, errmsg = custom_state_compile_linevar(custom_state)
+ if success then
+ -- TODO: zkontrolovat práva a možnost přepsání i zde!
+ custom_state.message = color_green..S("No issues found, the line can now be saved!")
+ else
+ custom_state.message = color_red..S("Error in line setup: ")..(errmsg or S("Unknown reason"))
+ end
+ update_formspec = true
+ else
+ -- pokusit se uložit...
+ custom_state.message = ""
+
+ local selection_index = custom_state.selection_index or 1
+ local selected_linevar, selected_linevar_def, selected_linevar_station
+ local to_linevar, to_linevar_def, to_linevar_station
+ local new_linevar, new_linevar_def, new_linevar_station
+
+ -- NEW:
+ new_linevar_def = custom_state.compiled_linevar
+ new_linevar = new_linevar_def.name
+ new_linevar_station = get_stn_from_linevar(new_linevar)
+
+ -- SELECTED:
+ if custom_state.selection_index > 1 and custom_state.linevars[selection_index - 1] ~= nil then
+ selected_linevar_def, selected_linevar_station = try_get_linevar_def(custom_state.linevars[selection_index - 1].name)
+ if selected_linevar_def ~= nil then
+ selected_linevar = selected_linevar_def.name
+ end
+ end
+
+ -- TO OVERWRITE:
+ to_linevar_def, to_linevar_station = try_get_linevar_def(new_linevar)
+ if to_linevar_def ~= nil then
+ to_linevar = to_linevar_def.name
+ end
+
+ local success, errmsg
+ if selected_linevar == nil then
+ if to_linevar == nil then
+ -- zcela nová varianta
+ core.log("action", "Will add a new linevar '"..new_linevar.."'")
+ success, errmsg = add_linevar(new_linevar_station, new_linevar_def)
+ else
+ -- replace
+ core.log("action", "Will replace an existing linevar '"..new_linevar.."'")
+ success = check_rights(pinfo, to_linevar_def.owner)
+ if success then
+ success, errmsg = replace_linevar(new_linevar_station, new_linevar_def)
+ else
+ errmsg = S("Insufficient permissions to edit '@1'.", to_linevar)
+ end
+ end
+ elseif to_linevar == nil then
+ -- delete and add
+ core.log("action", "Will delete selected linevar '"..selected_linevar.."' and add new linevar '"..new_linevar.."'")
+ success = check_rights(pinfo, selected_linevar_def.owner)
+ if success then
+ success, errmsg = delete_linevar(selected_linevar_station, selected_linevar)
+ if success then
+ success, errmsg = add_linevar(new_linevar_station, new_linevar_def)
+ end
+ else
+ errmsg = S("Insufficient permissions to edit '@1'.", selected_linevar)
+ end
+ elseif selected_linevar ~= to_linevar then
+ -- delete and replace
+ core.log("action", "Will add delete selected linevar '"..selected_linevar.."' and replace existing linevar '"..new_linevar.."'")
+ success = check_rights(pinfo, to_linevar_def.owner)
+ if success then
+ success = check_rights(pinfo, selected_linevar_def.owner)
+ if success then
+ success, errmsg = delete_linevar(selected_linevar_station, selected_linevar)
+ if success then
+ success, errmsg = replace_linevar(new_linevar_station, new_linevar_def)
+ end
+ else
+ errmsg = S("Insufficient permissions to edit '@1'.", selected_linevar)
+ end
+ else
+ errmsg = S("Insufficient permissions to edit '@1'.", to_linevar)
+ end
+ else
+ -- replace
+ core.log("action", "Will replace existing linevar '"..new_linevar.."'")
+ success = check_rights(pinfo, to_linevar_def.owner)
+ if success then
+ success, errmsg = replace_linevar(new_linevar_station, new_linevar_def)
+ else
+ errmsg = S("Insufficient permissions to edit '@1'.", to_linevar)
+ end
+ end
+
+ if success then
+ custom_state.message = color_green..S("Line '@1' successfully saved!", new_linevar)
+ custom_state_refresh_linevars(custom_state, new_linevar)
+ else
+ custom_state.message = color_red..S("Error in line setup: ")..(errmsg or S("Unknown reason"))
+ end
+ update_formspec = true
+ end
+
+ elseif fields.delete then
+ local pinfo = ch_core.normalize_player(player)
+ if pinfo.role == "new" or pinfo.role == "none" then
+ core.log("error", "Access violation in line editor caused by '"..pinfo.player_name.."'!")
+ return -- access violation!
+ end
+ local selection_index = custom_state.selection_index or 1
+ local selected_linevar, selected_linevar_def, selected_linevar_station
+ if selection_index > 1 and custom_state.linevars[selection_index - 1] ~= nil then
+ selected_linevar_def, selected_linevar_station = try_get_linevar_def(custom_state.linevars[selection_index - 1].name)
+ if selected_linevar_def ~= nil then
+ selected_linevar = selected_linevar_def.name
+ end
+ local success, errmsg
+ success = check_rights(pinfo, selected_linevar_def.owner)
+ if success then
+ success, errmsg = delete_linevar(selected_linevar_station, selected_linevar)
+ else
+ errmsg = S("Insufficient permissions to edit '@1'.", selected_linevar)
+ end
+ if success then
+ custom_state.message = S("Line '@1' successfully deleted!", selected_linevar)
+ custom_state_refresh_linevars(custom_state)
+ custom_state_set_selection_index(custom_state, 1)
+ else
+ custom_state.message = S("Deletion failed: ")..(errmsg or S("Unknown reason"))
+ end
+ update_formspec = true
+ end
+ elseif fields.last_passages then
+ local selected_linevar_def = try_get_linevar_def(custom_state.linevars[(custom_state.selection_index or 1) - 1].name)
+ if selected_linevar_def ~= nil then
+ assert(selected_linevar_def.name)
+ show_last_passages_formspec(player, selected_linevar_def, assert(selected_linevar_def.name))
+ return
+ end
+ end
+
+ if update_formspec then
+ return get_formspec(custom_state)
+ end
+end
+
+local function show_editor_formspec(player, linevar_to_select)
+ if player == nil then return false end
+ local custom_state = {
+ player_name = assert(player:get_player_name()),
+ evl_scroll = 0,
+ message = "",
+ continues = "",
+ }
+ if not custom_state_refresh_linevars(custom_state, linevar_to_select) then
+ custom_state_set_selection_index(custom_state, 1)
+ end
+ 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
+
+show_last_passages_formspec = function(player, linevar_def, selected_linevar)
+ local rwt = advtrains.lines.rwt
+ local formspec = {
+ "formspec_version[6]"..
+ "size[20,10]"..
+ "label[0.5,0.6;",
+ S("Last passages of line @1", F(assert(linevar_def.name))),
+ "]"..
+ "tablecolumns[text;text;text,width=5;text,width=5;text,width=5;text,width=5;text,width=5;text,width=5;text,width=5;text,width=5;text,width=5;text,width=5]",
+ "table[0.5,1.25;19,8;jizdy;",S("Code"),",",S("Station"),",1.j.,2.j.,3.j.,4.j.,5.j.,6.j.,7.j.,8.j.,9.j.,10.j."
+ }
+ local passages, stops = get_last_passages(linevar_def)
+ local max_time = {}
+ if passages ~= nil then
+ for j = 1, 10 do
+ max_time[j] = 0
+ if passages[j] == nil then
+ passages[j] = {}
+ end
+ end
+ -- stání na výchozí zastávce:
+ table.insert(formspec, ",,"..S("At start station:"))
+ for j = 1, 10 do
+ local wait = passages[j].wait
+ if wait ~= nil then
+ table.insert(formspec, ","..wait.." s")
+ else
+ table.insert(formspec, ",-")
+ end
+ end
+ -- odjezd z výchozí zastávky:
+ table.insert(formspec, ","..F(stops[1][1])..","..F(stops[1][2]).." "..S("(departed)"))
+ for j = 1, 10 do
+ local time = passages[j][1]
+ if time ~= nil then
+ table.insert(formspec, ",("..core.formspec_escape(rwt.t_str(time, 1))..")")
+ if rwt.is_before(max_time[j], time) then
+ max_time[j] = time
+ end
+ else
+ table.insert(formspec, ",-")
+ end
+ end
+ -- odjezdy z ostatních zasŧávek:
+ for i = 2, #stops do -- i = index zastávky
+ table.insert(formspec, ","..F(stops[i][1])..","..F(stops[i][2]))
+ for j = 1, 10 do -- j = index jízdy
+ local dep_vych = passages[j][1]
+ local time = passages[j][i]
+ if time ~= nil and dep_vych ~= nil then
+ table.insert(formspec, ","..(rwt.diff(dep_vych, time)))
+ if rwt.is_before(max_time[j], time) then
+ max_time[j] = time
+ end
+ else
+ table.insert(formspec, ",-")
+ end
+ end
+ end
+ table.insert(formspec, ",,"..S("Travelling:"))
+ for i = 1, 10 do
+ if max_time[i] ~= 0 then
+ table.insert(formspec, ",_"..(rwt.diff(passages[i][1], max_time[i])).."_")
+ else
+ table.insert(formspec, ",-")
+ end
+ 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;"..S("Time data in seconds of railway time").."]")
+ formspec = table.concat(formspec)
+ local custom_state = {
+ player_name = player:get_player_name(),
+ selected_linevar = selected_linevar,
+ }
+ ch_core.show_formspec(player, "advtrains_line_automation:posledni_jizdy", formspec, lp_formspec_callback, custom_state, {})
+end
+
+def = {
+ -- params = "",
+ description = S("Open line editor"),
+ privs = {railway_operator = true},
+ func = function(player_name, param) show_editor_formspec(minetest.get_player_by_name(player_name)) end,
+}
+core.register_chatcommand("line_editor", def)
diff --git a/advtrains_line_automation/line_functions.lua b/advtrains_line_automation/line_functions.lua
new file mode 100644
index 0000000..8f69a00
--- /dev/null
+++ b/advtrains_line_automation/line_functions.lua
@@ -0,0 +1,1350 @@
+local al = advtrains.lines
+local rwt = assert(advtrains.lines.rwt)
+
+-- Get current translator
+local S = advtrains.lines.translate
+
+local MODE_NORMAL = 0 -- normální zastávka (výchozí nebo mezilehlá)
+local MODE_REQUEST_STOP = 1 -- zastávka na znamení (mezilehlá)
+local MODE_HIDDEN = 2 -- skrytá zastávka (výchozí nebo mezilehlá)
+local MODE_DISABLED = 3 -- vypnutá zastávka (mezilehlá nebo koncová)
+local MODE_FINAL = 4 -- koncová zastávka (linka zde jízdu končí)
+local MODE_FINAL_HIDDEN = 5 -- koncová zastávka skrytá
+local MODE_FINAL_CONTINUE = 6 -- koncová zastávka (vlak pokračuje jako jiná linka)
+
+local simple_modes = {
+ [MODE_NORMAL] = MODE_NORMAL,
+ [MODE_REQUEST_STOP] = MODE_NORMAL,
+ [MODE_HIDDEN] = MODE_NORMAL,
+ [MODE_DISABLED] = MODE_DISABLED,
+ [MODE_FINAL] = MODE_FINAL,
+ [MODE_FINAL_HIDDEN] = MODE_FINAL,
+ [MODE_FINAL_CONTINUE] = MODE_FINAL,
+}
+
+local current_passages = {--[[
+ [train_id] = {
+ [1] = rwtime,
+ ...,
+ [n] = rwtime (časy *odjezdu*, kromě koncových zastávek, kde jde o čas příjezdu)
+ wait = int or nil (původně naplánovaná doba čekání na výchozí zastávce)
+ }
+]]}
+
+local last_passages = {--[[
+ [linevar] = {
+ [1..10] = {[1] = rwtime, ..., wait} -- jízdy seřazeny od nejstarší (1) po nejnovější (až 10) podle odjezdu z výchozí zastávky
+ }
+]]}
+
+local debug_print_i = 0
+
+-- LOCAL funkce:
+-- =========================================================================
+local function debug_print(s)
+ debug_print_i = debug_print_i + 1
+ -- core.chat_send_all("["..debug_print_i.."] "..tostring(s))
+ return s
+end
+
+-- Je-li stn kód stanice, vrací její jméno, jinak vrací "???". stn může být i nil.
+local function get_station_name(stn)
+ local station = advtrains.lines.stations[stn or ""]
+ if station ~= nil and station.name ~= nil then
+ return station.name
+ else
+ return "???"
+ end
+end
+al.get_station_name = get_station_name
+
+--[[
+ -- Vrací index následujícího výskytu 'stn' v seznamu zastávek podle linevar_def.
+ -- Vrací i skryté zastávky, ale ne vypnuté.
+ -- Je-li linevar_def == nil nebo stn == nil nebo stn == "", vrací nil.
+ - line_status = table
+ - linevar_def = table or nil
+ - stn = string
+ return: int or nil
+]]
+local function find_next_index(line_status, linevar_def, stn)
+ assert(line_status)
+ if linevar_def ~= nil and stn ~= nil and stn ~= "" then
+ local stops = linevar_def.stops
+ if line_status.linevar_index < #stops then
+ for i = line_status.linevar_index + 1, #stops do
+ local stop = stops[i]
+ if stop.stn == stn and (stop.mode or MODE_NORMAL) ~= MODE_DISABLED then
+ return i
+ end
+ end
+ end
+ end
+end
+
+-- Vrací kódy výchozí a cílové stanice k zobrazení cestujícím: stn_first (string), stn_terminus (string)
+-- Předané linevar_def musí obsahovat platný seznam 'stops', ale nemusí obsahovat nic jiného (nemusí to být platná definice).
+-- V případě chyby vrací nil, nil.
+local function get_first_last_stations(linevar_def)
+ local a, b = linevar_def.index_vychozi, linevar_def.index_cil
+ if a ~= nil and b ~= nil then
+ local stops = linevar_def.stops
+ return stops[a].stn, stops[b].stn
+ else
+ return nil, nil
+ end
+end
+
+--[[
+ Používá se na *nelinkový* vlak stojící na *neanonymní* zastávce.
+ Zahájí jízdu na lince nalezené podle kombinace line/stn/rc, nebo vrátí false.
+ chg orwell: added linevar parameter, linevar no longer derived from the line/rc/stn
+]]
+local function line_start(train, stn, departure_rwtime, linevar)
+ if not linevar then
+ return false
+ end
+ assert(train)
+ assert(stn and stn ~= "")
+ assert(departure_rwtime)
+ local ls = al.get_line_status(train)
+ if ls.linevar ~= nil then
+ -- chg orwell: no longer error here, instead cancel previous linevar
+ al.cancel_linevar(train)
+ end
+ local linevar_def = al.try_get_linevar_def(linevar, stn)
+ if linevar == nil or linevar_def == nil or linevar_def.disabled then
+ return false
+ end
+ ls.linevar = linevar
+ ls.linevar_station = stn
+ ls.linevar_index = 1
+ ls.linevar_dep = departure_rwtime
+ ls.linevar_last_dep = departure_rwtime
+ ls.linevar_last_stn = stn
+ ls.linevar_past = nil
+ train.text_outside = al.get_line_display(linevar_def)
+ return true
+end
+
+--[[
+ Vrací:
+ - "true", pokud má vlak zastavit
+ - nil, pokud zastavit nemá
+ - "on_request", pokud má zastavit na znamení, ale znamení zatím nebylo dáno
+]]
+local function should_stop(pos, stdata, train)
+ if stdata == nil or stdata.stn == nil then
+ return nil -- neplatná data
+ end
+ local stn = assert(stdata.stn) -- zastávka stále může být anonymní
+ local ls, linevar_def = al.get_line_status(train)
+ local next_index
+ if stn ~= "" then
+ next_index = find_next_index(ls, linevar_def, stn)
+ end
+ -- jde o linkový vlak?
+ if linevar_def ~= nil then
+ if next_index == nil then
+ return nil
+ end
+ local stop = assert(linevar_def.stops[next_index])
+ if stop.pos ~= nil and stop.pos ~= string.format("%d,%d,%d", pos.x, pos.y, pos.z) then
+ return nil
+ end
+ if stop.mode ~= nil and stop.mode == MODE_REQUEST_STOP then
+ if ls.stop_request ~= nil then
+ debug_print("Vlak "..train.id.." zastaví na zastávce na znamení.")
+ return "true"
+ else
+ debug_print("Vlak "..train.id.." možná zastaví na zastávce na znamení.")
+ return "on_request"
+ end
+ end
+ return "true"
+ -- TODO: zastávky na znamení
+ else
+ -- train not on a timetable
+ local ars = stdata.ars
+ -- vyhovuje vlak ARS pravidlům?
+ local mspec,mdef = advtrains.interlocking.ars_check_rule_match(ars, train)
+ local result = (mspec or mdef) and true
+ if result then
+ return "true"
+ else
+ return nil
+ end
+ end
+end
+
+local function update_value(train, key, setting)
+ if setting == "-" then
+ train[key] = nil
+ elseif setting ~= "" then
+ train[key] = setting
+ end
+ return train[key]
+end
+
+--[[
+ Pokud vlak jede na lince, odebere ho z této linky a vrátí true; jinak vrátí false.
+]]
+function al.cancel_linevar(train)
+ local ls = train.line_status
+ if ls == nil or ls.linevar == nil then return false end
+ ls.linevar = nil
+ ls.linevar_station = nil
+ ls.linevar_index = nil
+ ls.linevar_dep = nil
+ ls.linevar_last_dep = nil
+ ls.linevar_last_stn = nil
+ train.text_outside = ""
+ return true
+end
+
+-- Vrací seznam názvů neskrytých zastávek, počínaje od uvedeného indexu.
+-- Pokud by vrátila prázdný seznam, vrátí místo něj {"???"}.
+function al.get_stop_names(linevar_def, start_index)
+ local stations = advtrains.lines.stations
+ local result = {}
+ if linevar_def ~= nil then
+ local stops = linevar_def.stops
+ if start_index == nil then
+ start_index = 1
+ end
+ for i = start_index, #stops do
+ local stop = stops[i]
+ if stop.mode == nil or (stop.mode ~= MODE_HIDDEN and stop.mode ~= MODE_FINAL_HIDDEN and stop.mode ~= MODE_DISABLED) then
+ local station = stations[stop.stn]
+ if station ~= nil and station.name ~= nil and station.name ~= "" then
+ table.insert(result, station.name)
+ else
+ table.insert(result, "???")
+ end
+ end
+ end
+ end
+ if result[1] == nil then
+ result[1] = "???"
+ end
+ return result
+end
+
+--[[
+ Vrací:
+ a) index, stop_data -- pokud byla vyhovující předchozí zastávka nalezena
+ b) nil, nil -- pokud nalezena nebyla
+]]
+function al.get_first_stop(linevar_def, allow_hidden_stops)
+ if allow_hidden_stops then
+ return 1, linevar_def.stops[1]
+ else
+ local result = linevar_def.index_vychozi
+ if result ~= nil then
+ return result, linevar_def.stops[result]
+ else
+ return nil, nil
+ end
+ end
+end
+
+--[[
+ Vrací:
+ a) index, stop_data -- pokud byla vyhovující předchozí zastávka nalezena
+ b) nil, nil -- pokud nalezena nebyla
+]]
+function al.get_last_stop(linevar_def, allow_hidden_stops)
+ if allow_hidden_stops then
+ local stops = linevar_def.stops[result]
+ for i = linevar_def.index_cil, #stops do
+ local stop = stops[i]
+ local mode = stop.mode
+ if mode == MODE_FINAL or mode == MODE_FINAL_CONTINUE or mode == MODE_FINAL_HIDDEN then
+ return i, stop
+ end
+ end
+ else
+ local result = linevar_def.index_cil
+ if result ~= nil then
+ return result, linevar_def.stops[result]
+ end
+ end
+ return nil, nil
+end
+
+--[[
+ Vrací:
+ a) index, stop_data -- pokud byla vyhovující předchozí zastávka nalezena
+ b) nil, nil -- pokud nalezena nebyla
+]]
+function al.get_prev_stop(linevar_def, current_index, allow_hidden_stops)
+ local stops = assert(linevar_def.stops)
+ assert(current_index)
+ if current_index > 1 then
+ for i = current_index - 1, 1, -1 do
+ local mode = stops[i].mode
+ if mode == nil or (mode ~= MODE_DISABLED and ((mode ~= MODE_HIDDEN and mode ~= MODE_FINAL_HIDDEN) or allow_hidden_stops)) then
+ return i, stops[i]
+ end
+ end
+ end
+ return nil, nil
+end
+
+--[[
+ Vrací:
+ a) index, stop_data -- pokud byla vyhovující další zastávka nalezena
+ b) nil, nil -- pokud nalezena nebyla
+]]
+function al.get_next_stop(linevar_def, current_index, allow_hidden_stops)
+ local stops = assert(linevar_def.stops)
+ assert(current_index)
+ if current_index < #stops then
+ for i = current_index + 1, #stops do
+ local mode = stops[i].mode
+ if mode == nil or (mode ~= MODE_DISABLED and ((mode ~= MODE_HIDDEN and mode ~= MODE_FINAL_HIDDEN) or allow_hidden_stops)) then
+ return i, stops[i]
+ end
+ end
+ end
+ return nil, nil
+end
+
+--[[
+ Vrací:
+ a) index, stop_data -- pokud byla vyhovující koncová zastávka nalezena
+ b) nil, nil -- pokud nalezena nebyla
+]]
+function al.get_terminus(linevar_def, current_index, allow_hidden_stops)
+ if linevar_def.index_cil ~= nil then
+ return linevar_def.index_cil, linevar_def.stops[linevar_def.index_cil]
+ end
+ local stops = assert(linevar_def.stops)
+ local r_i, r_stop
+ if current_index < #stops then
+ for i = current_index + 1, #stops do
+ local mode = stops[i].mode or MODE_NORMAL
+ if mode ~= MODE_DISABLED and ((mode ~= MODE_HIDDEN and mode ~= MODE_FINAL_HIDDEN) or allow_hidden_stops) then
+ r_i, r_stop = i, stops[i]
+ end
+ if mode == MODE_FINAL or mode == MODE_FINAL_CONTINUE or mode == MODE_FINAL_HIDDEN then
+ break
+ end
+ end
+ end
+ return r_i, r_stop
+end
+
+function al.get_line_display(linevar_def)
+ if linevar_def.train_name then
+ return linevar_def.train_name
+ end
+
+ return core.get_translated_string("", al.get_line_description(linevar_def, {
+ line_number = true,
+ last_stop = true,
+ }))
+end
+
+--[[
+ options = {
+ 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
+ }
+]]
+function al.get_line_description(linevar_def, options)
+ local line, stn = al.linevar_decompose(linevar_def.name)
+ local first_stn, last_stn = get_first_last_stations(linevar_def)
+ if line == nil or first_stn == nil or last_stn == nil then
+ return "???"
+ end
+ if options == nil then options = {} end
+ local s1, s2 = "", ""
+ if options.line_number then
+ s1 = "["..line.."] "
+ end
+ if options.last_stop == nil or options.last_stop then
+ local last_stn_description = get_station_name(last_stn)
+ if options.first_stop then
+ 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
+ s2 = last_stn_description
+ end
+ elseif options.first_stop then
+ s2 = get_station_name(first_stn)
+ end
+ return s1..s2
+end
+
+function al.get_stop_description(stop_data, next_stop_data)
+ local s1, s2 = "", ""
+ if stop_data ~= nil then
+ local mode = stop_data.mode
+ if mode ~= MODE_DISABLED and mode ~= MODE_HIDDEN and mode ~= MODE_FINAL_HIDDEN then
+ s1 = get_station_name(stop_data.stn)
+ --[[
+ if
+ mode == MODE_FINAL or mode == MODE_FINAL_CONTINUE or
+ (next_stop_data ~= nil and next_stop_data.mode == MODE_FINAL_HIDDEN)
+ then
+ s2 = "Koncová zastávka"
+ end
+ ]]
+ end
+ end
+ if next_stop_data ~= nil then
+ local mode = next_stop_data.mode
+ if mode ~= MODE_DISABLED and mode ~= MODE_HIDDEN and mode ~= MODE_FINAL_HIDDEN then
+ s2 = S("Next Stop: ")..get_station_name(next_stop_data.stn)
+ if mode == MODE_REQUEST_STOP then
+ s2 = s2..S(" (on request)")
+ end
+ end
+ else
+ s2 = S("Terminus")
+ end
+ if s1 ~= "" and s2 ~= "" then
+ return s1.."\n"..s2
+ else
+ return s1..s2
+ end
+end
+
+--[[
+ Není-li zpoždění k dispozici, vrací {text = ""}, jinak vrací:
+ {
+ has_delay = bool,
+ delay = int,
+ text = string,
+ }
+]]
+function al.get_delay_description(line_status, linevar_def, rwtime)
+ assert(line_status)
+ if linevar_def == nil then
+ return {text = ""}
+ end
+ local stops = linevar_def.stops
+ local expected_departure = rwt.add(line_status.linevar_dep, assert(stops[line_status.linevar_index]).dep)
+ local real_departure = line_status.linevar_last_dep
+ local delay = rwt.diff(expected_departure, real_departure)
+
+ if rwtime ~= nil then
+ local expected_departure_next
+ for i = line_status.linevar_index + 1, #stops do
+ if stops[i] == nil then
+ break
+ else
+ local mode = stops[i].mode
+ if mode == nil or mode ~= MODE_DISABLED then
+ expected_departure_next = rwt.add(line_status.linevar_dep, stops[i].dep)
+ break
+ end
+ end
+ end
+ if expected_departure_next ~= nil then
+ local delay2 = rwt.diff(expected_departure_next, rwtime)
+ if delay2 > delay then
+ delay = delay2
+ end
+ end
+ end
+
+ if delay < -1 or delay > 10 then
+ return {
+ has_delay = true,
+ delay = delay,
+ text = "late "..delay.." seconds",
+ }
+ else
+ return {
+ has_delay = false,
+ delay = delay,
+ text = "on time",
+ }
+ end
+end
+
+-- Test na módy MODE_FINAL*
+function al.is_final_mode(stop_mode)
+ return stop_mode ~= nil and simple_modes[stop_mode] == MODE_FINAL
+end
+local is_final_mode = al.is_final_mode
+
+-- Test na skrytou zastávku. Vrací true, pokud zadaný mód neodpovídá skryté zastávce.
+function al.is_visible_mode(stop_mode)
+ return stop_mode == nil or (stop_mode ~= MODE_HIDDEN and stop_mode ~= MODE_FINAL_HIDDEN)
+end
+local is_visible_mode = al.is_visible_mode
+
+-- Pokud zadaná varianta linky existuje, vrátí:
+-- linevar_def, linevar_station
+-- Jinak vrací:
+-- nil, nil
+-- Je-li linevar_station == nil, doplní se z linevar. Je-li linevar == nil, vrátí nil, nil.
+function al.try_get_linevar_def(linevar, linevar_station)
+ if linevar == nil then
+ return nil, nil
+ end
+ if linevar_station == nil then
+ local line
+ line, linevar_station = al.linevar_decompose(linevar)
+ if line == nil then
+ return nil, nil
+ end
+ end
+ local t = advtrains.lines.stations[linevar_station]
+ if t ~= nil then
+ t = t.linevars
+ if t ~= nil then
+ return t[linevar], linevar_station
+ end
+ end
+ return nil, nil
+end
+
+--[[
+ Vrací 2 hodnoty:
+ - line_status = table -- tabulka train.line_status (může být prázdná)
+ - linevar_def = table or nil -- jde-li o linkový vlak, vrací definici linevar, jinak nil
+ Parametry:
+ - train = table (train)
+]]
+function al.get_line_status(train)
+ assert(train)
+ if train.line_status == nil then
+ train.line_status = {}
+ return train.line_status, nil
+ end
+ local ls = train.line_status
+ if ls.linevar == nil then
+ -- nelinkový vlak
+ local linevar_past = ls.linevar_past
+ if linevar_past ~= nil then
+ if train.line ~= linevar_past.line or rwt.diff(linevar_past.arrival, rwt.now()) >= 86400 then
+ -- smazat linevar_past, pokud se změnilo označení linky nebo uplynulo 24 hodin
+ ls.linevar_past = nil
+ end
+ end
+ return ls, nil
+ end
+ if rwt.diff(ls.linevar_dep, rwt.now()) >= 86400 then
+ core.log("warning", "Train "..train.id.." put out of linevar '"..ls.linevar.."', because it was riding more then 24 hours.")
+ al.cancel_linevar(train)
+ return ls, nil
+ end
+ local linevar_def = al.try_get_linevar_def(ls.linevar, ls.linevar_station)
+ if linevar_def == nil then
+ core.log("warning", "Train "..train.id.." was riding a non-existent (undefined) line '"..tostring(ls.linevar).."'!")
+ al.cancel_linevar(train)
+ elseif linevar_def.stops[ls.linevar_index] == nil then
+ core.log("warning", "Train "..train.id.." put out of linevar '"..ls.linevar.."', because its index "..ls.linevar_index.." became invalid.")
+ al.cancel_linevar(train)
+ linevar_def = nil
+ end
+ return ls, linevar_def
+end
+
+local function check_selector_ars(train, stdata)
+ local ars = stdata.selector_ars
+ if not ars then
+ return true
+ end
+ -- vyhovuje vlak ARS pravidlům?
+ local mspec,mdef = advtrains.interlocking.ars_check_rule_match(ars, train)
+ return (mspec or mdef) and true
+end
+
+function al.on_train_approach(pos, train_id, train, index)
+ if train.path_cn[index] ~= 1 then return end -- špatný směr
+ local pe = advtrains.encode_pos(pos)
+ local stdata = advtrains.lines.stops[pe]
+ if stdata == nil then
+ return -- neplatná zastávka
+ end
+ if not check_selector_ars(train, stdata) then
+ return -- does not consider stop pos here
+ end
+ if should_stop(pos, stdata, train) ~= nil then
+ advtrains.lzb_add_checkpoint(train, index, 2, nil)
+ if train.line_status.linevar == nil then
+ -- nelinkový vlak:
+ local stn = advtrains.lines.stations[stdata.stn]
+ local stnname = stn and stn.name or S("Unknown Station")
+ train.text_inside = S("Next Stop:") .. "\n"..stnname
+ end
+ if not stdata.arskeepen then
+ advtrains.interlocking.ars_set_disable(train, true)
+ end
+ end
+end
+
+local function record_skipped_stops(train_id, linevar_def, linevar_index, next_index)
+ assert(linevar_def)
+ if next_index > linevar_index + 1 then
+ local skipped_stops = {}
+ for i = linevar_index + 1, next_index - 1 do
+ local mode = linevar_def.stops[i].mode or MODE_NORMAL
+ if mode ~= MODE_DISABLED then
+ table.insert(skipped_stops, linevar_def.stops[i].stn)
+ end
+ end
+ if #skipped_stops > 0 then
+ core.log("warning", "Train "..train_id.." of line '"..linevar_def.name.."' skipped "..#skipped_stops.." stops: "..
+ table.concat(skipped_stops, ", "))
+ end
+ return #skipped_stops
+ else
+ return 0
+ end
+end
+
+function al.on_train_enter(pos, train_id, train, index)
+ if train.path_cn[index] ~= 1 then return end -- špatný směr
+ local pe = advtrains.encode_pos(pos)
+ local stdata = advtrains.lines.stops[pe]
+ if stdata == nil then
+ return -- neplatná zastávka
+ end
+ if not check_selector_ars(train, stdata) then
+ return -- does not consider stop pos here
+ end
+
+ local stn = stdata.stn or ""
+ local rwtime = assert(rwt.now())
+ local ls, linevar_def = al.get_line_status(train)
+ local next_index
+ if stn ~= "" then
+ if linevar_def ~= nil then
+ next_index = find_next_index(ls, linevar_def, stn)
+ end
+ ls.last_enter = {stn = stn, encpos = pe, rwtime = rwtime}
+ debug_print("Vlak "..train_id.." zaznamenán: "..stn.." "..core.pos_to_string(pos).." @ "..rwt.t_str(rwtime))
+ end
+ local should_stop_result = should_stop(pos, stdata, train)
+ if should_stop_result == nil then
+ debug_print("Vlak "..train_id.." projel zastávkou "..stn)
+ return
+ elseif should_stop_result == "on_request" then
+ -- projetí zastávky na znamení
+ debug_print("Vlak "..train_id.." projel zastávkou na znamení "..stn)
+ if linevar_def ~= nil and next_index ~= nil then
+ local stop_def = assert(linevar_def.stops[next_index])
+ if stop_def.mode == nil or stop_def.mode ~= MODE_REQUEST_STOP then
+ error("Internal error: mode "..MODE_REQUEST_STOP.." expected, but the real mode is "..tostring(stop_def.mode).."!")
+ end
+ assert(stn ~= "")
+ record_skipped_stops(train_id, linevar_def, ls.linevar_index, next_index)
+ ls.linevar_index = next_index
+ ls.linevar_last_dep = rwtime -- u zastávky na znamení se průjezd počítá jako odjezd
+ ls.linevar_last_stn = stn
+ local next_stop_index, next_stop_data = al.get_next_stop(linevar_def, next_index)
+ train.text_inside = al.get_stop_description(nil, linevar_def.stops[next_stop_index or 0])
+ -- ATC command:
+ local atc_command = "A1 S" ..(stdata.speed or "M")
+ advtrains.atc.train_set_command(train, atc_command, true)
+ end
+ return
+ end
+
+ -- naplánovat čas odjezdu
+ local wait = tonumber(stdata.wait) or 0
+ local interval = nil
+ if stdata.dep_mode=="interval" or stdata.dep_mode=="ttbegin" then -- TODO: in ttbegin case, the interval should come from tt not from rail
+ interval = stdata.interval
+ end
+ local last_dep = stdata.last_dep -- posl. odjezd z této zastávkové koleje
+
+ if interval ~= nil and last_dep ~= nil then
+ if rwt.is_after(last_dep, rwtime) then
+ last_dep = rwtime
+ end
+ local ioffset = stdata.ioffset or 0
+ local normal_dep = rwt.add(rwtime, wait)
+ local next_dep = rwt.next_rpt(last_dep, interval, ioffset)
+ if rwt.is_before(normal_dep, next_dep) then
+ -- core.log("action", "[INFO] The train "..train_id.." will wait for "..(next_dep - normal_dep).." additional seconds due to interval at "..core.pos_to_string(pos)..".")
+ wait = wait + rwt.diff(normal_dep, next_dep)
+ -- else -- will wait normal time
+ end
+ end
+ local planned_departure = rwt.add(rwtime, wait)
+ debug_print("Vlak "..train_id.." zastavil na "..stn.." a odjede za "..wait.." sekund ("..rwt.t_str(planned_departure)..").")
+ stdata.last_dep = planned_departure -- naplánovaný čas odjezdu
+ stdata.last_wait = wait -- naplánovaná doba čekání
+ ls.standing_at = pe
+ if linevar_def == nil or next_index == nil or (linevar_def.stops[next_index].mode or MODE_NORMAL) ~= MODE_HIDDEN then
+ -- zrušit stop_request, pokud jsme nezastavili na skryté zastávce:
+ ls.stop_request = nil
+ end
+
+ local can_start_line
+ local had_linevar = linevar_def ~= nil
+ if linevar_def == nil then
+ -- nelinkový vlak
+ can_start_line = true
+ elseif next_index ~= nil then
+ -- linkový vlak zastavil na své řádné zastávce
+ assert(stn ~= "") -- dopravna musí mít kód
+ local stop_def = assert(linevar_def.stops[next_index])
+ debug_print("Vlak "..train_id.." je linkový vlak ("..ls.linevar..") a zastavil na své pravidelné zastávce "..stn.." (index = "..next_index..")")
+ record_skipped_stops(train_id, linevar_def, ls.linevar_index, next_index)
+ local stop_smode = simple_modes[stop_def.mode or 0]
+ if stop_smode == MODE_NORMAL then
+ -- mezilehlá zastávka
+ can_start_line = false
+ ls.linevar_index = next_index
+ ls.linevar_last_dep = planned_departure
+ ls.linevar_last_stn = stn
+ debug_print("Jde o mezilehlou zastávku.")
+ local next_stop_index, next_stop_data = al.get_next_stop(linevar_def, next_index)
+ train.text_inside = al.get_stop_description(linevar_def.stops[next_index], linevar_def.stops[next_stop_index or 0])
+ else
+ -- koncová zastávka
+ can_start_line = stop_def.mode == MODE_FINAL_CONTINUE
+ core.log("action", "Train "..train_id.." arrived at the final station "..stop_def.stn.." of linevar "..ls.linevar.." after "..rwt.diff(ls.linevar_dep, rwtime).." seconds.")
+ debug_print("Vlak "..train_id.." skončil jízdu na lince "..ls.linevar..", může pokračovat na jinou linku: "..(can_start_line and "ihned" or "na příští zastávce"))
+ train.text_inside = al.get_stop_description(linevar_def.stops[next_index])
+ local current_passage = current_passages[train_id]
+ if current_passage ~= nil then
+ current_passage[next_index] = rwtime
+ current_passages[train_id] = nil
+ end
+ al.cancel_linevar(train)
+ -- vyplnit linevar_past:
+ if train.line ~= nil and train.line ~= "" then
+ local past_linevar = assert(linevar_def.name)
+ local past_line = al.linevar_decompose(past_linevar)
+ ls.linevar_past = {
+ line = assert(past_line),
+ linevar = past_linevar,
+ station = stn,
+ arrival = rwtime,
+ }
+ end
+ end
+ else
+ -- linkový vlak zastavil na neznámé zastávce (nemělo by nastat)
+ core.log("warning", "Train "..train_id.." of linevar '"..ls.linevar.."' stopped at unknown station '"..stn.."' at "..core.pos_to_string(pos).."!")
+ debug_print("Vlak "..train_id.." je linkový vlak ("..ls.linevar.."), ale zastavil na sobě neznámé zastávce "..stn..", což by se nemělo stát.")
+ can_start_line = false
+ end
+
+ -- ATC příkaz
+ local trn_door_delay = math.ceil(train.door_operation_time or 1) -- must round to whole number
+ local atc_command = "B0 W O"..stdata.doors -- stop and open doors
+ ..(stdata.kick and "K" or "") -- potentially kick passengers out
+ ..(stdata.reverse and "R" or "") -- reverse if requested
+ .." D"..wait.." " -- wait for the requested time (TODO: replace this by a RWT scheduler at some point!)
+ .." A1 "..(stdata.waitsig and "G " or " ") -- enable ARS again and potentially wait for signal
+ ..(stdata.keepopen and "" or "OC") -- close doors, unless keepopen was set
+ .." D"..trn_door_delay -- wait for the door delay
+ .." S"..(stdata.speed or "M") -- depart with specified speed
+
+ advtrains.atc.train_set_command(train, atc_command, true)
+
+ -- začít novou linku?
+ if can_start_line and stdata.dep_mode == "ttbegin" then
+ -- if train may start a new line and departure mode is set to ttbegin, set the new linevar
+ if line_start(train, stn, planned_departure, stdata.tt_begin_linevar) then
+ debug_print("Vlak "..train_id.." zahájil jízdu na nové lince ("..ls.linevar..") ze stanice "..stn..".")
+ core.log("action", "Train "..train_id.." started a route with linevar '"..ls.linevar.."' at station '"..stn.."'.")
+ train.text_inside = get_station_name(stn)
+ assert(ls.linevar)
+ linevar_def = assert(al.try_get_linevar_def(ls.linevar))
+ local next_stop_index, next_stop_data = al.get_next_stop(linevar_def, 1)
+ if next_stop_index ~= nil then
+ train.text_inside = train.text_inside.."\n"..S("Next stop: ")..get_station_name(next_stop_data.stn)
+ if next_stop_data.mode ~= nil and next_stop_data.mode == MODE_REQUEST_STOP then
+ train.text_inside = train.text_inside..S(" (on request)")
+ end
+ end
+ end
+ elseif not had_linevar and ls.linevar == nil then
+ -- vlak, který nebyl a stále není linkový:
+ train.text_inside = get_station_name(stn)
+ -- core.after(wait, function() train.text_inside = "" end)
+ end
+end
+
+function al.on_train_leave(pos, train_id, train, index)
+ local pe = advtrains.encode_pos(pos)
+ local stdata = advtrains.lines.stops[pe]
+ if stdata == nil then
+ return -- neplatná zastávka
+ end
+ local stn = stdata.stn or ""
+ local ls, linevar_def = al.get_line_status(train)
+ local rwtime = rwt.now()
+
+ if stn ~= "" then
+ ls.last_leave = {stn = stn, encpos = pe, rwtime = rwtime}
+ debug_print("Vlak "..train_id.." zaznamenán na odjezdu: "..stn.." "..core.pos_to_string(pos).." @ "..rwt.t_str(rwtime))
+ end
+
+ if ls.standing_at == pe then
+ -- vlak stál v této dopravně
+ ls.standing_at = nil
+ if
+ linevar_def == nil or ls.linevar_index == nil or
+ linevar_def.stops[ls.linevar_index] == nil or
+ (linevar_def.stops[ls.linevar_index].mode or MODE_NORMAL) ~= MODE_HIDDEN
+ then
+ ls.stop_request = nil -- zrušit stop_request při odjezdu ze zastávky, pokud není nekoncová skrytá
+ end
+ if stn ~= "" then
+ debug_print("Vlak "..train_id.." odjel ze zastávky "..stn)
+ if ls.linevar_last_dep ~= nil and rwt.is_after(ls.linevar_last_dep, rwtime) then
+ debug_print("Vlak "..train_id.." předčasně odjel z dopravny "..stn.." (zbývalo "..rwt.diff(rwtime, ls.linevar_last_dep).." sekund)")
+ ls.linevar_last_dep = rwtime -- předčasný odjezd
+ if ls.linevar_index == 1 then
+ ls.linevar_dep = rwtime
+ end
+ end
+ else
+ debug_print("Vlak "..train_id.." odjel z anonymní zastávky "..core.pos_to_string(pos)..".")
+ end
+ train.text_inside = ""
+ if linevar_def ~= nil then
+ -- linkový vlak:
+ debug_print("Linkový vlak "..train_id.." odjel ze zastávky s indexem "..ls.linevar_index)
+ if ls.linevar_index == 1 then
+ -- odjezd z výchozí zastávky:
+ local new_passage = {rwtime}
+ if stdata.last_wait ~= nil then
+ new_passage.wait = stdata.last_wait
+ end
+ current_passages[train_id] = new_passage
+ local passages_by_linevar = last_passages[ls.linevar]
+ if passages_by_linevar == nil then
+ passages_by_linevar = {new_passage}
+ last_passages[ls.linevar] = passages_by_linevar
+ else
+ while #passages_by_linevar >= 10 do
+ table.remove(passages_by_linevar, 1)
+ end
+ table.insert(passages_by_linevar, new_passage)
+ end
+ else
+ -- odjezd z nácestné zastávky
+ local current_passage = current_passages[train_id]
+ if current_passage ~= nil then
+ current_passage[ls.linevar_index] = rwtime
+ end
+ end
+ local next_stop_index, next_stop_data = al.get_next_stop(linevar_def, ls.linevar_index)
+ if next_stop_index ~= nil then
+ train.text_inside = al.get_stop_description(nil, next_stop_data)
+ end
+ end
+ -- else
+ --[[ průjezd?
+ local stn = (stdata and stdata.stn) or ""
+ if stn ~= "" then
+ debug_print("Vlak "..train_id.." projel (odjezd) zastávkou "..stn..".")
+ else
+ debug_print("Vlak "..train_id.." projel (odjezd) anonymní zastávkou "..core.pos_to_string(pos)..".")
+ end
+ ]]
+ end
+end
+
+function al.linevar_decompose(linevar)
+ if linevar == nil then
+ return nil, nil, nil
+ end
+ local parts = string.split(linevar, "/", true, 3)
+ return parts[1], parts[2] or "", parts[3] or ""
+end
+
+--[[
+ Vrací:
+ a) pokud linevar existuje a má průjezdy:
+ passages, stops:
+ {{[1] = rwtime, ..., wait = int or nil}...}, {"kód", "název"}...}
+ b) jinak:
+ nil, nil
+]]
+function al.get_last_passages(linevar_def)
+ local lp = last_passages[linevar_def.name]
+ if linevar_def ~= nil and lp ~= nil and lp[1] ~= nil then
+ local passages, stops = {}, {}
+ for i, stop in ipairs(linevar_def.stops) do
+ stops[i] = {stop.stn, get_station_name(stop.stn)}
+ end
+ for i = 1, #lp do
+ passages[i] = table.copy(lp[i])
+ end
+ return passages, stops
+ end
+end
+
+local function get_last_pos(line_status)
+ assert(line_status)
+ local last_enter, last_leave, standing_at = line_status.last_enter, line_status.last_leave, line_status.standing_at
+ local last_pos, last_pos_type
+ if last_enter ~= nil then
+ last_pos, last_pos_type = last_enter, "enter"
+ if standing_at ~= nil and standing_at == last_enter.encpos then
+ last_pos_type = "standing"
+ elseif last_leave ~= nil and rwt.is_after(last_leave.rwtime, last_enter.rwtime) then
+ last_pos, last_pos_type = last_leave, "leave"
+ end
+ elseif last_leave ~= nil then
+ last_pos, last_pos_type = last_leave, "leave"
+ else
+ result.type = "none"
+ return {type = "none"}
+ end
+ local result = {type = last_pos_type, last_pos = last_pos}
+ if last_enter ~= nil then
+ result.last_enter = last_enter
+ end
+ if last_leave ~= nil then
+ result.last_leave = last_leave
+ end
+ return result
+end
+
+function al.get_last_pos_station_name(line_status)
+ local result = get_last_pos(line_status)
+ if result.type ~= "none" then
+ return get_station_name(result.last_pos.stn)
+ else
+ return nil
+ end
+end
+
+local function get_train_position(line_status, linevar_def, rwtime)
+ if line_status ~= nil then
+ local last_pos_info = get_last_pos(line_status)
+ local last_pos = last_pos_info.last_pos
+ if last_pos ~= nil then
+ 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.." ("..rwt.diff(last_pos.rwtime, rwtime).." seconds ago)"
+ end
+ if delay_info.has_delay ~= nil then
+ result = result.." ("..delay_info.text..")"
+ end
+ return result
+ end
+ end
+ return "???"
+end
+
+--[[
+local function prepare_prediction_for_dump(result)
+ local x = {}
+ for i, record in ipairs(result) do
+ local y = table.copy(record)
+ y.stdata = record.stdata.name
+ if y.arr_linevar_def ~= nil then
+ y.arr_linevar_def = y.arr_linevar_def.name
+ end
+ if y.dep_linevar_def ~= nil then
+ y.dep_linevar_def = y.dep_linevar_def.name
+ end
+ x[i] = y
+ end
+ return x
+end
+]]
+
+local function predict_train_continue(line, stn, rc, departure, result)
+ if line == nil or line == "" then
+ return
+ end
+ local linevar_def = al.try_get_linevar_def(line.."/"..stn.."/"..rc, stn)
+ if linevar_def == nil then
+ return
+ end
+ if #result == 0 then
+ return
+ end
+ local stops = assert(linevar_def.stops)
+ local last_record = result[#result]
+ last_record.dep = departure
+ last_record.dep_linevar_def = linevar_def
+ last_record.dep_index = 1
+ local index = 2
+ while stops[index] ~= nil do
+ local stop = stops[index]
+ local stdata = advtrains.lines.stations[stop.stn]
+ if stop.mode == MODE_FINAL or stop.mode == MODE_FINAL_CONTINUE or stop.mode == MODE_FINAL_HIDDEN then
+ -- koncová zastávka
+ local arr = rwt.add(departure, stop.dep)
+ local record = {
+ stn = assert(stop.stn),
+ track = stop.track or "",
+ stdata = stdata,
+ arr = arr,
+ arr_linevar_def = linevar_def,
+ arr_index = index,
+ delay = 0,
+ hidden = stop.mode == MODE_FINAL_HIDDEN,
+ }
+ table.insert(result, record)
+ return
+ elseif stop.mode ~= MODE_DISABLED then
+ -- mezilehlá zastávka
+ local dep = rwt.add(departure, stop.dep)
+ table.insert(result, {
+ stn = assert(stop.stn),
+ track = stop.track or "",
+ stdata = stdata,
+ arr = rwt.add(dep, -(stop.wait or 10)),
+ arr_linevar_def = linevar_def,
+ arr_index = index,
+ dep = dep,
+ dep_linevar_def = linevar_def,
+ dep_index = index,
+ delay = 0,
+ hidden = stop.mode == MODE_HIDDEN,
+ })
+ end
+ index = index + 1
+ end
+end
+
+--[[
+ Zadaný vlak musí být linkový.
+ Parametry:
+ line_status = table,
+ linevar_def = table,
+ rwtime = int,
+ allow_continue = bool,
+ Vrací *pole* následujících záznamů:
+ {
+ stn = string,
+ track = string,
+ delay = int,
+ stdata = table or nil,
+ dep = int or nil, dep_linevar_def = table or nil, dep_index = int or nil,
+ arr = int or nil, arr_linevar_def = table or nil, arr_index = int or nil,
+ }
+]]
+function al.predict_train(line_status, linevar_def, rwtime, allow_continue)
+ assert(line_status)
+ assert(linevar_def)
+ local stops = linevar_def.stops
+ local result = {}
+ local index = assert(line_status.linevar_index)
+ if rwtime == nil then
+ rwtime = rwt.now()
+ end
+ local delay_desc = al.get_delay_description(line_status, linevar_def, rwtime)
+ local delay
+ if delay_desc.has_delay then
+ delay = delay_desc.delay
+ else
+ delay = 0
+ end
+ local departure = line_status.linevar_dep
+ if line_status.standing_at ~= nil then
+ -- vlak stojí na zastávce
+ local stop = assert(stops[index])
+ local stdata = advtrains.lines.stations[stop.stn]
+ table.insert(result, {
+ stn = line_status.linevar_last_stn,
+ track = stop.track or "",
+ stdata = stdata,
+ dep = assert(line_status.linevar_last_dep),
+ dep_linevar_def = assert(linevar_def),
+ dep_index = index,
+ -- arr = nil, arr_index = nil, arr_linevar_def = nil,
+ delay = delay,
+ hidden = stop.mode == MODE_HIDDEN
+ })
+ end
+ index = index + 1
+ while stops[index] ~= nil do
+ local stop = stops[index]
+ local stdata = advtrains.lines.stations[stop.stn]
+ if stop.mode == MODE_FINAL or stop.mode == MODE_FINAL_CONTINUE or stop.mode == MODE_FINAL_HIDDEN then
+ -- koncová zastávka
+ local arr = rwt.add(rwt.add(departure, stop.dep), delay)
+ local record = {
+ stn = assert(stop.stn),
+ track = stop.track or "",
+ stdata = stdata,
+ arr = arr,
+ arr_linevar_def = linevar_def,
+ arr_index = index,
+ delay = delay,
+ hidden = stop.mode == MODE_FINAL_HIDDEN,
+ final = true,
+ }
+ table.insert(result, record)
+ if allow_continue and (linevar_def.continue_line or "") ~= "" and stop.mode == MODE_FINAL_CONTINUE then
+ predict_train_continue(linevar_def.continue_line, stop.stn, linevar_def.continue_rc, rwt.add(arr, (stop.wait or 10)), result)
+ end
+ break
+ elseif stop.mode ~= MODE_DISABLED then
+ -- mezilehlá zastávka
+ local dep = rwt.add(rwt.add(departure, stop.dep), delay)
+ table.insert(result, {
+ stn = assert(stop.stn),
+ track = stop.track or "",
+ stdata = stdata,
+ arr = rwt.sub(dep, (stop.wait or 10)),
+ arr_linevar_def = linevar_def,
+ arr_index = index,
+ dep = dep,
+ dep_linevar_def = assert(linevar_def),
+ dep_index = index,
+ delay = delay,
+ hidden = stop.mode == MODE_HIDDEN,
+ })
+ end
+ index = index + 1
+ end
+ -- print("DEBUG: "..dump2({prediction = prepare_prediction_for_dump(result)}))
+ return result
+end
+
+--[[
+ Parametry:
+ linevar_def = table, -- definice linevar, z něhož se má analýza provádět
+ linevar_index = int,
+ rwtime = int or nil, -- (aktuální žel. čas; nepovinné)
+ trains = {train_table...} or nil, -- je-li zadáno, bude zkoumat pouze vlaky v tomto seznamu
+ Vrací *pole* záznamů (stejných jako al.predict_train) vztahujících se k odjezdu
+ z požadované zastávky, seřazené od nejbližšího odjezdu po nejvzdálenější.
+]]
+function al.predict_station_departures(linevar_def, linevar_index, rwtime, trains)
+ assert(linevar_def)
+ assert(linevar_index)
+ local linevar = linevar_def.name
+ local stop = assert(linevar_def.stops[linevar_index])
+ if trains == nil then
+ trains = al.get_trains_by_linevar()[linevar] or {}
+ end
+ if rwtime == nil then
+ rwtime = rwt.now()
+ end
+ local result = {}
+ for _, train in ipairs(trains) do
+ local ls, lvdef = al.get_line_status(train)
+ if ls.linevar == linevar and ls.linevar_index <= linevar_index then
+ local prediction = al.predict_train(ls, linevar_def, rwtime, true)
+ for _, pr in ipairs(prediction) do
+ if
+ pr.dep ~= nil and pr.dep_linevar_def ~= nil and pr.dep_index ~= nil and
+ pr.dep_linevar_def.name == linevar and
+ pr.dep_index == linevar_index and
+ rwt.is_after(pr.dep, rwtime)
+ then
+ table.insert(result, pr)
+ break
+ end
+ end
+ end
+ end
+ table.sort(result, function(a, b) return rwt.is_before(a.dep, b.dep) end)
+ return result
+end
+
+--[[
+ => {{
+ linevar = string,
+ indices = {int,...},
+ linevar_def = linevar_def,
+ }...}
+]]
+function al.get_linevars_by_station(stn, track, options)
+ if options == nil then
+ options = {}
+ end
+ local include_hidden_stops = options.include_hidden_stops
+ local ignore_first_stop = options.ignore_first_stop
+ local ignore_last_stop = options.ignore_last_stop
+ local result = {}
+ assert(stn)
+ for lvstn, stdata in pairs(advtrains.lines.stations) do
+ if stdata.linevars ~= nil then
+ for linevar, linevar_def in pairs(stdata.linevars) do
+ local first_stop_index = al.get_first_stop(linevar_def, include_hidden_stops)
+ local last_stop_index = al.get_last_stop(linevar_def, include_hidden_stops)
+ if not (ignore_first_stop or ignore_last_stop) or (first_stop_index ~= nil and last_stop_index ~= nil) then
+ local ld
+ for i, stop in ipairs(linevar_def.stops) do
+ if
+ stop.stn == stn and
+ (track == nil or tostring(stop.track) == track) and
+ (include_hidden_stops or is_visible_mode(stop.mode)) and
+ ((not ignore_first_stop) or i ~= 1) and
+ ((not ignore_last_stop) or (not is_final_mode(stop.mode)))
+ then
+ if ld == nil then
+ ld = {linevar = linevar, linevar_def = linevar_def, indices = {i}}
+ table.insert(result, ld)
+ else
+ table.insert(ld.indices, i)
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ if #result > 1 then
+ table.sort(result, function(a, b) return a.linevar < b.linevar end)
+ end
+ return result
+end
+
+--[[
+ => {
+ [linevar] = {train...}, -- generuje jen neprázdné seznamy
+ }
+]]
+function al.get_trains_by_linevar()
+ local result = {}
+ for train_id, train in pairs(advtrains.trains) do
+ local ls, linevar_def = al.get_line_status(train)
+ if linevar_def ~= nil then
+ local linevar = linevar_def.name
+ local list = result[linevar]
+ if list ~= nil then
+ table.insert(list, train)
+ else
+ list = {train}
+ result[linevar] = list
+ end
+ end
+ end
+ for linevar, list in pairs(result) do
+ if list[2] ~= nil then
+ table.sort(list, function(a, b) return a.id < b.id end)
+ end
+ end
+ return result
+end
+
+local function vlaky(param, past_trains_too)
+ local result = {}
+ if param:match("/") then
+ return result -- parametr nesmí obsahovat '/'
+ end
+ local train_line_prefix
+ if param ~= "" then
+ train_line_prefix = param.."/"
+ end
+ local rwtime = rwt.now()
+ local players_per_train = {}
+ local results = {}
+ for player_name, train_id in pairs(advtrains.player_to_train_mapping) do
+ results[train_id] = (results[train_id] or 0) + 1
+ end
+ for train_id, train in pairs(advtrains.trains) do
+ local ls, linevar_def = al.get_line_status(train)
+ if linevar_def ~= nil then
+ if train_line_prefix == nil or train_line_prefix == ls.linevar:sub(1, #train_line_prefix) then
+ local direction_index, direction_stop = al.get_terminus(linevar_def, ls.linevar_index, false)
+ local direction = "???"
+ if direction_index ~= nil then
+ direction = get_station_name(direction_stop.stn)
+ end
+ local line = al.linevar_decompose(linevar_def.name)
+ 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].." 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.."] finished, location: "..
+ get_station_name(ls.linevar_past.station).." ("..age.." seconds ago)"
+ if results[train_id] ~= nil then
+ 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),
+ value = s,
+ })
+ end
+ end
+ table.sort(results, function(a, b) return a.key < b.key end)
+ for i, v in ipairs(results) do
+ result[i] = v.value
+ end
+ return result
+end
+
+-- příkaz /vlaky
+local def = {
+ 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, "No matching train found."
+ end
+ return true, "Listing "..#result.." trains:\n- "..table.concat(result, "\n- ")
+ end,
+}
+core.register_chatcommand("list_trains", def)
+def = {
+ params = "[line]",
+ description = "List all trains on the given line (or all lines) + trains that have recently completed the line",
+ privs = {},
+ func = function(player_name, param)
+ local result = vlaky(param, true)
+ if #result == 0 then
+ return false, "No matching train found."
+ end
+ return true, "Listing "..#result.." trains:\n- "..table.concat(result, "\n- ")
+ end,
+}
+core.register_chatcommand("list_trains+", def)
+
+def = {
+ -- params = "",
+ description = "(pro ladění)",
+ privs = {server = true},
+ func = function(player_name, param)
+ local train = advtrains.trains[param]
+ if train == nil then
+ return false, "Vlak "..param.." nenalezen!"
+ end
+ local line_status, linevar_def = al.get_line_status(train)
+ if linevar_def == nil then
+ return false, "Vlak "..param.." není linkový!"
+ end
+ -- function al.predict_train(line_status, linevar_def, rwtime, allow_continue)
+ local rwtime = rwt.now()
+ local predictions = al.predict_train(line_status, linevar_def, rwtime, true)
+ local result = {"----"}
+ local s
+ for i, record in ipairs(predictions) do
+ local arr, dep
+ if record.arr ~= nil then
+ arr = "("..rwt.diff(rwtime, record.arr)..", lv="..record.arr_linevar_def.name..", i="..record.arr_index..")"
+ else
+ arr = "nil"
+ end
+ if record.dep ~= nil then
+ dep = "("..rwt.diff(rwtime, record.dep)..", lv="..record.dep_linevar_def.name..", i="..record.dep_index..")"
+ else
+ dep = "nil"
+ end
+ result[i + 1] = "- "..record.stn.." ["..record.track.."] arr="..arr.." dep="..dep.." delay="..record.delay
+ end
+ table.insert(result, "----")
+ s = table.concat(result, "\n")
+ print(s)
+ core.chat_send_player(player_name, s)
+ return true
+ end,
+}
+core.register_chatcommand("jřád", def)
+core.register_chatcommand("jrad", def)
diff --git a/advtrains_line_automation/locale/advtrains_line_automation.de.po b/advtrains_line_automation/locale/advtrains_line_automation.de.po
new file mode 100644
index 0000000..f198867
--- /dev/null
+++ b/advtrains_line_automation/locale/advtrains_line_automation.de.po
@@ -0,0 +1,1273 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: advtrains\n"
+"Report-Msgid-Bugs-To: advtrains-discuss@lists.sr.ht\n"
+"POT-Creation-Date: 2026-03-22 17:25+0100\n"
+"PO-Revision-Date: 2026-03-22 17:28+0100\n"
+"Last-Translator: Y. Wang <yw05@forksworld.de>\n"
+"Language-Team: German\n"
+"Language: de\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 3.6\n"
+
+#: line_editor.lua
+msgid "(departed)"
+msgstr "(abgefahren)"
+
+#: line_editor.lua
+msgid "@1 errors while checking line setup!"
+msgstr "@1 Fehler beim Prüfen der Linie!"
+
+#: line_editor.lua
+msgid "@1 trains restarted due to changes"
+msgstr "@1 Züge nach Änderung neu gestartet"
+
+#: line_editor.lua
+msgid "At start station:"
+msgstr "Am Startbahnhof:"
+
+#: line_editor.lua
+msgid "Back"
+msgstr "Zurück"
+
+#: line_editor.lua
+msgid "Cannot delete, because lineval @1 does not yet exist"
+msgstr "Kann nicht löschen, da @1 nicht existiert"
+
+#: line_editor.lua
+msgid "Cannot replace, because lineval @1 does not yet exist"
+msgstr "Kann nicht ersetzen, da @1 nicht existiert"
+
+#: line_editor.lua
+msgid "Code"
+msgstr "Code"
+
+#: line_editor.lua
+msgid "Continues:"
+msgstr "Weiter als:"
+
+#: line_editor.lua
+msgid "Delete Line"
+msgstr "Linie löschen"
+
+#: line_editor.lua
+msgid "Deletion failed: "
+msgstr "Löschen fehlgeschlagen: "
+
+#: line_editor.lua
+msgid "Dep."
+msgstr "Ab"
+
+#: line_editor.lua
+msgid "Departure time must lie within 0-3600 seconds!"
+msgstr "Abfahrtszeit muss zwischen 0-3600 Sekunden liegen!"
+
+#: line_editor.lua
+msgid "Dest. Display:"
+msgstr "Zielanzeige:"
+
+#: line_editor.lua
+msgid "Disable"
+msgstr "Deaktivieren"
+
+#: line_editor.lua
+msgid "Duplicate departure time!"
+msgstr "Doppelte Abfahrtszeit!"
+
+#: line_editor.lua
+msgid "Error in line setup: "
+msgstr "Fehler in der Linie: "
+
+#: line_editor.lua
+msgid "Field 'Continuation' must contain maximum 1 '/'!"
+msgstr "Feld \"Weiter Als\" darf max 1x '/' haben!"
+
+#: line_editor.lua
+msgid "Hidden"
+msgstr "Versteckt"
+
+#: line_editor.lua
+msgid "Hidden (normal)"
+msgstr "Versteckt (normal)"
+
+#: line_editor.lua
+msgid "Inactive"
+msgstr "Inaktiv"
+
+#: line_editor.lua
+msgid "Incorrect departure time format!"
+msgstr "Inkorrektes Abfahrtszeitformat!"
+
+#: line_editor.lua
+msgid "Incorrect format for stop position!"
+msgstr "Inkorrektes Format für Stoppposition!"
+
+#: line_editor.lua
+msgid "Insufficient permissions to edit '@1'."
+msgstr "Nicht genug Berechtigungen, um '@1' zu bearbeiten."
+
+#: line_editor.lua
+msgid "LINE,ROUTE,VAR."
+msgstr "LINIE,ROUTE,VAR."
+
+#: line_editor.lua
+msgid "Last passages"
+msgstr "Letzte Fahrten"
+
+#: line_editor.lua
+msgid "Last passages of line @1"
+msgstr "Letzte Fahrten der Linie @1"
+
+#: line_editor.lua
+msgid "Line '@1' successfully deleted!"
+msgstr "Linie '@1' erfolgreich gelöscht!"
+
+#: line_editor.lua
+msgid "Line '@1' successfully saved!"
+msgstr "Linie '@1' erfolgreich gespeichert!"
+
+#: line_editor.lua stoprail.lua
+msgid "Line Editor"
+msgstr "Linieneditor"
+
+#: line_editor.lua
+msgid "Line name must not be empty!"
+msgstr "Linienname darf nicht leer sein!"
+
+#: line_editor.lua
+msgid "Line name must not contain characters '/', '|' or '\\'!"
+msgstr "Linienname darf nicht '/', '|' oder '\\' enthalten!"
+
+#: line_editor.lua
+msgid "Line name must not exceed 16 characters!"
+msgstr "Linienname darf nicht mehr als 16 Zeichen haben!"
+
+#: line_editor.lua
+msgid "Line name must not exceed 256 characters!"
+msgstr "Linienname darf nicht mehr als 256 Zeichen haben!"
+
+#: line_editor.lua
+msgid "Line owner must not be empty!"
+msgstr "Besitzer darf nicht leer sein!"
+
+#: line_editor.lua
+msgid "Line setup must contain at least 1 terminus stop!"
+msgstr "Linie muss mindestens 1 Endstation haben!"
+
+#: line_editor.lua
+msgid "Line:"
+msgstr "Linie:"
+
+#: line_editor.lua
+msgid "Mode"
+msgstr "Modus"
+
+#: line_editor.lua
+msgid "New Line..."
+msgstr "Neue Linie..."
+
+#: line_editor.lua
+msgid "No issues found, the line can now be saved!"
+msgstr "Keine Probleme gefunden, Linie kann jetzt gespeichert werden!"
+
+#: line_editor.lua
+msgid "No such station"
+msgstr "Kein solcher Bahnhof"
+
+#: line_editor.lua
+msgid "Normal"
+msgstr "Normal"
+
+#: line_editor.lua station_editor.lua
+msgid "OWNER"
+msgstr "BESITZER"
+
+#: line_editor.lua
+msgid "Open line editor"
+msgstr "Öffne Linieneditor"
+
+#: line_editor.lua station_editor.lua
+msgid "Owner:"
+msgstr "Besitzer:"
+
+#: line_editor.lua
+msgid "Position"
+msgstr "Position"
+
+#: line_editor.lua
+msgid "Request Stop (experimental)"
+msgstr "Bedarfshalt (experimentell)"
+
+#: line_editor.lua
+msgid "Reset changes"
+msgstr "Änd. zurücksetzen"
+
+#: line_editor.lua
+msgid "Routing code must not contain '/', '|' or '\\'!"
+msgstr "Routingcode darf nicht '/', '|' oder '\\' enthalten!"
+
+#: line_editor.lua
+msgid "Save changes"
+msgstr "Speichern"
+
+#: line_editor.lua
+msgid "St.Time"
+msgstr "W.zeit"
+
+#: line_editor.lua
+msgid "Starting station code must not be empty!"
+msgstr "Startstations-Code darf nicht leer sein!"
+
+#: line_editor.lua
+msgid "Station"
+msgstr "Bhf."
+
+#: line_editor.lua stoprail.lua
+msgid "Station Code"
+msgstr "Kennz."
+
+#: line_editor.lua
+msgid "Station code must not contain '/', '|' or '\\'!"
+msgstr "Stationscode darf nicht '/', '|' oder '\\' enthalten!"
+
+#: line_editor.lua
+msgid "Stop position must not exceed 22 characters!"
+msgstr "Halteposition darf nicht mehr als 22 Zeichen haben!"
+
+#: line_editor.lua line_functions.lua
+msgid "Terminus"
+msgstr "Endstation"
+
+#: line_editor.lua
+msgid "Terminus (continuing)"
+msgstr "Endstation (fortsetzend)"
+
+#: line_editor.lua
+msgid "Terminus (hidden)"
+msgstr "Endstation (versteckt)"
+
+#: line_editor.lua station_editor.lua stoprail.lua
+msgid "Track"
+msgstr "Gleis"
+
+#: line_editor.lua
+msgid "Train name must not exceed 256 characters!"
+msgstr "Zugname darf nicht mehr als 256 Zeichen haben!"
+
+#: line_editor.lua
+msgid "Travelling:"
+msgstr "Unterwegs:"
+
+#: line_editor.lua
+msgid "Unknown reason"
+msgstr "Unbekannter Grund"
+
+#: line_editor.lua
+msgid "Unknown station code!"
+msgstr "Unbekannter Stationscode!"
+
+#: line_editor.lua
+msgid "Update"
+msgstr "Aktualisieren"
+
+#: line_editor.lua
+msgid "Variant:"
+msgstr "Variante:"
+
+#: line_editor.lua
+msgid "Verify/Save"
+msgstr "Prüfen/Speichern"
+
+#: line_functions.lua
+msgid " (on request)"
+msgstr " (Bedarfshalt)"
+
+#: line_functions.lua
+msgid "Next Stop:"
+msgstr "Nächste Haltestelle:"
+
+#: line_functions.lua
+msgid "Next Stop: "
+msgstr "Nächste Haltestelle: "
+
+#: line_functions.lua
+msgid "Next stop: "
+msgstr "Nächste Haltestelle: "
+
+#: line_functions.lua
+msgid "Unknown Station"
+msgstr "Unbekannte Station"
+
+#: station_editor.lua
+msgid "(all platforms)"
+msgstr "(alle Bahnsteige)"
+
+#: station_editor.lua
+msgid "(select station)"
+msgstr "(wähle Bahnhof)"
+
+#: station_editor.lua
+msgid "@1 tracks"
+msgstr "@1 Gleise"
+
+#: station_editor.lua
+msgid "Assign"
+msgstr "Zuweisen"
+
+#: station_editor.lua
+msgid "Assign Track"
+msgstr "Gleis zuweisen"
+
+#: station_editor.lua
+msgid "By Distance"
+msgstr "Nach Distanz"
+
+#: station_editor.lua
+msgid "CODE"
+msgstr "CODE"
+
+#: station_editor.lua
+msgid "Code changed, @1 station tracks updated!"
+msgstr "Code geändert, @1 Stationsgleise aktualisiert!"
+
+#: station_editor.lua
+msgid "Code:"
+msgstr "Code:"
+
+#: station_editor.lua
+msgid "Create New"
+msgstr "Neu erstellen"
+
+#: station_editor.lua
+msgid "DISTANCE"
+msgstr "DISTANZ"
+
+#: station_editor.lua
+msgid "Delete"
+msgstr "Löschen"
+
+#: station_editor.lua
+msgid "ERROR: Code must not be empty!"
+msgstr "FEHLER: Code darf nicht leer sein!"
+
+#: station_editor.lua
+msgid "ERROR: No stop selected!"
+msgstr "FEHLER: Keine Haltestelle ausgewählt!"
+
+#: station_editor.lua
+msgid "ERROR: No such station!"
+msgstr "FEHLER: Keine solche Haltestelle!"
+
+#: station_editor.lua
+msgid "ERROR: Station '@1' already exists!"
+msgstr "FEHLER: Haltestelle '@1' existiert schon!"
+
+#: station_editor.lua
+msgid "ERROR: There are station tracks assigned, cannot delete the station!"
+msgstr "FEHLER: Es sind Stationsgleise zugewiesen, kann Station nicht löschen!"
+
+#: station_editor.lua
+msgid "INFO"
+msgstr "INFO"
+
+#: station_editor.lua
+msgid "Lines"
+msgstr "Linien"
+
+#: station_editor.lua
+msgid "My Stations (By Distance)"
+msgstr "Meine Stationen (nach Distanz)"
+
+#: station_editor.lua
+msgid "My Stations (Station Code A-Z)"
+msgstr "Meine Stationen (Stationscode A-Z)"
+
+#: station_editor.lua
+msgid "My Stations (Station Name A-Z)"
+msgstr "Meine Stationen (Stationsname A-Z)"
+
+#: station_editor.lua
+msgid "NAME"
+msgstr "NAME"
+
+#: station_editor.lua
+msgid "Name changed!"
+msgstr "Name geändert!"
+
+#: station_editor.lua
+msgid "Name:"
+msgstr "Name:"
+
+#: station_editor.lua
+msgid "No departures for the selected line found in the near future"
+msgstr "Keine Abfahrten für diese Linie in nächster Zeit"
+
+#: station_editor.lua
+msgid "Nothing has changed."
+msgstr "Nichts hat sich geändert."
+
+#: station_editor.lua
+msgid "Open station editor"
+msgstr "Stationseditor öffnen"
+
+#: station_editor.lua
+msgid "Owner changed!"
+msgstr "Besitzer geändert!"
+
+#: station_editor.lua
+msgid "Owner: "
+msgstr "Besitzer: "
+
+#: station_editor.lua
+msgid "Positions of tracks:"
+msgstr "Position der Gleise:"
+
+#: station_editor.lua
+msgid "Save Changes"
+msgstr "Änderungen speichern"
+
+#: station_editor.lua
+msgid "Set"
+msgstr "Setzen"
+
+#: station_editor.lua
+msgid "Station Code (A-Z)"
+msgstr "Stationscode (A-Z)"
+
+#: station_editor.lua stoprail.lua
+msgid "Station Editor"
+msgstr "Stationseditor"
+
+#: station_editor.lua
+msgid "Station Name (A-Z)"
+msgstr "Name der Haltestelle (A-Z)"
+
+#: station_editor.lua
+msgid "Station Operator: "
+msgstr "Stationsbetreiber: "
+
+#: station_editor.lua
+msgid "Station deleted!"
+msgstr "Station gelöscht!"
+
+#: station_editor.lua
+msgid "Station successfully created."
+msgstr "Station erfolgreich erstellt."
+
+#: station_editor.lua
+msgid "Timetable for current station (all lines)"
+msgstr "Fahrplan für aktuelle Station (alle Linien)"
+
+#: station_editor.lua
+msgid "Timetables"
+msgstr "Fahrpläne"
+
+#: station_editor.lua
+msgid "Timetables (all lines)"
+msgstr "Fahrpläne (alle Linien)"
+
+#: station_editor.lua
+msgid "Timetables..."
+msgstr "Fahrpläne..."
+
+#: station_editor.lua
+msgid "Timetables: "
+msgstr "Fahrpläne: "
+
+#: station_editor.lua
+msgid "Track successfully assigned!"
+msgstr "Gleis erfolgreich zugewiesen!"
+
+#: station_editor.lua
+msgid "Update next departures..."
+msgstr "Nächste Abfahren aktualisieren..."
+
+#: station_editor.lua
+msgid "[Station Editor]"
+msgstr "[Stationseditor]"
+
+#: station_editor.lua
+msgid "in operation"
+msgstr "in Betrieb"
+
+#: station_editor.lua
+msgid "lines"
+msgstr "Linien"
+
+#: station_editor.lua
+msgid "next departures of the selected line in: "
+msgstr "Nächste Abfahrt dieser Linie in: "
+
+#: station_editor.lua
+msgid "unknown state"
+msgstr "Unbekannter Zustand"
+
+#: stoprail.lua
+msgid "(foreign)"
+msgstr "(fremd)"
+
+#: stoprail.lua
+msgid "(unassigned)"
+msgstr "(nicht zugewiesen)"
+
+#: stoprail.lua
+msgid "Arrival Actions"
+msgstr "Aktionen bei Ankunft"
+
+#: stoprail.lua
+msgid "Departure Actions"
+msgstr "Aktionen bei Abfahrt"
+
+#: stoprail.lua
+msgid "Departure Mode"
+msgstr "Abfahrtsmodus"
+
+#: stoprail.lua
+msgid "Do not close the doors when departing, if they are open"
+msgstr "Türen bei Abfahrt nicht schließen"
+
+#: stoprail.lua
+msgid ""
+"Do not depart immediately, instead first enable ARS and wait until the next "
+"signal ahead clears (ATC G command) before closing the doors and departing."
+msgstr ""
+"Bei Abfahrt, aktiviert zuerst ARS und wartet bis Signal Fahrt zeigt (wie ATC "
+"G Befehl) bevor Türen geschlossen werden und abgefahren wird."
+
+#: stoprail.lua
+msgid ""
+"Do not disable ARS on approaching. Signals behind the stop rail already set "
+"ARS routes when the train arrives, not just before departure. (currently not "
+"implemented)"
+msgstr ""
+"Deaktiviert ARS nicht. Signale hinter dem Stationsgleis stellen bereits "
+"Fahrstraßen ein. (aktuell nicht implementiert)"
+
+#: stoprail.lua
+msgid "Door Side"
+msgstr "Türseite"
+
+#: stoprail.lua
+msgid "Interval:"
+msgstr "Intervall:"
+
+#: stoprail.lua
+msgid "Keep ARS enabled"
+msgstr "ARS aktiviert lassen"
+
+#: stoprail.lua
+msgid "Keep doors open"
+msgstr "Türen nach Abfahrt offen lassen"
+
+#: stoprail.lua
+msgid "Kick out passengers"
+msgstr "Fahrgäste zum Ausstieg zwingen"
+
+#: stoprail.lua
+msgid ""
+"List of actions to perform on arrival (currently not implemented, later will "
+"allow actions such as setting line, RC and displays)"
+msgstr "Liste von Aktionen bei Ankunft (aktuell nicht implementiert)"
+
+#: stoprail.lua
+msgid ""
+"List of actions to perform on departure (currently not implemented, later "
+"will allow actions such as setting line, RC and displays)"
+msgstr "Liste von Aktionen bei Abfahrt (aktuell nicht implementiert)"
+
+#: stoprail.lua
+msgid ""
+"No linevars\n"
+"available!"
+msgstr ""
+"Keine Fahrpläne\n"
+"ab hier verfügbar!"
+
+#: stoprail.lua
+msgid ""
+"Non-timetabled trains matching these ARS rules will stop at this position.\n"
+"Note: Train must also match the 'Selector' filter above!"
+msgstr ""
+"Nicht-Fahrplanzüge, die diesen Regeln entsprechen, halten hier.\n"
+"Achtung: Züge müssen auch dem 'Selektor' oben entsprechen!"
+
+#: stoprail.lua
+msgid ""
+"Non-timetabled trains matching these ARS rules will stop at this position.\n"
+"Trains under timetable will use the timetable's settings."
+msgstr ""
+"Nicht-Fahrplanzüge, die diesen Regeln entsprechen, halten hier.\n"
+"Züge im Fahrplan nutzen die Einstellungen des Fahrplans."
+
+#: stoprail.lua
+msgid "Offset:"
+msgstr "Versatz:"
+
+#: stoprail.lua
+msgid ""
+"Only trains matching these ARS rules will consider this stop rail as "
+"suitable timing point/stop position.\n"
+"Affects both timetabled and non-timetabled trains.\n"
+"Example: define a stop position for long trains (TL 30) and another for "
+"short trains (TL 0-30)."
+msgstr ""
+"Nur Züge, die diesen Regeln entsprechen, beachten dieses Stationsgleis als "
+"potentielle Halteposition.\n"
+"Betrifft sowohl Fahrplanzüge als auch Nicht-Fahrplanzüge.\n"
+"Beispiel: definiere 2 Halteplätze je für Langzüge (TL 30) und Kurzzüge (TL "
+"0-30)."
+
+#: stoprail.lua
+msgid "Reverse train"
+msgstr "Zug Umkehren"
+
+#: stoprail.lua
+msgid "Save"
+msgstr "Speichern"
+
+#: stoprail.lua
+msgid "Select if and on which side the train will open its doors once stopped"
+msgstr "Wähle aus, ob und auf welcher Seite die Türen öffnen sollen"
+
+#: stoprail.lua
+msgid ""
+"Select the time for departure:\n"
+"Normal: depart immediately after the stop time elapsed\n"
+"Interval: depart at the next time position set by interval and offset\n"
+"Begin Timetable: The train gets the given timetable assigned and departs "
+"according to its settings (currently not implemented)"
+msgstr ""
+"Abfahrtszeitpunkt auswählen:\n"
+"Normal: fährt sofort nach Ablauf der Haltezeit ab\n"
+"Intervall: fährt zum nächsten Zeitpunkt im gegebenen Intervall / Versatz ab\n"
+"Fahrplan beginnen: Beginnt den ausgewählten Fahrplan und fährt nach dessen "
+"Einstellungen ab"
+
+#: stoprail.lua
+msgid "Selector for stop pos (ARS)"
+msgstr "Selektor für Haltepos. (ARS)"
+
+#: stoprail.lua
+msgid "Selector for stop position..."
+msgstr "Selektor für Halteposition..."
+
+#: stoprail.lua
+msgid "Speed"
+msgstr "Geschw."
+
+#: stoprail.lua
+msgid "Speed that the train sets when departing. Set 'M' for maximum speed."
+msgstr "Geschwindigkeit des Zugs nach Abfahrt. 'M' für Höchstgeschwindigkeit."
+
+#: stoprail.lua
+msgid "Station Name"
+msgstr "Name der Haltestelle"
+
+#: stoprail.lua
+msgid "Station code '@1' does already exist and is owned by @2"
+msgstr ""
+"Die Haltestelle mit dem Kennzeichen „@1“ ist bereits vorhanden und wird von "
+"@2 verwaltet"
+
+#: stoprail.lua
+msgid "Station/Stop Track"
+msgstr "Haltepunktgleis"
+
+#: stoprail.lua
+msgid "Stn. @1 (@2) T. @3"
+msgstr "Stn. @1 (@2) Gl. @3"
+
+#: stoprail.lua
+msgid "Stop Time"
+msgstr "Wartezeit"
+
+#: stoprail.lua
+msgid "Stopping trains (ARS)"
+msgstr "Haltende Züge (ARS)"
+
+#: stoprail.lua
+msgid ""
+"The interval / time distance between departures in seconds. E.g. every two "
+"minutes -> set interval = 120"
+msgstr ""
+"Intervall / Abstand zwischen 2 Zügen in Sekunden. Z.B. alle 2 Minuten -> "
+"setze 120"
+
+#: stoprail.lua
+msgid ""
+"The offset of departures from time 0:00 in seconds. E.g. interval 120 offset "
+"60 -> departure at every odd minute"
+msgstr ""
+"Versatz gegenüber Zeit 00;00 in Sekunden. Z.B. Intervall 120 Versatz 60 "
+"bedeutet Abfahrt zu Minuten 01, 03, 05 usw."
+
+#: stoprail.lua
+msgid "Track number, for informational purposes"
+msgstr "Gleisnummer, für Informationszwecke"
+
+#: stoprail.lua
+msgid "Train will depart in the direction from where it arrived"
+msgstr "Zug fährt in die entgegengesetzte Richtung ab"
+
+#: stoprail.lua
+msgid ""
+"Train will remain stopped with open doors for at least this time before "
+"departure is attempted."
+msgstr "Zug bleibt mindestens für diese Zeit mit geöffneten Türen stehen."
+
+#: stoprail.lua
+msgid ""
+"Use when multiple stop rails are located in the same track of a station. "
+"Allows to select a suitable stop position depending on the class of train."
+msgstr ""
+"Nutzen Sie dies, wenn sich mehrere Stationsgleise im selben Gleis befinden "
+"sollen, welche verschiedene Haltepositionen für verschiedene Zugarten "
+"angeben. Erlaubt es, für jede Zugart die passende Position auszuwählen."
+
+#: stoprail.lua
+msgid "Wait for signal to clear"
+msgstr "Warte bis Signal Fahrt zeigt"
+
+#: stoprail.lua
+msgid "You are not allowed to configure this track."
+msgstr "Sie dürfen dieses Gleis nicht konfigurieren."
+
+#: stoprail.lua
+msgid "closed"
+msgstr "Geschlossen"
+
+#: stoprail.lua
+msgid "left"
+msgstr "Links"
+
+#: stoprail.lua
+msgid "right"
+msgstr "Rechts"
+
+#: time_table.lua
+msgid "Timetable"
+msgstr "Fahrplan"
+
+#: time_table.lua
+msgid "Timetable (on pole)"
+msgstr "Fahrplan (auf Stange)"
+
+#: time_table.lua
+msgid "Timetable (owner: @1)"
+msgstr "Fahrplan (Besitzer: @1)"
+
+#~ msgid "(Doors closed)"
+#~ msgstr "(Türen geschlossen)"
+
+#~ msgid "3-way turnout"
+#~ msgstr "Dreiwegweiche"
+
+#~ msgid "90+Angle Diamond Crossing Track"
+#~ msgstr "Kreuzung mit einem achsenparallelen Gleis"
+
+#~ msgid "<No coupler>"
+#~ msgstr "<Keine Kupplung vorhanden>"
+
+#~ msgid "@1 Platform (45 degree)"
+#~ msgstr "Hoher @1-Bahnsteig (45°)"
+
+#~ msgid "@1 Platform (high)"
+#~ msgstr "Hoher @1-Bahnsteig"
+
+#~ msgid "@1 Platform (low)"
+#~ msgstr "Niedriger @1-Bahnsteig"
+
+#~ msgid "@1 Platform (low, 45 degree)"
+#~ msgstr "Niedriger @1-Bahnsteig (45°)"
+
+#~ msgid "@1 Slope"
+#~ msgstr "@1 Steigung"
+
+#~ msgid "ATC Kick command warning: doors are closed."
+#~ msgstr ""
+#~ "Zugbeeinflussung: Wegen geschlossener Türen werden Fahrgäste nicht zum "
+#~ "Ausstieg gezwungen."
+
+#~ msgid "ATC Kick command warning: train moving."
+#~ msgstr ""
+#~ "Zugbeeinflussung: Der Zug befindet sich in Bewegung, Fahrgäste werden "
+#~ "nicht zum Ausstieg gezwungen."
+
+#~ msgid "ATC Reverse command warning: didn't reverse train, train moving."
+#~ msgstr ""
+#~ "Zugbeeinflussung: Der Zug befindet sich in Bewegung und kann nicht "
+#~ "umgekehrt werden."
+
+#~ msgid "ATC command parse error: Unknown command: @1"
+#~ msgstr "Zugbeeinflussung: Unbekannter Befehl: @1"
+
+#~ msgid "ATC command syntax error: I statement not closed: @1"
+#~ msgstr "Zugbeeinflussung: Unvollständiger I-Befehl: @1"
+
+#~ msgid "ATC controller"
+#~ msgstr "Zugbeeinflussungsgleis"
+
+#~ msgid ""
+#~ "ATC controller, mode @1\n"
+#~ "Channel: @2"
+#~ msgstr ""
+#~ "Zugbeeinflussungsgleis in Betriebsart „@1“\n"
+#~ "Kanal: @2"
+
+#~ msgid ""
+#~ "ATC controller, mode @1\n"
+#~ "Command: @2"
+#~ msgstr ""
+#~ "Zugbeeinflussungsgleis in Betriebsart „@1“\n"
+#~ "Befehl: @2"
+
+#~ msgid "Access to @1"
+#~ msgstr "Zugang zu @1"
+
+#~ msgid "Andrew's Cross"
+#~ msgstr "Andreaskreuz"
+
+#~ msgid "Back of train would end up off track, cancelling."
+#~ msgstr "Der hinterer Teil dez Zuges wäre nicht auf dem Gleis."
+
+#~ msgid "Big Industrial Train Engine"
+#~ msgstr "Große Industrielle Lokomotive"
+
+#~ msgid "Box Wagon"
+#~ msgstr "Güterwaggon"
+
+#~ msgid "Buffer and Chain Coupler"
+#~ msgstr "Schraubenkupplung"
+
+#~ msgid "Bumper"
+#~ msgstr "Prellbock"
+
+#~ msgid "Can not couple: The couplers of the trains do not match (@1 and @2)."
+#~ msgstr "Die Kupplungen der Züge passen nicht zueinander (@1 und @2)."
+
+#~ msgid ""
+#~ "Can place and configure LuaATC components, including execute potentially "
+#~ "harmful Lua code"
+#~ msgstr ""
+#~ "Kann LuaATC-Bauteile platzieren und konfigurieren (auch evtl. schädliche "
+#~ "Programme ausführen)"
+
+#~ msgid "Can't get on: wagon full or doors closed!"
+#~ msgstr ""
+#~ "Sie können nicht einsteigen: der Waggon ist voll oder die Türen sind "
+#~ "geschlossen."
+
+#, fuzzy
+#~ msgid "Can't place: Not enough slope items left (@1 required)"
+#~ msgstr ""
+#~ "Es kann nicht platziert werden: Sie haben nicht genug Steigungsblöcke, es "
+#~ "werden insgesamt @1 benötigt."
+
+#, fuzzy
+#~ msgid "Can't place: There's no slope of length @1"
+#~ msgstr ""
+#~ "Es kann nicht platziert werden: die Steigung der Länge @1 ist nicht "
+#~ "definiert."
+
+#, fuzzy
+#~ msgid "Can't place: no supporting node at upper end."
+#~ msgstr ""
+#~ "Es kann nicht platziert werden: es gibt keinen unterstützenden Block am "
+#~ "Ende der Steigung."
+
+#, fuzzy
+#~ msgid "Can't place: not pointing at node"
+#~ msgstr "Es kann nicht platziert werden: Sie zeigen nicht auf einem Block."
+
+#~ msgid "Can't place: protected position!"
+#~ msgstr "Es kann nicht platziert werden: diese Position ist geschützt."
+
+#, fuzzy
+#~ msgid "Can't place: space occupied!"
+#~ msgstr "Es kann nicht platziert werden: Diese Position ist besetzt."
+
+#~ msgid "Command"
+#~ msgstr "Befehl"
+
+#~ msgid "Command (on)"
+#~ msgstr "Befehl (wenn aktiviert)"
+
+#~ msgid "Default Seat"
+#~ msgstr "Standardsitzplatz"
+
+#~ msgid "Default Seat (driver stand)"
+#~ msgstr "Standardsitzplatz (Führerstand)"
+
+#~ msgid "Dep. Speed"
+#~ msgstr "Zielgeschwindigkeit bei Abfahrt"
+
+#~ msgid "Deprecated Track"
+#~ msgstr "ausrangiertes Gleis, nicht verwenden."
+
+#~ msgid "Detailed Steam Engine"
+#~ msgstr "Detaillierte Dampflokomotive"
+
+#~ msgid "Detector Rail"
+#~ msgstr "Detektorgleis"
+
+#~ msgid "Diagonal Diamond Crossing Track"
+#~ msgstr "Diagonale Gleiskreuzung"
+
+#~ msgid "Digiline channel"
+#~ msgstr "Digiline-Kanal"
+
+#~ msgid "Door Delay"
+#~ msgstr "Zeit für die Türschließung"
+
+#~ msgid "Doors are closed! (Try holding sneak key!)"
+#~ msgstr "Die Türen sind geschlossen."
+
+#~ msgid ""
+#~ "Doors are closed. Use Sneak+rightclick to ignore the closed doors and get "
+#~ "off."
+#~ msgstr ""
+#~ "Die Türen sind geschlossen. Nutzen Sie Schleichen+Rechtsklick, um trotz "
+#~ "geschlossener Türen auszusteigen."
+
+#, fuzzy
+#~ msgid "Driver Stand"
+#~ msgstr "Führerstand"
+
+#~ msgid "Driver Stand (left)"
+#~ msgstr "Führerstand Links"
+
+#~ msgid "Driver Stand (right)"
+#~ msgstr "Führerstand Rechts"
+
+#~ msgid "Driver stand"
+#~ msgstr "Führerstand"
+
+#~ msgid "Driver's cab"
+#~ msgstr "Führerstand"
+
+#~ msgid "Get off"
+#~ msgstr "Aussteigen"
+
+#~ msgid "Get off (forced)"
+#~ msgstr "Ausstieg zwingen"
+
+#~ msgid "Industrial Train Engine"
+#~ msgstr "Industrielle Lokomotive"
+
+#~ msgid "Industrial tank wagon"
+#~ msgstr "Tankwaggon"
+
+#~ msgid "Industrial wood wagon"
+#~ msgstr "Holztransportwaggon"
+
+#~ msgid "Japanese Train Engine"
+#~ msgstr "Japanische Personenzug-Lokomotive"
+
+#~ msgid "Japanese Train Inter-Wagon Connection"
+#~ msgstr "Waggonzwischenverbindung Japanischer Personenzüge"
+
+#~ msgid "Japanese Train Wagon"
+#~ msgstr "Japanischer Personenzug-Passagierwaggon"
+
+#, fuzzy
+#~ msgid "Japanese signal pole"
+#~ msgstr "Japanischer Personenzug-Passagierwaggon"
+
+#~ msgid "Lampless Signal"
+#~ msgstr "Mechanisches Signal"
+
+#~ msgid "Left"
+#~ msgstr "Links"
+
+#~ msgid "Lock couples"
+#~ msgstr "Kupplungen sperren"
+
+#~ msgid "LuaATC component with error: @1"
+#~ msgstr "LuaATC-Bauteil mit Fehlermeldung: @1"
+
+#~ msgid "No such lua entity."
+#~ msgstr ""
+#~ "Sie zeigen nicht auf einem Objekt, das mit diesem Werkzeug kopiert werden "
+#~ "kann."
+
+#~ msgid "No such wagon: @1."
+#~ msgstr "Es gibt keinen mit „@1“ identifizierbaren Waggon."
+
+#, fuzzy
+#~ msgid "Not allowed to do this."
+#~ msgstr "Sie dürfen dieses Gleis nicht konfigurieren."
+
+#~ msgid "Passenger Wagon"
+#~ msgstr "Passagierwaggon"
+
+#, fuzzy
+#~ msgid "Passenger area"
+#~ msgstr "Passagierwaggon"
+
+#~ msgid ""
+#~ "Passive Component Naming Tool\n"
+#~ "\n"
+#~ "Right-click to name a passive component."
+#~ msgstr ""
+#~ "PC-Benennungswerkzeug\n"
+#~ "\n"
+#~ "Rechtsklick zur Benennung der passiven Komponente."
+
+#~ msgid "Perpendicular Diamond Crossing Track"
+#~ msgstr "Kreuzung mit zueinander orthogonalen Gleisen"
+
+#~ msgid "Point Speed Restriction Track"
+#~ msgstr "Geschwindigkeitskontrollgleis"
+
+#~ msgid "Point speed restriction: @1"
+#~ msgstr "Geschwindigkeitskontrolle: @1"
+
+#~ msgid "Position is occupied by a train."
+#~ msgstr "Ein Zug steht an dieser Position."
+
+#~ msgid "Save wagon properties"
+#~ msgstr "Waggon-Einstellungen speichern"
+
+#~ msgid "Scharfenberg Coupler"
+#~ msgstr "Scharfenbergkupplung"
+
+#~ msgid "Select seat:"
+#~ msgstr "Wählen Sie einen Sitzplatz aus:"
+
+#~ msgid "Show Inventory"
+#~ msgstr "Inventar Zeigen"
+
+#~ msgid "Signal"
+#~ msgstr "Lichtsignal"
+
+#~ msgid "Steam Engine"
+#~ msgstr "Dampflokomotive"
+
+#~ msgid "Subway Passenger Wagon"
+#~ msgstr "U-Bahn-Waggon"
+
+#~ msgid "Target:"
+#~ msgstr "Zielges.:"
+
+#~ msgid "Text displayed inside train"
+#~ msgstr "Innere Anzeige"
+
+#~ msgid "Text displayed outside on train"
+#~ msgstr "Äußere Anzeige"
+
+#, fuzzy
+#~ msgid "That wagon does not exist!"
+#~ msgstr "In diesem Waggon ist kein Sitzplatz vorhanden."
+
+#~ msgid "The clipboard couldn't access the metadata. Copy failed."
+#~ msgstr ""
+#~ "Wegen des fehlgeschlagenen Zugriffs auf die Metadaten konnte der Zug "
+#~ "nicht kopiert werden."
+
+#~ msgid "The clipboard couldn't access the metadata. Paste failed."
+#~ msgstr ""
+#~ "Wegen des fehlgeschlagenen Zugriffs auf die Metadaten konnte eine Kopie "
+#~ "des Zuges nicht eingefügt werden."
+
+#~ msgid "The clipboard is empty."
+#~ msgstr "Das Clipboard ist leer."
+
+#, fuzzy
+#~ msgid "The track you are trying to place the wagon on is not long enough!"
+#~ msgstr "Das Gleis, auf dem der Waggon platziert werden woll, ist zu kurz."
+
+#~ msgid "The track you are trying to place the wagon on is not long enough."
+#~ msgstr "Das Gleis, auf dem der Waggon platziert werden woll, ist zu kurz."
+
+#~ msgid "The wagon's inventory is not empty."
+#~ msgstr "Das Inventar dieses Waggons ist nicht leer."
+
+#~ msgid "There's a Signal Influence Point here."
+#~ msgstr "Hier ist ein Signal-Beeinflussungspunkt."
+
+#~ msgid "There's a Track Circuit Break here."
+#~ msgstr "Hier ist eine Gleisabschnittsgrenze (TCB)."
+
+#, fuzzy
+#~ msgid "This Wagon ID"
+#~ msgstr "Der Waggon ist voll."
+
+#, fuzzy
+#~ msgid "This node can't be changed using the trackworker!"
+#~ msgstr "Dieser Block kann nicht mit dem Gleiswerkzeug bearbeitet werden."
+
+#, fuzzy
+#~ msgid "This node can't be rotated using the trackworker!"
+#~ msgstr "Dieser Block kann nicht mit dem Gleiswerkzeug gedreht werden."
+
+#~ msgid "This position is protected!"
+#~ msgstr "Diese Position ist geschützt!"
+
+#~ msgid "This station is owned by @1. You are not allowed to edit its name."
+#~ msgstr ""
+#~ "Diese Haltestelle wird von @1 verwaltet. Sie dürfen sie nicht umbenennen."
+
+#~ msgid "This track can not be changed."
+#~ msgstr "Dieses Gleis kann nicht geändert werden."
+
+#, fuzzy
+#~ msgid "This track can not be removed!"
+#~ msgstr "Dieses Gleis kann nicht entfernt werden."
+
+#, fuzzy
+#~ msgid "This track can not be rotated!"
+#~ msgstr "Dieses Gleis kann nicht gedreht werden."
+
+#~ msgid "This wagon has no seats."
+#~ msgstr "In diesem Waggon ist kein Sitzplatz vorhanden."
+
+#~ msgid "This wagon is full."
+#~ msgstr "Der Waggon ist voll."
+
+#~ msgid "This wagon is owned by @1, you can't destroy it."
+#~ msgstr "Dieser Waggon gehört @1, Sie dürfen ihn nicht abbauen."
+
+#~ msgid ""
+#~ "Track Worker Tool\n"
+#~ "\n"
+#~ "Left-click: change rail type (straight/curve/switch)\n"
+#~ "Right-click: rotate object"
+#~ msgstr ""
+#~ "Gleiswerkzeug\n"
+#~ "\n"
+#~ "Linksklick: Gleistyp ändern\n"
+#~ "Rechtsklick: Objekt drehen"
+
+#, fuzzy
+#~ msgid "Train "
+#~ msgstr "Der Zug wurde Kopiert."
+
+#~ msgid "Train copied."
+#~ msgstr "Der Zug wurde Kopiert."
+
+#~ msgid ""
+#~ "Train copy/paste tool\n"
+#~ "\n"
+#~ "Left-click: copy train\n"
+#~ "Right-click: paste train"
+#~ msgstr ""
+#~ "Werkzeug zur Erstellung von Zugkopien\n"
+#~ "\n"
+#~ "Linksklick: Zug ins Clipboard kopieren\n"
+#~ "Right-click: Kopierten Zug einfügen"
+
+#~ msgid "Trains stopping here (ARS rules)"
+#~ msgstr "Züge, die hier halten (ARS-Regeln)"
+
+#~ msgid "Unconfigured ATC controller"
+#~ msgstr "Nicht konfiguiertes Zugbeeinflussungsgleis"
+
+#~ msgid "Unconfigured LuaATC component"
+#~ msgstr "Nicht konfiguierter LuaATC-Bauteil"
+
+#~ msgid "Unloading Track"
+#~ msgstr "Abladungsgleis"
+
+#~ msgid "Use Sneak+rightclick to bypass closed doors!"
+#~ msgstr ""
+#~ "Nutzen Sie Schleichen+Rechtsklick, um trotz geschlossener Türen "
+#~ "einzusteigen."
+
+#, fuzzy
+#~ msgid "Wagon Properties Tool"
+#~ msgstr "Waggon-Einstellungen"
+
+#~ msgid ""
+#~ "Wagon needs to be decoupled from other wagons in order to destroy it."
+#~ msgstr "Der Waggon muss abgekoppelt sein, damit Sie ihn abbauen können."
+
+#~ msgid "Wagon properties"
+#~ msgstr "Waggon-Einstellungen"
+
+#~ msgid "Wallmounted Signal (left)"
+#~ msgstr "An der linken Seite montiertes Signal"
+
+#~ msgid "Wallmounted Signal (right)"
+#~ msgstr "An der rechten Seite montiertes Signal"
+
+#~ msgid "Wallmounted Signal (top)"
+#~ msgstr "An der Decke montiertes Signal"
+
+#~ msgid ""
+#~ "Warning: If you destroy this wagon, you only get some steel back! If you "
+#~ "are sure, hold Sneak and left-click the wagon."
+#~ msgstr ""
+#~ "Warnung: Durch den Abbau des Waggons erhalten Sie nur etwas Stahl zurück. "
+#~ "Nutzen Sie Schleichen+Linksklick, um dem Waggon abzubauen."
+
+#~ msgid "Y-turnout"
+#~ msgstr "Y-Weiche"
+
+#~ msgid "You are not allowed to access the driver stand."
+#~ msgstr "Sie haben keinen Zugang zum Führerstand."
+
+#~ msgid "You are not allowed to build near tracks at this protected position."
+#~ msgstr ""
+#~ "Sie dürfen an geschützten Stellen nicht in der Nähe von Gleisen bauen."
+
+#~ msgid ""
+#~ "You are not allowed to build near tracks without the track_builder "
+#~ "privilege."
+#~ msgstr ""
+#~ "Sie dürfen ohne das „track_builder“-Privileg nicht in der Nähe von "
+#~ "Gleisen bauen."
+
+#~ msgid "You are not allowed to build tracks at this protected position."
+#~ msgstr "Sie dürfen an geschützten Stellen kein Gleis bauen."
+
+#~ msgid ""
+#~ "You are not allowed to build tracks without the track_builder privilege."
+#~ msgstr "Sie dürfen ohne das „track_builder“-Privileg kein Gleis bauen."
+
+#~ msgid ""
+#~ "You are not allowed to configure this LuaATC component without the @1 "
+#~ "privilege."
+#~ msgstr ""
+#~ "Sie dürfen ohne das „@1“-Privileg diesen LuaATC-Bauteil nicht "
+#~ "konfigurieren."
+
+#~ msgid ""
+#~ "You are not allowed to configure this track without the @1 privilege."
+#~ msgstr "Sie dürfen ohne das „@1“-Privileg dieses Gleis nicht konfigurieren."
+
+#~ msgid ""
+#~ "You are not allowed to couple trains without the train_operator privilege."
+#~ msgstr "Sie dürfen ohne das „train_operator“-Privileg keine Züge ankuppeln."
+
+#, fuzzy
+#~ msgid "You are not allowed to modify this protected track."
+#~ msgstr "Sie dürfen an geschützten Stellen kein Gleis bauen."
+
+#~ msgid ""
+#~ "You are not allowed to name LuaATC passive components without the @1 "
+#~ "privilege."
+#~ msgstr "Sie dürfen ohne das „@1“ keinen passiven LuaATC-Bauteil benennen."
+
+#~ msgid ""
+#~ "You are not allowed to operate turnouts and signals without the "
+#~ "railway_operator privilege."
+#~ msgstr ""
+#~ "Sie dürfen ohne das „railway_operator“-Privileg keine Bahnanlage "
+#~ "operieren."
+
+#~ msgid "You can't get on this wagon."
+#~ msgstr "Sie können nicht in diesen Waggon einsteigen."
+
+#~ msgid "You do not have the @1 privilege."
+#~ msgstr "Ihnen fehlt das „@1“-Privileg."
+
+#, fuzzy
+#~ msgid "You don't have the train_operator privilege."
+#~ msgstr "Ihnen fehlt das „@1“-Privileg."
+
+#~ msgid ""
+#~ "You need to own at least one neighboring wagon to destroy this couple."
+#~ msgstr ""
+#~ "Sie müssen Besitzer eines angrenzenden Waggons sein, um hier abzukuppeln."
diff --git a/advtrains_line_automation/locale/advtrains_line_automation.fr.po b/advtrains_line_automation/locale/advtrains_line_automation.fr.po
new file mode 100644
index 0000000..3cf315b
--- /dev/null
+++ b/advtrains_line_automation/locale/advtrains_line_automation.fr.po
@@ -0,0 +1,1549 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: advtrains\n"
+"Report-Msgid-Bugs-To: advtrains-discuss@lists.sr.ht\n"
+"POT-Creation-Date: 2026-03-22 17:25+0100\n"
+"PO-Revision-Date: 2025-03-25 15:06+0100\n"
+"Last-Translator: Tanavit <tanavit@posto.ovh>\n"
+"Language-Team: French\n"
+"Language: fr\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 2.4.2\n"
+
+#: line_editor.lua
+msgid "(departed)"
+msgstr ""
+
+#: line_editor.lua
+msgid "@1 errors while checking line setup!"
+msgstr ""
+
+#: line_editor.lua
+msgid "@1 trains restarted due to changes"
+msgstr ""
+
+#: line_editor.lua
+msgid "At start station:"
+msgstr ""
+
+#: line_editor.lua
+msgid "Back"
+msgstr ""
+
+#: line_editor.lua
+msgid "Cannot delete, because lineval @1 does not yet exist"
+msgstr ""
+
+#: line_editor.lua
+msgid "Cannot replace, because lineval @1 does not yet exist"
+msgstr ""
+
+#: line_editor.lua
+msgid "Code"
+msgstr "Code"
+
+#: line_editor.lua
+msgid "Continues:"
+msgstr ""
+
+#: line_editor.lua
+msgid "Delete Line"
+msgstr ""
+
+#: line_editor.lua
+#, fuzzy
+msgid "Deletion failed: "
+msgstr "Échec de sauvegarde : "
+
+#: line_editor.lua
+msgid "Dep."
+msgstr ""
+
+#: line_editor.lua
+msgid "Departure time must lie within 0-3600 seconds!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Dest. Display:"
+msgstr ""
+
+#: line_editor.lua
+msgid "Disable"
+msgstr ""
+
+#: line_editor.lua
+msgid "Duplicate departure time!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Error in line setup: "
+msgstr ""
+
+#: line_editor.lua
+msgid "Field 'Continuation' must contain maximum 1 '/'!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Hidden"
+msgstr ""
+
+#: line_editor.lua
+msgid "Hidden (normal)"
+msgstr ""
+
+#: line_editor.lua
+msgid "Inactive"
+msgstr ""
+
+#: line_editor.lua
+msgid "Incorrect departure time format!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Incorrect format for stop position!"
+msgstr ""
+
+#: line_editor.lua
+#, fuzzy
+msgid "Insufficient permissions to edit '@1'."
+msgstr "Privilèges insuffisants pour utiliser ceci !"
+
+#: line_editor.lua
+msgid "LINE,ROUTE,VAR."
+msgstr ""
+
+#: line_editor.lua
+msgid "Last passages"
+msgstr ""
+
+#: line_editor.lua
+msgid "Last passages of line @1"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line '@1' successfully deleted!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line '@1' successfully saved!"
+msgstr ""
+
+#: line_editor.lua stoprail.lua
+msgid "Line Editor"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line name must not be empty!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line name must not contain characters '/', '|' or '\\'!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line name must not exceed 16 characters!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line name must not exceed 256 characters!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line owner must not be empty!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line setup must contain at least 1 terminus stop!"
+msgstr ""
+
+#: line_editor.lua
+#, fuzzy
+msgid "Line:"
+msgstr "Ligne"
+
+#: line_editor.lua
+msgid "Mode"
+msgstr ""
+
+#: line_editor.lua
+msgid "New Line..."
+msgstr ""
+
+#: line_editor.lua
+msgid "No issues found, the line can now be saved!"
+msgstr ""
+
+#: line_editor.lua
+#, fuzzy
+msgid "No such station"
+msgstr "Pas de tel train : @1."
+
+#: line_editor.lua
+msgid "Normal"
+msgstr ""
+
+#: line_editor.lua station_editor.lua
+msgid "OWNER"
+msgstr ""
+
+#: line_editor.lua
+msgid "Open line editor"
+msgstr ""
+
+#: line_editor.lua station_editor.lua
+msgid "Owner:"
+msgstr ""
+
+#: line_editor.lua
+msgid "Position"
+msgstr ""
+
+#: line_editor.lua
+msgid "Request Stop (experimental)"
+msgstr ""
+
+#: line_editor.lua
+#, fuzzy
+msgid "Reset changes"
+msgstr "Changement d'état de l'itinéraire."
+
+#: line_editor.lua
+msgid "Routing code must not contain '/', '|' or '\\'!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Save changes"
+msgstr ""
+
+#: line_editor.lua
+#, fuzzy
+msgid "St.Time"
+msgstr "Durée d'arrêt"
+
+#: line_editor.lua
+msgid "Starting station code must not be empty!"
+msgstr ""
+
+#: line_editor.lua
+#, fuzzy
+msgid "Station"
+msgstr "Code de Station"
+
+#: line_editor.lua stoprail.lua
+msgid "Station Code"
+msgstr "Code de Station"
+
+#: line_editor.lua
+msgid "Station code must not contain '/', '|' or '\\'!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Stop position must not exceed 22 characters!"
+msgstr ""
+
+#: line_editor.lua line_functions.lua
+msgid "Terminus"
+msgstr ""
+
+#: line_editor.lua
+msgid "Terminus (continuing)"
+msgstr ""
+
+#: line_editor.lua
+msgid "Terminus (hidden)"
+msgstr ""
+
+#: line_editor.lua station_editor.lua stoprail.lua
+msgid "Track"
+msgstr "Voie"
+
+#: line_editor.lua
+msgid "Train name must not exceed 256 characters!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Travelling:"
+msgstr ""
+
+#: line_editor.lua
+#, fuzzy
+msgid "Unknown reason"
+msgstr "Gare inconnue"
+
+#: line_editor.lua
+#, fuzzy
+msgid "Unknown station code!"
+msgstr "Gare inconnue"
+
+#: line_editor.lua
+msgid "Update"
+msgstr ""
+
+#: line_editor.lua
+msgid "Variant:"
+msgstr ""
+
+#: line_editor.lua
+msgid "Verify/Save"
+msgstr ""
+
+#: line_functions.lua
+msgid " (on request)"
+msgstr ""
+
+#: line_functions.lua
+#, fuzzy
+msgid "Next Stop:"
+msgstr "Prochain arrêt :\n"
+
+#: line_functions.lua
+#, fuzzy
+msgid "Next Stop: "
+msgstr "Prochain arrêt :\n"
+
+#: line_functions.lua
+#, fuzzy
+msgid "Next stop: "
+msgstr "Prochain arrêt :\n"
+
+#: line_functions.lua
+msgid "Unknown Station"
+msgstr "Gare inconnue"
+
+#: station_editor.lua
+msgid "(all platforms)"
+msgstr ""
+
+#: station_editor.lua
+#, fuzzy
+msgid "(select station)"
+msgstr "Pas de tel train : @1."
+
+#: station_editor.lua
+msgid "@1 tracks"
+msgstr ""
+
+#: station_editor.lua
+msgid "Assign"
+msgstr ""
+
+#: station_editor.lua
+#, fuzzy
+msgid "Assign Track"
+msgstr "Voie de Chargement"
+
+#: station_editor.lua
+msgid "By Distance"
+msgstr ""
+
+#: station_editor.lua
+msgid "CODE"
+msgstr ""
+
+#: station_editor.lua
+msgid "Code changed, @1 station tracks updated!"
+msgstr ""
+
+#: station_editor.lua
+#, fuzzy
+msgid "Code:"
+msgstr "Code"
+
+#: station_editor.lua
+msgid "Create New"
+msgstr ""
+
+#: station_editor.lua
+msgid "DISTANCE"
+msgstr ""
+
+#: station_editor.lua
+msgid "Delete"
+msgstr ""
+
+#: station_editor.lua
+msgid "ERROR: Code must not be empty!"
+msgstr ""
+
+#: station_editor.lua
+msgid "ERROR: No stop selected!"
+msgstr ""
+
+#: station_editor.lua
+msgid "ERROR: No such station!"
+msgstr ""
+
+#: station_editor.lua
+msgid "ERROR: Station '@1' already exists!"
+msgstr ""
+
+#: station_editor.lua
+msgid "ERROR: There are station tracks assigned, cannot delete the station!"
+msgstr ""
+
+#: station_editor.lua
+msgid "INFO"
+msgstr ""
+
+#: station_editor.lua
+#, fuzzy
+msgid "Lines"
+msgstr "Ligne"
+
+#: station_editor.lua
+msgid "My Stations (By Distance)"
+msgstr ""
+
+#: station_editor.lua
+msgid "My Stations (Station Code A-Z)"
+msgstr ""
+
+#: station_editor.lua
+msgid "My Stations (Station Name A-Z)"
+msgstr ""
+
+#: station_editor.lua
+msgid "NAME"
+msgstr ""
+
+#: station_editor.lua
+#, fuzzy
+msgid "Name changed!"
+msgstr "Changement d'état de l'itinéraire."
+
+#: station_editor.lua
+msgid "Name:"
+msgstr ""
+
+#: station_editor.lua
+msgid "No departures for the selected line found in the near future"
+msgstr ""
+
+#: station_editor.lua
+#, fuzzy
+msgid "Nothing has changed."
+msgstr "Changement d'état de l'itinéraire."
+
+#: station_editor.lua
+msgid "Open station editor"
+msgstr ""
+
+#: station_editor.lua
+msgid "Owner changed!"
+msgstr ""
+
+#: station_editor.lua
+msgid "Owner: "
+msgstr ""
+
+#: station_editor.lua
+msgid "Positions of tracks:"
+msgstr ""
+
+#: station_editor.lua
+msgid "Save Changes"
+msgstr ""
+
+#: station_editor.lua
+msgid "Set"
+msgstr ""
+
+#: station_editor.lua
+#, fuzzy
+msgid "Station Code (A-Z)"
+msgstr "Code de Station"
+
+#: station_editor.lua stoprail.lua
+#, fuzzy
+msgid "Station Editor"
+msgstr "Code de Station"
+
+#: station_editor.lua
+#, fuzzy
+msgid "Station Name (A-Z)"
+msgstr "Nom de Station"
+
+#: station_editor.lua
+#, fuzzy
+msgid "Station Operator: "
+msgstr "Code de Station"
+
+#: station_editor.lua
+#, fuzzy
+msgid "Station deleted!"
+msgstr "Code de Station"
+
+#: station_editor.lua
+msgid "Station successfully created."
+msgstr ""
+
+#: station_editor.lua
+msgid "Timetable for current station (all lines)"
+msgstr ""
+
+#: station_editor.lua
+msgid "Timetables"
+msgstr ""
+
+#: station_editor.lua
+msgid "Timetables (all lines)"
+msgstr ""
+
+#: station_editor.lua
+msgid "Timetables..."
+msgstr ""
+
+#: station_editor.lua
+msgid "Timetables: "
+msgstr ""
+
+#: station_editor.lua
+msgid "Track successfully assigned!"
+msgstr ""
+
+#: station_editor.lua
+msgid "Update next departures..."
+msgstr ""
+
+#: station_editor.lua
+#, fuzzy
+msgid "[Station Editor]"
+msgstr "Code de Station"
+
+#: station_editor.lua
+msgid "in operation"
+msgstr ""
+
+#: station_editor.lua
+msgid "lines"
+msgstr ""
+
+#: station_editor.lua
+msgid "next departures of the selected line in: "
+msgstr ""
+
+#: station_editor.lua
+#, fuzzy
+msgid "unknown state"
+msgstr "Gare inconnue"
+
+#: stoprail.lua
+msgid "(foreign)"
+msgstr ""
+
+#: stoprail.lua
+msgid "(unassigned)"
+msgstr ""
+
+#: stoprail.lua
+msgid "Arrival Actions"
+msgstr ""
+
+#: stoprail.lua
+msgid "Departure Actions"
+msgstr ""
+
+#: stoprail.lua
+msgid "Departure Mode"
+msgstr ""
+
+#: stoprail.lua
+msgid "Do not close the doors when departing, if they are open"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Do not depart immediately, instead first enable ARS and wait until the next "
+"signal ahead clears (ATC G command) before closing the doors and departing."
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Do not disable ARS on approaching. Signals behind the stop rail already set "
+"ARS routes when the train arrives, not just before departure. (currently not "
+"implemented)"
+msgstr ""
+
+#: stoprail.lua
+msgid "Door Side"
+msgstr "Ouv. des portes coté"
+
+#: stoprail.lua
+msgid "Interval:"
+msgstr ""
+
+#: stoprail.lua
+msgid "Keep ARS enabled"
+msgstr ""
+
+#: stoprail.lua
+msgid "Keep doors open"
+msgstr ""
+
+#: stoprail.lua
+msgid "Kick out passengers"
+msgstr "Éjecter les passagers"
+
+#: stoprail.lua
+msgid ""
+"List of actions to perform on arrival (currently not implemented, later will "
+"allow actions such as setting line, RC and displays)"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"List of actions to perform on departure (currently not implemented, later "
+"will allow actions such as setting line, RC and displays)"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"No linevars\n"
+"available!"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Non-timetabled trains matching these ARS rules will stop at this position.\n"
+"Note: Train must also match the 'Selector' filter above!"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Non-timetabled trains matching these ARS rules will stop at this position.\n"
+"Trains under timetable will use the timetable's settings."
+msgstr ""
+
+#: stoprail.lua
+msgid "Offset:"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Only trains matching these ARS rules will consider this stop rail as "
+"suitable timing point/stop position.\n"
+"Affects both timetabled and non-timetabled trains.\n"
+"Example: define a stop position for long trains (TL 30) and another for "
+"short trains (TL 0-30)."
+msgstr ""
+
+#: stoprail.lua
+msgid "Reverse train"
+msgstr "Inversion du sens de marche"
+
+#: stoprail.lua
+msgid "Save"
+msgstr "Sauvegarder"
+
+#: stoprail.lua
+msgid "Select if and on which side the train will open its doors once stopped"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Select the time for departure:\n"
+"Normal: depart immediately after the stop time elapsed\n"
+"Interval: depart at the next time position set by interval and offset\n"
+"Begin Timetable: The train gets the given timetable assigned and departs "
+"according to its settings (currently not implemented)"
+msgstr ""
+
+#: stoprail.lua
+msgid "Selector for stop pos (ARS)"
+msgstr ""
+
+#: stoprail.lua
+msgid "Selector for stop position..."
+msgstr ""
+
+#: stoprail.lua
+#, fuzzy
+msgid "Speed"
+msgstr "Vitesse : "
+
+#: stoprail.lua
+msgid "Speed that the train sets when departing. Set 'M' for maximum speed."
+msgstr ""
+
+#: stoprail.lua
+msgid "Station Name"
+msgstr "Nom de Station"
+
+#: stoprail.lua
+#, fuzzy
+msgid "Station code '@1' does already exist and is owned by @2"
+msgstr "Le code de station \"@1\" existe et est possédé par @2."
+
+#: stoprail.lua
+msgid "Station/Stop Track"
+msgstr "Voie d'arrêt en station"
+
+#: stoprail.lua
+msgid "Stn. @1 (@2) T. @3"
+msgstr ""
+
+#: stoprail.lua
+msgid "Stop Time"
+msgstr "Durée d'arrêt"
+
+#: stoprail.lua
+msgid "Stopping trains (ARS)"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"The interval / time distance between departures in seconds. E.g. every two "
+"minutes -> set interval = 120"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"The offset of departures from time 0:00 in seconds. E.g. interval 120 offset "
+"60 -> departure at every odd minute"
+msgstr ""
+
+#: stoprail.lua
+msgid "Track number, for informational purposes"
+msgstr ""
+
+#: stoprail.lua
+msgid "Train will depart in the direction from where it arrived"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Train will remain stopped with open doors for at least this time before "
+"departure is attempted."
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Use when multiple stop rails are located in the same track of a station. "
+"Allows to select a suitable stop position depending on the class of train."
+msgstr ""
+
+#: stoprail.lua
+msgid "Wait for signal to clear"
+msgstr "En attente de signal d'autorisation"
+
+#: stoprail.lua
+msgid "You are not allowed to configure this track."
+msgstr "Vous n'êtes pas autorisé à configurer cette voie."
+
+#: stoprail.lua
+#, fuzzy
+msgid "closed"
+msgstr "Fermé"
+
+#: stoprail.lua
+msgid "left"
+msgstr ""
+
+#: stoprail.lua
+#, fuzzy
+msgid "right"
+msgstr "Droit"
+
+#: time_table.lua
+msgid "Timetable"
+msgstr ""
+
+#: time_table.lua
+msgid "Timetable (on pole)"
+msgstr ""
+
+#: time_table.lua
+msgid "Timetable (owner: @1)"
+msgstr ""
+
+#~ msgid " does not exist or is invalid"
+#~ msgstr " n'existe pas ou est invalide"
+
+#~ msgid " is at "
+#~ msgstr " est à la position "
+
+#~ msgid " units"
+#~ msgstr " Unités"
+
+#~ msgid " wagon:destroy(): data is not set!"
+#~ msgstr " Appel de wagon:destroy() : données non définies !"
+
+#~ msgid "!!! Train off track !!!"
+#~ msgstr "!!! Train hors voie !!!"
+
+#~ msgid "(Doors closed)"
+#~ msgstr "(Portes closes)"
+
+#~ msgid "(log"
+#~ msgstr "(log"
+
+#~ msgid ", using placeholder"
+#~ msgstr ", dans un espace réservé"
+
+#~ msgid "3-way turnout"
+#~ msgstr "Embranchement triple"
+
+#~ msgid "90+Angle Diamond Crossing Track"
+#~ msgstr "Croisement perpendiculo-diagonal"
+
+#~ msgid "<No coupler>"
+#~ msgstr "<Pas de coupleur>"
+
+#~ msgid "@1 Platform (45 degree)"
+#~ msgstr "Quai @1 (haut, 45°)"
+
+#~ msgid "@1 Platform (high)"
+#~ msgstr "Quai @1 (haut)"
+
+#~ msgid "@1 Platform (low)"
+#~ msgstr "Quai @1 (bas)"
+
+#~ msgid "@1 Platform (low, 45 degree)"
+#~ msgstr "Quai @1 (bas, 45°)"
+
+#~ msgid "@1 Slope"
+#~ msgstr "Pente @1"
+
+#~ msgid "ATC Kick command warning: doors are closed."
+#~ msgstr "Avertissement commande ATC Éjecter : portes closes."
+
+#~ msgid "ATC Kick command warning: train moving."
+#~ msgstr "Avertissement commande ATC Éjecter : train en mouvement."
+
+#~ msgid "ATC Reverse command warning: didn't reverse train, train moving."
+#~ msgstr ""
+#~ "Attention : Commande ATC de renversement impossible car le train se "
+#~ "déplace."
+
+#~ msgid "ATC command parse error: Unknown command: @1"
+#~ msgstr "Erreur d'analyse de commande ATC : Commande inconnue : @1"
+
+#~ msgid "ATC command syntax error: I statement not closed: @1"
+#~ msgstr ""
+#~ "Erreur de syntaxe de commande ATC : instruction \"I\" incomplète : @1"
+
+#~ msgid "ATC controller"
+#~ msgstr "Controlleur ATC"
+
+#~ msgid ""
+#~ "ATC controller, mode @1\n"
+#~ "Channel: @2"
+#~ msgstr ""
+#~ "Controlleur ATC, mode @1\n"
+#~ "Canal : @2"
+
+#~ msgid ""
+#~ "ATC controller, mode @1\n"
+#~ "Command: @2"
+#~ msgstr ""
+#~ "Controlleur ATC, mode @1\n"
+#~ "Commande : @2"
+
+#~ msgid "Access to @1"
+#~ msgstr "Accès à @1"
+
+#~ msgid "Advtrains Status: no_action"
+#~ msgstr "État d'advtrains : aucune action"
+
+#~ msgid "Advtrains is already running normally!"
+#~ msgstr "Advtrains fonctionne déjà correctement !"
+
+#~ msgid "Allow these players to access your wagon:"
+#~ msgstr "Autoriser ces joueurs à embarquer :"
+
+#~ msgid "Andrew's Cross"
+#~ msgstr "Croix de Saint André"
+
+#~ msgid "Back of train would end up off track, cancelling."
+#~ msgstr "La fin du train serait hors voie : annulation."
+
+#~ msgid "Big Industrial Train Engine"
+#~ msgstr "Grosse locomotive industrielle"
+
+#~ msgid "Boiler"
+#~ msgstr "Chaudière à vapeur"
+
+#~ msgid "Box Wagon"
+#~ msgstr "Wagon de frêt"
+
+#~ msgid "Buffer and Chain Coupler"
+#~ msgstr "Attelage à tampon et vis"
+
+#~ msgid "Bumper"
+#~ msgstr "Heurtoir"
+
+#~ msgid "Can not couple: The couplers of the trains do not match (@1 and @2)."
+#~ msgstr ""
+#~ "Accouplement impossible: les attelages des trains ne concordent pas (@1 "
+#~ "et @2)."
+
+#~ msgid "Can operate turnouts and signals in unprotected areas"
+#~ msgstr ""
+#~ "Possibilité d'opérer des embranchements et signaux dans les zones non "
+#~ "protégées"
+
+#~ msgid ""
+#~ "Can place and configure LuaATC components, including execute potentially "
+#~ "harmful Lua code"
+#~ msgstr ""
+#~ "Permet le placement et la configuration de composants LuaATC avec risque "
+#~ "d'exécution de code Lua dangereux"
+
+#~ msgid "Can place and dig tracks in unprotected areas"
+#~ msgstr ""
+#~ "Possibilité de poser ou retirer des voies dans les zones non protégées"
+
+#~ msgid ""
+#~ "Can place, remove and operate any train, regardless of owner, whitelist, "
+#~ "or protection"
+#~ msgstr ""
+#~ "Possibilité de poser, retirer ou opérer un quelconque train, "
+#~ "indépendamment du propriétaire, de la liste blanche ou de protection"
+
+#~ msgid "Can place, remove and operate trains"
+#~ msgstr "Possibilité de poser, retirer ou opérer les trains"
+
+#~ msgid "Can't get on: wagon full or doors closed!"
+#~ msgstr ""
+#~ "Embarquement impossible : le wagon est plein ou ses portes sont closes !"
+
+#~ msgid "Can't place: Not enough slope items left (@1 required)"
+#~ msgstr ""
+#~ "Placement impossible : quantité insuffisante de voie pentue (@1 manquant)"
+
+#~ msgid "Can't place: There's no slope of length @1"
+#~ msgstr "Placement impossible : il n'y a pas de voie pentue de longueur @1"
+
+#~ msgid "Can't place: no supporting node at upper end."
+#~ msgstr ""
+#~ "Placement impossible : pas de nœud d'appui à l'extrémité supérieure."
+
+#~ msgid "Can't place: not pointing at node"
+#~ msgstr "Placement impossible : ne pointe pas un nœud"
+
+#~ msgid "Can't place: protected position!"
+#~ msgstr "Placement impossible : emplacement protégé"
+
+#~ msgid "Can't place: space occupied!"
+#~ msgstr "Placement impossible : espace occupé !"
+
+#~ msgid "Caution"
+#~ msgstr "Attention"
+
+#~ msgid "Chimney"
+#~ msgstr "Cheminée"
+
+#~ msgid "Clear 'Disable ARS' flag"
+#~ msgstr "Effacer le drapeau \"Désactiver l'ARS\""
+
+#~ msgid "Clear (proceed)"
+#~ msgstr "Autorisation (procédez)"
+
+#~ msgid "Clear Local Environment"
+#~ msgstr "Effacer l'environnement LuaATC"
+
+#~ msgid "Command"
+#~ msgstr "Commande"
+
+#~ msgid "Command (on)"
+#~ msgstr "Commande (marche)"
+
+#~ msgid ""
+#~ "Crash during advtrains main step - skipping the shutdown save operation "
+#~ "to not save inconsistent data!"
+#~ msgstr ""
+#~ "Crash durant le pas principal d'advtrains - saut de l'opération de "
+#~ "sauvegarde de terminaison pour éviter l'enregistrement de données "
+#~ "corrompues !"
+
+#~ msgid "Current FC: "
+#~ msgstr "Code de fret courant: "
+
+#~ msgid "Danger (halt)"
+#~ msgstr "Danger (stop)"
+
+#~ msgid ""
+#~ "Data is being saved. While saving, advtrains will remove the players from "
+#~ "trains. Save files will be reloaded afterwards!"
+#~ msgstr ""
+#~ "Données en cours de sauvegarde. Durant cette phase, advtrains débarquera "
+#~ "les joueurs des trains. Les fichiers de sauvegarde seront ultérieurement "
+#~ "rechargés !"
+
+#~ msgid "Default Seat"
+#~ msgstr "Siège par défaut"
+
+#~ msgid "Default Seat (driver stand)"
+#~ msgstr "Siège par défaut (poste de pilotage)"
+
+# Routage est il le bon terme ?
+#~ msgid "Delete all train routes, force them to recalculate"
+#~ msgstr "Suppression et recalcul de tous les routages"
+
+#~ msgid "Dep. Speed"
+#~ msgstr "Vit. de départ"
+
+#~ msgid "Deprecated Track"
+#~ msgstr "Voie déconseillée"
+
+#~ msgid ""
+#~ "Destroying wagon with inventory, but inventory is not found? Shouldn't "
+#~ "happen!"
+#~ msgstr "Desctruction d'un wagon avec inventaire introuvable ? Anomalie !"
+
+#~ msgid ""
+#~ "Detach all players, especially the offline ones, from all trains. Use "
+#~ "only when no one serious is on a train."
+#~ msgstr ""
+#~ "Débarque tous les joueurs, en particulier ceux déconnectés, de tous les "
+#~ "trains. À n'utiliser que quand aucun joueur sérieux n'a embarqué."
+
+#~ msgid "Detailed Steam Engine"
+#~ msgstr "Locomotive à vapeur complexe"
+
+#~ msgid "Detector Rail"
+#~ msgstr "Voie détectrice"
+
+#~ msgid "Diagonal Diamond Crossing Track"
+#~ msgstr "Croisement diagonal"
+
+#~ msgid "Digiline channel"
+#~ msgstr "Canal Digiline"
+
+#~ msgid "Disable the advtrains globalstep temporarily"
+#~ msgstr "Désactive temporairement le pas global d'advtrains"
+
+#~ msgid "Disabled advtrains successfully"
+#~ msgstr "Succès de la désactivation d'advtrains"
+
+#~ msgid "Door Delay"
+#~ msgstr "Durée d'ouverture des portes"
+
+#~ msgid "Doors are closed! (Try holding sneak key!)"
+#~ msgstr "Portes closes : (Essayez la \"sneak key\"!\")"
+
+#~ msgid ""
+#~ "Doors are closed. Use Sneak+rightclick to ignore the closed doors and get "
+#~ "off."
+#~ msgstr ""
+#~ "Portes closes ! Utilisez \"Marcher lentement (Sneak)\" et Clic-Droit pour "
+#~ "franchir les portes et débarquer."
+
+#~ msgid "Driver Stand"
+#~ msgstr "Poste de pilotage"
+
+#~ msgid "Driver Stand (left)"
+#~ msgstr "Poste de pilotage (gauche)"
+
+#~ msgid "Driver Stand (right)"
+#~ msgstr "Poste de pilotage (droit)"
+
+#~ msgid "Driver stand"
+#~ msgstr "Poste de pilotage"
+
+#~ msgid "Driver's cab"
+#~ msgstr "Cabine de pilotage"
+
+#~ msgid "Freight Code:"
+#~ msgstr "Code de frêt :"
+
+#~ msgid "Get off"
+#~ msgstr "Débarquer"
+
+#~ msgid "Get off (forced)"
+#~ msgstr "Débarquer (de force)"
+
+#~ msgid "Industrial Train Engine"
+#~ msgstr "Locomotive industrielle"
+
+#~ msgid "Industrial tank wagon"
+#~ msgstr "Wagon-citerne industriel"
+
+#~ msgid "Industrial wood wagon"
+#~ msgstr "Wagon grumier industriel"
+
+#~ msgid "Instructed to save() but load() was never called!"
+#~ msgstr "Appel de save() requis sans appel préalable de load() !"
+
+#~ msgid "Japanese Train Engine"
+#~ msgstr "Motrice Japonaise"
+
+#~ msgid "Japanese Train Inter-Wagon Connection"
+#~ msgstr "Passage inter-voiture de train Japonais"
+
+#~ msgid "Japanese Train Wagon"
+#~ msgstr "Voiture Japonaise"
+
+#~ msgid "Japanese signal pole"
+#~ msgstr "Voiture Japonaise"
+
+#~ msgid "Lampless Signal"
+#~ msgstr "Sémaphore"
+
+#~ msgid "Left"
+#~ msgstr "Gauche"
+
+#~ msgid "Left,Right,Closed;"
+#~ msgstr "Gauche,Droit,Fermé;"
+
+#~ msgid "Liquid: "
+#~ msgstr "Liquide : "
+
+#~ msgid "Liquid: empty"
+#~ msgstr "Liquide : vide"
+
+#~ msgid "Lock couples"
+#~ msgstr "Verrouiller l'accouplement"
+
+#~ msgid "LuaATC Environment"
+#~ msgstr "Environnement LuaATC"
+
+#~ msgid "LuaATC Mesecon Controller"
+#~ msgstr "Commande Mesecon de LuaATC"
+
+#~ msgid "LuaATC Operation Panel"
+#~ msgstr "Panneau de commande de LuaATC"
+
+#~ msgid "LuaATC component assigned to an invalid environment"
+#~ msgstr "Composant LuaATC assigné à un environnement invalide"
+
+#~ msgid "LuaATC component assigned to environment '@1'"
+#~ msgstr "Composant LuaATC assigné à l'environnement '@1'"
+
+#~ msgid "LuaATC component with error: @1"
+#~ msgstr "Erreur @1 du composant LuaATC"
+
+#~ msgid "Missing train_operator privilege"
+#~ msgstr "Privilège \"train_operator\" manquant"
+
+#~ msgid "Munich U-Bahn Distant Signal ("
+#~ msgstr "Signal distant métro de Munich ("
+
+#~ msgid "Munich U-Bahn Main Signal ("
+#~ msgstr "Signal principal métro de Munich ("
+
+#~ msgid "Next FC:"
+#~ msgstr "Code de fret suivant :"
+
+#~ msgid "No callback to handle schedule"
+#~ msgstr "Absence de fonction de gestion de planning"
+
+#~ msgid "No such lua entity."
+#~ msgstr "Pas de telle entité lua."
+
+#~ msgid "No such wagon: @1."
+#~ msgstr "Pas de tel wagon : @1."
+
+#~ msgid "Not a valid wagon id."
+#~ msgstr "Identificateur de wagon invalide."
+
+#~ msgid "Not allowed to do this."
+#~ msgstr "Vous n'êtes pas autorisé effectuer ceci."
+
+#~ msgid ""
+#~ "OVERRUN RED SIGNAL! Examine situation and reverse train to move again."
+#~ msgstr ""
+#~ "Franchissement de signal rouge : examinez la situation et inversez le "
+#~ "sens de marche du train."
+
+#~ msgid "Onboard Computer"
+#~ msgstr "Ordinateur embarqué"
+
+#~ msgid "Passenger Wagon"
+#~ msgstr "Voiture passager"
+
+#~ msgid "Passenger area"
+#~ msgstr "Voiture Passager"
+
+#~ msgid ""
+#~ "Passive Component Naming Tool\n"
+#~ "\n"
+#~ "Right-click to name a passive component."
+#~ msgstr ""
+#~ "Outil de nommage de composant passif\n"
+#~ "\n"
+#~ "Clic-Droit pour nommer un composant passif."
+
+#~ msgid "Perpendicular Diamond Crossing Track"
+#~ msgstr "Croisement perpendiculaire"
+
+#~ msgid "Please specify a player name to transfer ownership to."
+#~ msgstr ""
+#~ "Spécifiez le nom du joueur à qui la propriété doit être transférée, SVP."
+
+#~ msgid "Point Speed Restriction Track"
+#~ msgstr "Voie de point de limitation de vitesse"
+
+#~ msgid "Point speed restriction: @1"
+#~ msgstr "Point de limitation de vitesse : @1"
+
+#~ msgid "Position is occupied by a train."
+#~ msgstr "Cet emplacement est occupé par un train."
+
+#~ msgid "Prev FC"
+#~ msgstr "Code de fret précédent"
+
+#~ msgid "Print advtrains status info"
+#~ msgstr "Affiche les informations d'état d'advtrains"
+
+#~ msgid "Re-enabling advtrains globalstep..."
+#~ msgstr "Réacivation du pas global d'advtrains..."
+
+#~ msgid "Reduced speed"
+#~ msgstr "Vitesse réduite"
+
+#~ msgid "Reload successful!"
+#~ msgstr "Succès du rechargement !"
+
+#~ msgid "Remote Routesetting"
+#~ msgstr "Routage à distance"
+
+#~ msgid "Removing unused wagon"
+#~ msgstr "Suppression d'un wagon inutilisé"
+
+#~ msgid "Restoring saved state in 1 second..."
+#~ msgstr "Restauration du l'état sauvegardé dans une seconde..."
+
+#~ msgid "Restricted speed"
+#~ msgstr "Vitesse limitée"
+
+#~ msgid "Returns the position of the train with the given id"
+#~ msgstr "Affiche la position du train identifié"
+
+#~ msgid "Routingcode"
+#~ msgstr "Code de routage"
+
+#~ msgid "Save wagon properties"
+#~ msgstr "Sauvegarder les propriétés du wagon"
+
+#~ msgid "Scharfenberg Coupler"
+#~ msgstr "Attelage Scharfenberg"
+
+#~ msgid "Select seat:"
+#~ msgstr "Choisir le siège :"
+
+#~ msgid "Set name of component (empty to clear)"
+#~ msgstr "Nommer le composant (chaîne vide pour effacer)"
+
+#~ msgid "Set point speed restriction:"
+#~ msgstr "Placez un point de limitation de vitesse :"
+
+#~ msgid "Show Inventory"
+#~ msgstr "Montrer le stock"
+
+#~ msgid "Signal"
+#~ msgstr "Signal"
+
+#~ msgid "Steam Engine"
+#~ msgstr "Locomotive à vapeur"
+
+#~ msgid "Subway Passenger Wagon"
+#~ msgstr "Voiture de Métropolitain"
+
+# Routage est il le bon terme ?
+#~ msgid "Successfully invalidated train routes"
+#~ msgstr "Succès d'invalidation des routages des trains"
+
+#~ msgid "Target:"
+#~ msgstr "Destination : "
+
+#~ msgid "Teleporting to train "
+#~ msgstr "Téléportation au train "
+
+#~ msgid "Teleports you to the position of the train with the given id"
+#~ msgstr "Vous téléporte à la position du train identifié"
+
+#~ msgid "Text displayed inside train"
+#~ msgstr "Texte affiché à l'intérieur du train"
+
+#~ msgid "Text displayed outside on train"
+#~ msgstr "Texte affiché à l'extérieur du train"
+
+#~ msgid "That player does not exist!"
+#~ msgstr "Ce joueur n'existe pas !"
+
+#~ msgid "That wagon does not exist!"
+#~ msgstr "Ce wagon n'a pas de siège !"
+
+#~ msgid ""
+#~ "The advtrains globalstep has been disabled. Trains are not moving, and no "
+#~ "data is saved! Run '/at_disable_step no' to enable again!"
+#~ msgstr ""
+#~ "Le pas global d'advtrains est désactivé. Les trains sont immobiles et "
+#~ "aucune donnée n'est sauvegardée. Exécutez '/at_disable_step no ' pour le "
+#~ "réactiver !"
+
+#~ msgid "The clipboard couldn't access the metadata. Copy failed."
+#~ msgstr ""
+#~ "Le presse-papier ne peut accéder aux métadonnées. Échec de la copie."
+
+#~ msgid "The clipboard couldn't access the metadata. Paste failed."
+#~ msgstr "Le presse-papier ne peut accéder aux métadonnées. Échec du collage."
+
+#~ msgid "The clipboard is empty."
+#~ msgstr "Le presse-papier est vide."
+
+#~ msgid "The track you are trying to place the wagon on is not long enough!"
+#~ msgstr ""
+#~ "La voie sur laquelle vous tentez de placer le wagon est trop courte !"
+
+#~ msgid "The track you are trying to place the wagon on is not long enough."
+#~ msgstr ""
+#~ "La voie sur laquelle vous tentez de placer le wagon est trop courte."
+
+#~ msgid "The wagon's inventory is not empty."
+#~ msgstr "Le stock de ce wagon n'est pas vide."
+
+#~ msgid "There's a Signal Influence Point here."
+#~ msgstr "Il y a un \"Signal Influence Point\" ici."
+
+#~ msgid "There's a Track Circuit Break here."
+#~ msgstr "Il y a un \"Track Circuit Break\" ici."
+
+#~ msgid "This Wagon ID"
+#~ msgstr "Identificateur du wagon"
+
+#~ msgid "This node can't be changed using the trackworker!"
+#~ msgstr "Ce nœud ne peut être modifié avec l'outil \"Trackworker\" !"
+
+#~ msgid "This node can't be rotated using the trackworker!"
+#~ msgstr "Ce nœud ne peut être tourné avec l'outil \"Trackworker\" !"
+
+#, fuzzy
+#~ msgid "This node can't be rotated using the trackworker,"
+#~ msgstr "Ce nœud ne peut être tourné avec l'outil \"Trackworker\" !"
+
+#~ msgid "This position is protected!"
+#~ msgstr "Cet emplacement est protégé !"
+
+#~ msgid "This station is owned by @1. You are not allowed to edit its name."
+#~ msgstr ""
+#~ "Cette station est la propriété de @1. Vous n'êtes pas autorisé à modifier "
+#~ "son nom."
+
+#~ msgid "This track can not be changed."
+#~ msgstr "Cette voie ne peut pas être modifiée."
+
+#~ msgid "This track can not be removed!"
+#~ msgstr "Cette voie ne peut pas être enlevée !"
+
+#~ msgid "This track can not be rotated!"
+#~ msgstr "Cette voie ne peut pas être tournée !"
+
+#~ msgid "This wagon has no seats."
+#~ msgstr "Ce wagon n'a pas de siège."
+
+#~ msgid "This wagon is full."
+#~ msgstr "Ce wagon est plein."
+
+#~ msgid "This wagon is owned by @1, you can't destroy it."
+#~ msgstr "Ce wagon est la propriété de @1, vous ne pouvez pas le détruire."
+
+#~ msgid ""
+#~ "Track Worker Tool\n"
+#~ "\n"
+#~ "Left-click: change rail type (straight/curve/switch)\n"
+#~ "Right-click: rotate object"
+#~ msgstr ""
+#~ "Outil \"Trackworker\"\n"
+#~ "\n"
+#~ "Clic-Gauche : change le type de rail (droit/courbé/aiguillage)\n"
+#~ "\n"
+#~ "Clic-Droit : tourne l'objet"
+
+#~ msgid "Train"
+#~ msgstr "Identificateur du train"
+
+#~ msgid "Train "
+#~ msgstr "Identificateur du train "
+
+#~ msgid "Train ID"
+#~ msgstr "Identificateur du train"
+
+#~ msgid "Train copied."
+#~ msgstr "Train copié."
+
+#~ msgid ""
+#~ "Train copy/paste tool\n"
+#~ "\n"
+#~ "Left-click: copy train\n"
+#~ "Right-click: paste train"
+#~ msgstr ""
+#~ "Outil de copie/collage de train\n"
+#~ "\n"
+#~ "Clic-Gauche : copie\n"
+#~ "\n"
+#~ "Clic-Droit : collage"
+
+#~ msgid ""
+#~ "Train overview / coupling control is only shown when the train stands."
+#~ msgstr ""
+#~ "Aperçu du train / commande d'accouplement montré uniquement à l'arrêt du "
+#~ "train."
+
+#~ msgid "Train overview /coupling control:"
+#~ msgstr "Aperçu du train / commande d'accouplement :"
+
+#~ msgid "Trains stopping here (ARS rules)"
+#~ msgstr "Trains marquant l'arrêt (règles ARS)"
+
+#~ msgid "Unable to load wagon type"
+#~ msgstr "Impossible de charger le type du wagon"
+
+#~ msgid "Unconfigured ATC controller"
+#~ msgstr "Controlleur ATC, non-configuré"
+
+#~ msgid "Unconfigured LuaATC component"
+#~ msgstr "Composant LuaATC non configuré"
+
+#~ msgid "Uninitialized init="
+#~ msgstr "Variable init non initialisée"
+
+#~ msgid "Uninitialized, removing"
+#~ msgstr "Non initialisé, retiré"
+
+#~ msgid "Unloading Track"
+#~ msgstr "Voie de Déchargement"
+
+#~ msgid "Use Sneak+rightclick to bypass closed doors!"
+#~ msgstr ""
+#~ "Utilisez \"Marcher lentement (Sneak)\" et Clic-Droit pour franchir les "
+#~ "portes closes !"
+
+#~ msgid "Wagon @1 ownership changed from @2 to @3"
+#~ msgstr "La propriété du wagon @1 a été transférée de @2 à @3"
+
+#~ msgid "Wagon Properties Tool"
+#~ msgstr "Outil de propriété du wagon"
+
+#~ msgid ""
+#~ "Wagon Properties Tool\n"
+#~ "Punch a wagon to view and edit the Wagon Properties"
+#~ msgstr ""
+#~ "Outil de propriété du wagon\n"
+#~ "Frappez un wagon pour voir et modifier ses propriétés"
+
+#~ msgid ""
+#~ "Wagon needs to be decoupled from other wagons in order to destroy it."
+#~ msgstr ""
+#~ "Les wagons doivent être désaccouplés des autres pour pouvoir être "
+#~ "détruits."
+
+#~ msgid "Wagon properties"
+#~ msgstr "Propriétés du wagon"
+
+#~ msgid "Wagon road number:"
+#~ msgstr "Immatriculation du wagon :"
+
+#~ msgid "Wallmounted Signal (left)"
+#~ msgstr "Signal mural (gauche)"
+
+#~ msgid "Wallmounted Signal (right)"
+#~ msgstr "Signal mural (droit)"
+
+#~ msgid "Wallmounted Signal (top)"
+#~ msgstr "Signal mural (plafond)"
+
+#~ msgid ""
+#~ "Warning: If you destroy this wagon, you only get some steel back! If you "
+#~ "are sure, hold Sneak and left-click the wagon."
+#~ msgstr ""
+#~ "Attention: Si vous détruisez ce wagon, vous ne récupérerez que de la "
+#~ "ferraille ! Si vous êtes sûr de vous, appuyez la touche \"Marcher "
+#~ "lentement (Sneak)\" et Clic-Gauche."
+
+#~ msgid "Wheel"
+#~ msgstr "Roue"
+
+#~ msgid "Y-turnout"
+#~ msgstr "Embranchement en Y"
+
+#~ msgid "You are not allowed to access the driver stand."
+#~ msgstr "Accès interdit au poste de pilotage."
+
+#~ msgid "You are not allowed to build near tracks at this protected position."
+#~ msgstr ""
+#~ "Vous ne pouvez pas construire à proximité d'une voie à cet emplacement "
+#~ "protégé."
+
+#~ msgid ""
+#~ "You are not allowed to build near tracks without the track_builder "
+#~ "privilege."
+#~ msgstr ""
+#~ "Vous ne pouvez pas construire à proximité d'une voie sans le privilège "
+#~ "\"track_builder\" (?)"
+
+#~ msgid "You are not allowed to build tracks at this protected position."
+#~ msgstr "Vous ne pouvez pas construire une voie à cet emplacement protégé."
+
+#~ msgid ""
+#~ "You are not allowed to build tracks without the track_builder privilege."
+#~ msgstr ""
+#~ "Vous ne pouvez pas construire une voie sans le privilège "
+#~ "\"track_builder\"."
+
+#~ msgid ""
+#~ "You are not allowed to configure this LuaATC component without the @1 "
+#~ "privilege."
+#~ msgstr "Vous ne pouvez configurer ce composant LuaATC sans le privilege @1."
+
+#~ msgid ""
+#~ "You are not allowed to configure this track without the @1 privilege."
+#~ msgstr ""
+#~ "Vous n'êtes pas autorisé à configurer cette voie sans le privilège @1."
+
+#~ msgid ""
+#~ "You are not allowed to couple trains without the train_operator privilege."
+#~ msgstr ""
+#~ "Vous n'êtes pas autorisé à coupler des trains sans le privilège "
+#~ "\"train_operator\"."
+
+#, fuzzy
+#~ msgid "You are not allowed to modify this protected track."
+#~ msgstr "Vous ne pouvez pas construire une voie à cet emplacement protégé"
+
+#~ msgid ""
+#~ "You are not allowed to name LuaATC passive components without the @1 "
+#~ "privilege."
+#~ msgstr ""
+#~ "Vous ne pouvez nommer un composant LuaATC passif sans le privilege @1."
+
+#~ msgid ""
+#~ "You are not allowed to operate turnouts and signals without the "
+#~ "railway_operator privilege."
+#~ msgstr ""
+#~ "Vous ne pouvez pas actionner les aiguillages ou les signaux (privilège "
+#~ "\"railway_operator\" manquant)"
+
+#~ msgid "You can't get on this wagon."
+#~ msgstr "Montée impossible dans ce wagon."
+
+#~ msgid "You do not have the @1 privilege."
+#~ msgstr "Vous ne possédez pas le privilège \"@1\"."
+
+#~ msgid "You don't have the train_operator privilege."
+#~ msgstr "Vous ne possédez pas le privilège \"train_operator\"."
+
+#~ msgid "You have been given ownership of wagon @1"
+#~ msgstr "La propriété du wagon @1 vous a été transférée"
+
+#~ msgid ""
+#~ "You need to own at least one neighboring wagon to destroy this couple."
+#~ msgstr ""
+#~ "Vous devez être propriétaire d'au moins un wagon voisin pour supprimer "
+#~ "cet attelage."
+
+#~ msgid "from wagon_save table."
+#~ msgstr "de la table wagon_save."
+
+#~ msgid ""
+#~ "had no wagons left because of some bug. It is being deleted. Wave it "
+#~ "goodbye!"
+#~ msgstr ""
+#~ "n'a plus de wagon à cause d'un bug quelconque. Il est détruit. Faites lui "
+#~ "coucou !"
+
+#~ msgid "slowdown"
+#~ msgstr "ralentissement"
diff --git a/advtrains_line_automation/locale/advtrains_line_automation.pot b/advtrains_line_automation/locale/advtrains_line_automation.pot
new file mode 100644
index 0000000..6721651
--- /dev/null
+++ b/advtrains_line_automation/locale/advtrains_line_automation.pot
@@ -0,0 +1,735 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the advtrains_line_automation package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: advtrains_line_automation\n"
+"Report-Msgid-Bugs-To: advtrains-discuss@lists.sr.ht\n"
+"POT-Creation-Date: 2026-04-23 15:18+0800\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: line_editor.lua
+msgid "No such station"
+msgstr ""
+
+#: line_editor.lua
+msgid "Cannot replace, because lineval @1 does not yet exist"
+msgstr ""
+
+#: line_editor.lua
+msgid "@1 trains restarted due to changes"
+msgstr ""
+
+#: line_editor.lua
+msgid "Cannot delete, because lineval @1 does not yet exist"
+msgstr ""
+
+#: line_editor.lua stoprail.lua
+msgid "Line Editor"
+msgstr ""
+
+#: line_editor.lua
+msgid "LINE,ROUTE,VAR."
+msgstr ""
+
+#: line_editor.lua station_editor.lua
+msgid "OWNER"
+msgstr ""
+
+#: line_editor.lua
+msgid "New Line..."
+msgstr ""
+
+#: line_editor.lua
+msgid "Delete Line"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line:"
+msgstr ""
+
+#: line_editor.lua
+msgid "Variant:"
+msgstr ""
+
+#: line_editor.lua
+msgid "Dest. Display:"
+msgstr ""
+
+#: line_editor.lua station_editor.lua
+msgid "Owner:"
+msgstr ""
+
+#: line_editor.lua
+msgid "Disable"
+msgstr ""
+
+#: line_editor.lua
+msgid "Continues:"
+msgstr ""
+
+#: line_editor.lua
+msgid "Last passages"
+msgstr ""
+
+#: line_editor.lua
+msgid "Save changes"
+msgstr ""
+
+#: line_editor.lua
+msgid "Verify/Save"
+msgstr ""
+
+#: line_editor.lua
+msgid "Reset changes"
+msgstr ""
+
+#: line_editor.lua
+msgid "Dep."
+msgstr ""
+
+#: line_editor.lua
+msgid "St.Time"
+msgstr ""
+
+#: line_editor.lua stoprail.lua
+msgid "Station Code"
+msgstr ""
+
+#: line_editor.lua
+msgid "Mode"
+msgstr ""
+
+#: line_editor.lua station_editor.lua stoprail.lua
+msgid "Track"
+msgstr ""
+
+#: line_editor.lua
+msgid "Position"
+msgstr ""
+
+#: line_editor.lua
+msgid "Hidden (normal)"
+msgstr ""
+
+#: line_editor.lua
+msgid "Normal"
+msgstr ""
+
+#: line_editor.lua
+msgid "Hidden"
+msgstr ""
+
+#: line_editor.lua
+msgid "Inactive"
+msgstr ""
+
+#: line_editor.lua
+msgid "Request Stop (experimental)"
+msgstr ""
+
+#: line_editor.lua line_functions.lua
+msgid "Terminus"
+msgstr ""
+
+#: line_editor.lua
+msgid "Terminus (hidden)"
+msgstr ""
+
+#: line_editor.lua
+msgid "Terminus (continuing)"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line name must not be empty!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line name must not contain characters '/', '|' or '\\'!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line name must not exceed 256 characters!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Starting station code must not be empty!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Routing code must not contain '/', '|' or '\\'!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line owner must not be empty!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Train name must not exceed 256 characters!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Field 'Continuation' must contain maximum 1 '/'!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Incorrect departure time format!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Departure time must lie within 0-3600 seconds!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Duplicate departure time!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Unknown station code!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Station code must not contain '/', '|' or '\\'!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line name must not exceed 16 characters!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Incorrect format for stop position!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Stop position must not exceed 22 characters!"
+msgstr ""
+
+#: line_editor.lua
+msgid "@1 errors while checking line setup!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line setup must contain at least 1 terminus stop!"
+msgstr ""
+
+#: line_editor.lua
+msgid "No issues found, the line can now be saved!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Error in line setup: "
+msgstr ""
+
+#: line_editor.lua
+msgid "Unknown reason"
+msgstr ""
+
+#: line_editor.lua
+msgid "Insufficient permissions to edit '@1'."
+msgstr ""
+
+#: line_editor.lua
+msgid "Line '@1' successfully saved!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line '@1' successfully deleted!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Deletion failed: "
+msgstr ""
+
+#: line_editor.lua
+msgid "Last passages of line @1"
+msgstr ""
+
+#: line_editor.lua
+msgid "Code"
+msgstr ""
+
+#: line_editor.lua
+msgid "Station"
+msgstr ""
+
+#: line_editor.lua
+msgid "At start station:"
+msgstr ""
+
+#: line_editor.lua
+msgid "(departed)"
+msgstr ""
+
+#: line_editor.lua
+msgid "Travelling:"
+msgstr ""
+
+#: line_editor.lua
+msgid "Update"
+msgstr ""
+
+#: line_editor.lua
+msgid "Back"
+msgstr ""
+
+#: line_editor.lua
+msgid "Open line editor"
+msgstr ""
+
+#: line_functions.lua
+msgid "Next Stop: "
+msgstr ""
+
+#: line_functions.lua
+msgid " (on request)"
+msgstr ""
+
+#: line_functions.lua
+msgid "Unknown Station"
+msgstr ""
+
+#: line_functions.lua
+msgid "Next Stop:"
+msgstr ""
+
+#: line_functions.lua
+msgid "Next stop: "
+msgstr ""
+
+#: station_editor.lua
+msgid "[Station Editor]"
+msgstr ""
+
+#: station_editor.lua
+msgid "By Distance"
+msgstr ""
+
+#: station_editor.lua
+msgid "Station Code (A-Z)"
+msgstr ""
+
+#: station_editor.lua
+msgid "Station Name (A-Z)"
+msgstr ""
+
+#: station_editor.lua
+msgid "My Stations (Station Code A-Z)"
+msgstr ""
+
+#: station_editor.lua
+msgid "My Stations (Station Name A-Z)"
+msgstr ""
+
+#: station_editor.lua
+msgid "My Stations (By Distance)"
+msgstr ""
+
+#: station_editor.lua stoprail.lua
+msgid "Station Editor"
+msgstr ""
+
+#: station_editor.lua
+msgid "CODE"
+msgstr ""
+
+#: station_editor.lua
+msgid "DISTANCE"
+msgstr ""
+
+#: station_editor.lua
+msgid "INFO"
+msgstr ""
+
+#: station_editor.lua
+msgid "NAME"
+msgstr ""
+
+#: station_editor.lua
+msgid "@1 tracks"
+msgstr ""
+
+#: station_editor.lua
+msgid "lines"
+msgstr ""
+
+#: station_editor.lua
+msgid "Code:"
+msgstr ""
+
+#: station_editor.lua
+msgid "Name:"
+msgstr ""
+
+#: station_editor.lua
+msgid "Create New"
+msgstr ""
+
+#: station_editor.lua
+msgid "Timetables..."
+msgstr ""
+
+#: station_editor.lua
+msgid "Save Changes"
+msgstr ""
+
+#: station_editor.lua
+msgid "Delete"
+msgstr ""
+
+#: station_editor.lua
+msgid "Assign Track"
+msgstr ""
+
+#: station_editor.lua
+msgid "Lines"
+msgstr ""
+
+#: station_editor.lua
+msgid "Assign"
+msgstr ""
+
+#: station_editor.lua
+msgid "Positions of tracks:"
+msgstr ""
+
+#: station_editor.lua
+msgid "ERROR: Code must not be empty!"
+msgstr ""
+
+#: station_editor.lua
+msgid "ERROR: Station '@1' already exists!"
+msgstr ""
+
+#: station_editor.lua
+msgid "Station successfully created."
+msgstr ""
+
+#: station_editor.lua
+msgid "ERROR: No such station!"
+msgstr ""
+
+#: station_editor.lua
+msgid "Nothing has changed."
+msgstr ""
+
+#: station_editor.lua
+msgid "Owner changed!"
+msgstr ""
+
+#: station_editor.lua
+msgid "Name changed!"
+msgstr ""
+
+#: station_editor.lua
+msgid "Code changed, @1 station tracks updated!"
+msgstr ""
+
+#: station_editor.lua
+msgid "ERROR: No stop selected!"
+msgstr ""
+
+#: station_editor.lua
+msgid "ERROR: There are station tracks assigned, cannot delete the station!"
+msgstr ""
+
+#: station_editor.lua
+msgid "Station deleted!"
+msgstr ""
+
+#: station_editor.lua
+msgid "Track successfully assigned!"
+msgstr ""
+
+#: station_editor.lua
+msgid "Open station editor"
+msgstr ""
+
+#: station_editor.lua
+msgid "(select station)"
+msgstr ""
+
+#: station_editor.lua
+msgid "in operation"
+msgstr ""
+
+#: station_editor.lua
+msgid "unknown state"
+msgstr ""
+
+#: station_editor.lua
+msgid "No departures for the selected line found in the near future"
+msgstr ""
+
+#: station_editor.lua
+msgid "next departures of the selected line in: "
+msgstr ""
+
+#: station_editor.lua
+msgid "Timetables"
+msgstr ""
+
+#: station_editor.lua
+msgid "(all platforms)"
+msgstr ""
+
+#: station_editor.lua
+msgid "Timetables (all lines)"
+msgstr ""
+
+#: station_editor.lua
+msgid "Timetables: "
+msgstr ""
+
+#: station_editor.lua
+msgid "Owner: "
+msgstr ""
+
+#: station_editor.lua
+msgid "Station Operator: "
+msgstr ""
+
+#: station_editor.lua
+msgid "Set"
+msgstr ""
+
+#: station_editor.lua
+msgid "Timetable for current station (all lines)"
+msgstr ""
+
+#: station_editor.lua
+msgid "Update next departures..."
+msgstr ""
+
+#: stoprail.lua
+msgid "Stn. @1 (@2) T. @3"
+msgstr ""
+
+#: stoprail.lua
+msgid "(unassigned)"
+msgstr ""
+
+#: stoprail.lua
+msgid "(foreign)"
+msgstr ""
+
+#: stoprail.lua
+msgid "You are not allowed to configure this track."
+msgstr ""
+
+#: stoprail.lua
+msgid "Station Name"
+msgstr ""
+
+#: stoprail.lua
+msgid "Track number, for informational purposes"
+msgstr ""
+
+#: stoprail.lua
+msgid "Selector for stop pos (ARS)"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Only trains matching these ARS rules will consider this stop rail as "
+"suitable timing point/stop position.\n"
+"Affects both timetabled and non-timetabled trains.\n"
+"Example: define a stop position for long trains (TL 30) and another for "
+"short trains (TL 0-30)."
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Non-timetabled trains matching these ARS rules will stop at this position.\n"
+"Note: Train must also match the 'Selector' filter above!"
+msgstr ""
+
+#: stoprail.lua
+msgid "Selector for stop position..."
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Use when multiple stop rails are located in the same track of a station. "
+"Allows to select a suitable stop position depending on the class of train."
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Non-timetabled trains matching these ARS rules will stop at this position.\n"
+"Trains under timetable will use the timetable's settings."
+msgstr ""
+
+#: stoprail.lua
+msgid "Stopping trains (ARS)"
+msgstr ""
+
+#: stoprail.lua
+msgid "Stop Time"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Train will remain stopped with open doors for at least this time before "
+"departure is attempted."
+msgstr ""
+
+#: stoprail.lua
+msgid "Door Side"
+msgstr ""
+
+#: stoprail.lua
+msgid "closed"
+msgstr ""
+
+#: stoprail.lua
+msgid "left"
+msgstr ""
+
+#: stoprail.lua
+msgid "right"
+msgstr ""
+
+#: stoprail.lua
+msgid "Select if and on which side the train will open its doors once stopped"
+msgstr ""
+
+#: stoprail.lua
+msgid "Reverse train"
+msgstr ""
+
+#: stoprail.lua
+msgid "Train will depart in the direction from where it arrived"
+msgstr ""
+
+#: stoprail.lua
+msgid "Kick out passengers"
+msgstr ""
+
+#: stoprail.lua
+msgid "Keep ARS enabled"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Do not disable ARS on approaching. Signals behind the stop rail already set "
+"ARS routes when the train arrives, not just before departure. (currently not "
+"implemented)"
+msgstr ""
+
+#: stoprail.lua
+msgid "Arrival Actions"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"List of actions to perform on arrival (currently not implemented, later will "
+"allow actions such as setting line, RC and displays)"
+msgstr ""
+
+#: stoprail.lua
+msgid "Speed"
+msgstr ""
+
+#: stoprail.lua
+msgid "Speed that the train sets when departing. Set 'M' for maximum speed."
+msgstr ""
+
+#: stoprail.lua
+msgid "Departure Mode"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Select the time for departure:\n"
+"Normal: depart immediately after the stop time elapsed\n"
+"Interval: depart at the next time position set by interval and offset\n"
+"Begin Timetable: The train gets the given timetable assigned and departs "
+"according to its settings (currently not implemented)"
+msgstr ""
+
+#: stoprail.lua
+msgid "Interval:"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"The interval / time distance between departures in seconds. E.g. every two "
+"minutes -> set interval = 120"
+msgstr ""
+
+#: stoprail.lua
+msgid "Offset:"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"The offset of departures from time 0:00 in seconds. E.g. interval 120 offset "
+"60 -> departure at every odd minute"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"No linevars\n"
+"available!"
+msgstr ""
+
+#: stoprail.lua
+msgid "Keep doors open"
+msgstr ""
+
+#: stoprail.lua
+msgid "Do not close the doors when departing, if they are open"
+msgstr ""
+
+#: stoprail.lua
+msgid "Wait for signal to clear"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Do not depart immediately, instead first enable ARS and wait until the next "
+"signal ahead clears (ATC G command) before closing the doors and departing."
+msgstr ""
+
+#: stoprail.lua
+msgid "Departure Actions"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"List of actions to perform on departure (currently not implemented, later "
+"will allow actions such as setting line, RC and displays)"
+msgstr ""
+
+#: stoprail.lua
+msgid "Save"
+msgstr ""
+
+#: stoprail.lua
+msgid "Station code '@1' does already exist and is owned by @2"
+msgstr ""
+
+#: stoprail.lua
+msgid "Station/Stop Track"
+msgstr ""
+
+#: time_table.lua
+msgid "Timetable"
+msgstr ""
+
+#: time_table.lua
+msgid "Timetable (owner: @1)"
+msgstr ""
+
+#: time_table.lua
+msgid "Timetable (on pole)"
+msgstr ""
diff --git a/advtrains_line_automation/locale/advtrains_line_automation.zh_CN.po b/advtrains_line_automation/locale/advtrains_line_automation.zh_CN.po
new file mode 100644
index 0000000..bc9e9ee
--- /dev/null
+++ b/advtrains_line_automation/locale/advtrains_line_automation.zh_CN.po
@@ -0,0 +1,1193 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: advtrains\n"
+"Report-Msgid-Bugs-To: advtrains-discuss@lists.sr.ht\n"
+"POT-Creation-Date: 2026-03-22 17:25+0100\n"
+"PO-Revision-Date: 2023-10-09 11:24+0200\n"
+"Last-Translator: Y. Wang <yw05@forksworld.de>\n"
+"Language-Team: Chinese (Simplified)\n"
+"Language: zh_CN\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 3.3.2\n"
+
+#: line_editor.lua
+msgid "(departed)"
+msgstr ""
+
+#: line_editor.lua
+msgid "@1 errors while checking line setup!"
+msgstr ""
+
+#: line_editor.lua
+msgid "@1 trains restarted due to changes"
+msgstr ""
+
+#: line_editor.lua
+msgid "At start station:"
+msgstr ""
+
+#: line_editor.lua
+msgid "Back"
+msgstr ""
+
+#: line_editor.lua
+msgid "Cannot delete, because lineval @1 does not yet exist"
+msgstr ""
+
+#: line_editor.lua
+msgid "Cannot replace, because lineval @1 does not yet exist"
+msgstr ""
+
+#: line_editor.lua
+msgid "Code"
+msgstr ""
+
+#: line_editor.lua
+msgid "Continues:"
+msgstr ""
+
+#: line_editor.lua
+msgid "Delete Line"
+msgstr ""
+
+#: line_editor.lua
+msgid "Deletion failed: "
+msgstr ""
+
+#: line_editor.lua
+msgid "Dep."
+msgstr ""
+
+#: line_editor.lua
+msgid "Departure time must lie within 0-3600 seconds!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Dest. Display:"
+msgstr ""
+
+#: line_editor.lua
+msgid "Disable"
+msgstr ""
+
+#: line_editor.lua
+msgid "Duplicate departure time!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Error in line setup: "
+msgstr ""
+
+#: line_editor.lua
+msgid "Field 'Continuation' must contain maximum 1 '/'!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Hidden"
+msgstr ""
+
+#: line_editor.lua
+msgid "Hidden (normal)"
+msgstr ""
+
+#: line_editor.lua
+msgid "Inactive"
+msgstr ""
+
+#: line_editor.lua
+msgid "Incorrect departure time format!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Incorrect format for stop position!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Insufficient permissions to edit '@1'."
+msgstr ""
+
+#: line_editor.lua
+msgid "LINE,ROUTE,VAR."
+msgstr ""
+
+#: line_editor.lua
+msgid "Last passages"
+msgstr ""
+
+#: line_editor.lua
+msgid "Last passages of line @1"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line '@1' successfully deleted!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line '@1' successfully saved!"
+msgstr ""
+
+#: line_editor.lua stoprail.lua
+msgid "Line Editor"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line name must not be empty!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line name must not contain characters '/', '|' or '\\'!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line name must not exceed 16 characters!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line name must not exceed 256 characters!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line owner must not be empty!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line setup must contain at least 1 terminus stop!"
+msgstr ""
+
+#: line_editor.lua
+#, fuzzy
+msgid "Line:"
+msgstr "火车线路"
+
+#: line_editor.lua
+msgid "Mode"
+msgstr ""
+
+#: line_editor.lua
+msgid "New Line..."
+msgstr ""
+
+#: line_editor.lua
+msgid "No issues found, the line can now be saved!"
+msgstr ""
+
+#: line_editor.lua
+#, fuzzy
+msgid "No such station"
+msgstr "ID 为“@1”的列车不存在。"
+
+#: line_editor.lua
+msgid "Normal"
+msgstr ""
+
+#: line_editor.lua station_editor.lua
+msgid "OWNER"
+msgstr ""
+
+#: line_editor.lua
+msgid "Open line editor"
+msgstr ""
+
+#: line_editor.lua station_editor.lua
+msgid "Owner:"
+msgstr ""
+
+#: line_editor.lua
+msgid "Position"
+msgstr ""
+
+#: line_editor.lua
+msgid "Request Stop (experimental)"
+msgstr ""
+
+#: line_editor.lua
+msgid "Reset changes"
+msgstr ""
+
+#: line_editor.lua
+msgid "Routing code must not contain '/', '|' or '\\'!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Save changes"
+msgstr ""
+
+#: line_editor.lua
+#, fuzzy
+msgid "St.Time"
+msgstr "停站时间"
+
+#: line_editor.lua
+msgid "Starting station code must not be empty!"
+msgstr ""
+
+#: line_editor.lua
+#, fuzzy
+msgid "Station"
+msgstr "车站代码"
+
+#: line_editor.lua stoprail.lua
+msgid "Station Code"
+msgstr "车站代码"
+
+#: line_editor.lua
+msgid "Station code must not contain '/', '|' or '\\'!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Stop position must not exceed 22 characters!"
+msgstr ""
+
+#: line_editor.lua line_functions.lua
+msgid "Terminus"
+msgstr ""
+
+#: line_editor.lua
+msgid "Terminus (continuing)"
+msgstr ""
+
+#: line_editor.lua
+msgid "Terminus (hidden)"
+msgstr ""
+
+#: line_editor.lua station_editor.lua stoprail.lua
+msgid "Track"
+msgstr "轨道"
+
+#: line_editor.lua
+msgid "Train name must not exceed 256 characters!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Travelling:"
+msgstr ""
+
+#: line_editor.lua
+msgid "Unknown reason"
+msgstr ""
+
+#: line_editor.lua
+#, fuzzy
+msgid "Unknown station code!"
+msgstr "车站代码"
+
+#: line_editor.lua
+msgid "Update"
+msgstr ""
+
+#: line_editor.lua
+msgid "Variant:"
+msgstr ""
+
+#: line_editor.lua
+msgid "Verify/Save"
+msgstr ""
+
+#: line_functions.lua
+msgid " (on request)"
+msgstr ""
+
+#: line_functions.lua
+msgid "Next Stop:"
+msgstr ""
+
+#: line_functions.lua
+msgid "Next Stop: "
+msgstr ""
+
+#: line_functions.lua
+msgid "Next stop: "
+msgstr ""
+
+#: line_functions.lua
+msgid "Unknown Station"
+msgstr ""
+
+#: station_editor.lua
+msgid "(all platforms)"
+msgstr ""
+
+#: station_editor.lua
+#, fuzzy
+msgid "(select station)"
+msgstr "ID 为“@1”的列车不存在。"
+
+#: station_editor.lua
+msgid "@1 tracks"
+msgstr ""
+
+#: station_editor.lua
+msgid "Assign"
+msgstr ""
+
+#: station_editor.lua
+#, fuzzy
+msgid "Assign Track"
+msgstr "装货轨道"
+
+#: station_editor.lua
+msgid "By Distance"
+msgstr ""
+
+#: station_editor.lua
+msgid "CODE"
+msgstr ""
+
+#: station_editor.lua
+msgid "Code changed, @1 station tracks updated!"
+msgstr ""
+
+#: station_editor.lua
+msgid "Code:"
+msgstr ""
+
+#: station_editor.lua
+msgid "Create New"
+msgstr ""
+
+#: station_editor.lua
+msgid "DISTANCE"
+msgstr ""
+
+#: station_editor.lua
+msgid "Delete"
+msgstr ""
+
+#: station_editor.lua
+msgid "ERROR: Code must not be empty!"
+msgstr ""
+
+#: station_editor.lua
+msgid "ERROR: No stop selected!"
+msgstr ""
+
+#: station_editor.lua
+msgid "ERROR: No such station!"
+msgstr ""
+
+#: station_editor.lua
+msgid "ERROR: Station '@1' already exists!"
+msgstr ""
+
+#: station_editor.lua
+msgid "ERROR: There are station tracks assigned, cannot delete the station!"
+msgstr ""
+
+#: station_editor.lua
+msgid "INFO"
+msgstr ""
+
+#: station_editor.lua
+#, fuzzy
+msgid "Lines"
+msgstr "火车线路"
+
+#: station_editor.lua
+msgid "My Stations (By Distance)"
+msgstr ""
+
+#: station_editor.lua
+msgid "My Stations (Station Code A-Z)"
+msgstr ""
+
+#: station_editor.lua
+msgid "My Stations (Station Name A-Z)"
+msgstr ""
+
+#: station_editor.lua
+msgid "NAME"
+msgstr ""
+
+#: station_editor.lua
+msgid "Name changed!"
+msgstr ""
+
+#: station_editor.lua
+msgid "Name:"
+msgstr ""
+
+#: station_editor.lua
+msgid "No departures for the selected line found in the near future"
+msgstr ""
+
+#: station_editor.lua
+msgid "Nothing has changed."
+msgstr ""
+
+#: station_editor.lua
+msgid "Open station editor"
+msgstr ""
+
+#: station_editor.lua
+msgid "Owner changed!"
+msgstr ""
+
+#: station_editor.lua
+msgid "Owner: "
+msgstr ""
+
+#: station_editor.lua
+msgid "Positions of tracks:"
+msgstr ""
+
+#: station_editor.lua
+msgid "Save Changes"
+msgstr ""
+
+#: station_editor.lua
+msgid "Set"
+msgstr ""
+
+#: station_editor.lua
+#, fuzzy
+msgid "Station Code (A-Z)"
+msgstr "车站代码"
+
+#: station_editor.lua stoprail.lua
+#, fuzzy
+msgid "Station Editor"
+msgstr "车站代码"
+
+#: station_editor.lua
+#, fuzzy
+msgid "Station Name (A-Z)"
+msgstr "车站名称"
+
+#: station_editor.lua
+#, fuzzy
+msgid "Station Operator: "
+msgstr "车站代码"
+
+#: station_editor.lua
+#, fuzzy
+msgid "Station deleted!"
+msgstr "车站代码"
+
+#: station_editor.lua
+msgid "Station successfully created."
+msgstr ""
+
+#: station_editor.lua
+msgid "Timetable for current station (all lines)"
+msgstr ""
+
+#: station_editor.lua
+msgid "Timetables"
+msgstr ""
+
+#: station_editor.lua
+msgid "Timetables (all lines)"
+msgstr ""
+
+#: station_editor.lua
+msgid "Timetables..."
+msgstr ""
+
+#: station_editor.lua
+msgid "Timetables: "
+msgstr ""
+
+#: station_editor.lua
+msgid "Track successfully assigned!"
+msgstr ""
+
+#: station_editor.lua
+msgid "Update next departures..."
+msgstr ""
+
+#: station_editor.lua
+#, fuzzy
+msgid "[Station Editor]"
+msgstr "车站代码"
+
+#: station_editor.lua
+msgid "in operation"
+msgstr ""
+
+#: station_editor.lua
+msgid "lines"
+msgstr ""
+
+#: station_editor.lua
+msgid "next departures of the selected line in: "
+msgstr ""
+
+#: station_editor.lua
+#, fuzzy
+msgid "unknown state"
+msgstr "车站代码"
+
+#: stoprail.lua
+msgid "(foreign)"
+msgstr ""
+
+#: stoprail.lua
+msgid "(unassigned)"
+msgstr ""
+
+#: stoprail.lua
+msgid "Arrival Actions"
+msgstr ""
+
+#: stoprail.lua
+msgid "Departure Actions"
+msgstr ""
+
+#: stoprail.lua
+msgid "Departure Mode"
+msgstr ""
+
+#: stoprail.lua
+msgid "Do not close the doors when departing, if they are open"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Do not depart immediately, instead first enable ARS and wait until the next "
+"signal ahead clears (ATC G command) before closing the doors and departing."
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Do not disable ARS on approaching. Signals behind the stop rail already set "
+"ARS routes when the train arrives, not just before departure. (currently not "
+"implemented)"
+msgstr ""
+
+#: stoprail.lua
+msgid "Door Side"
+msgstr ""
+
+#: stoprail.lua
+msgid "Interval:"
+msgstr ""
+
+#: stoprail.lua
+msgid "Keep ARS enabled"
+msgstr ""
+
+#: stoprail.lua
+msgid "Keep doors open"
+msgstr ""
+
+#: stoprail.lua
+msgid "Kick out passengers"
+msgstr "踢出乘客"
+
+#: stoprail.lua
+msgid ""
+"List of actions to perform on arrival (currently not implemented, later will "
+"allow actions such as setting line, RC and displays)"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"List of actions to perform on departure (currently not implemented, later "
+"will allow actions such as setting line, RC and displays)"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"No linevars\n"
+"available!"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Non-timetabled trains matching these ARS rules will stop at this position.\n"
+"Note: Train must also match the 'Selector' filter above!"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Non-timetabled trains matching these ARS rules will stop at this position.\n"
+"Trains under timetable will use the timetable's settings."
+msgstr ""
+
+#: stoprail.lua
+msgid "Offset:"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Only trains matching these ARS rules will consider this stop rail as "
+"suitable timing point/stop position.\n"
+"Affects both timetabled and non-timetabled trains.\n"
+"Example: define a stop position for long trains (TL 30) and another for "
+"short trains (TL 0-30)."
+msgstr ""
+
+#: stoprail.lua
+msgid "Reverse train"
+msgstr "改变行车方向"
+
+#: stoprail.lua
+msgid "Save"
+msgstr "保存"
+
+#: stoprail.lua
+msgid "Select if and on which side the train will open its doors once stopped"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Select the time for departure:\n"
+"Normal: depart immediately after the stop time elapsed\n"
+"Interval: depart at the next time position set by interval and offset\n"
+"Begin Timetable: The train gets the given timetable assigned and departs "
+"according to its settings (currently not implemented)"
+msgstr ""
+
+#: stoprail.lua
+msgid "Selector for stop pos (ARS)"
+msgstr ""
+
+#: stoprail.lua
+msgid "Selector for stop position..."
+msgstr ""
+
+#: stoprail.lua
+#, fuzzy
+msgid "Speed"
+msgstr "速度"
+
+#: stoprail.lua
+msgid "Speed that the train sets when departing. Set 'M' for maximum speed."
+msgstr ""
+
+#: stoprail.lua
+msgid "Station Name"
+msgstr "车站名称"
+
+#: stoprail.lua
+msgid "Station code '@1' does already exist and is owned by @2"
+msgstr ""
+
+#: stoprail.lua
+msgid "Station/Stop Track"
+msgstr "车站轨道"
+
+#: stoprail.lua
+msgid "Stn. @1 (@2) T. @3"
+msgstr ""
+
+#: stoprail.lua
+msgid "Stop Time"
+msgstr "停站时间"
+
+#: stoprail.lua
+msgid "Stopping trains (ARS)"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"The interval / time distance between departures in seconds. E.g. every two "
+"minutes -> set interval = 120"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"The offset of departures from time 0:00 in seconds. E.g. interval 120 offset "
+"60 -> departure at every odd minute"
+msgstr ""
+
+#: stoprail.lua
+msgid "Track number, for informational purposes"
+msgstr ""
+
+#: stoprail.lua
+msgid "Train will depart in the direction from where it arrived"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Train will remain stopped with open doors for at least this time before "
+"departure is attempted."
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Use when multiple stop rails are located in the same track of a station. "
+"Allows to select a suitable stop position depending on the class of train."
+msgstr ""
+
+#: stoprail.lua
+msgid "Wait for signal to clear"
+msgstr ""
+
+#: stoprail.lua
+msgid "You are not allowed to configure this track."
+msgstr "您不能调整这段轨道。"
+
+#: stoprail.lua
+#, fuzzy
+msgid "closed"
+msgstr "(车门已关闭)"
+
+#: stoprail.lua
+msgid "left"
+msgstr ""
+
+#: stoprail.lua
+msgid "right"
+msgstr ""
+
+#: time_table.lua
+msgid "Timetable"
+msgstr ""
+
+#: time_table.lua
+msgid "Timetable (on pole)"
+msgstr ""
+
+#: time_table.lua
+msgid "Timetable (owner: @1)"
+msgstr ""
+
+#~ msgid "3-way turnout"
+#~ msgstr "三开道岔"
+
+#~ msgid "90+Angle Diamond Crossing Track"
+#~ msgstr "交叉轨道 (其中一条轨道与坐标轴平行)"
+
+#~ msgid "<No coupler>"
+#~ msgstr "<没有车钩>"
+
+#~ msgid "@1 Platform (45 degree)"
+#~ msgstr "较高的@1站台 (45°)"
+
+#~ msgid "@1 Platform (high)"
+#~ msgstr "较高的@1站台"
+
+#~ msgid "@1 Platform (low)"
+#~ msgstr "较低的@1站台"
+
+#~ msgid "@1 Platform (low, 45 degree)"
+#~ msgstr "较低的@1站台 (45°)"
+
+#~ msgid "@1 Slope"
+#~ msgstr "@1斜坡"
+
+#~ msgid "ATC Kick command warning: doors are closed."
+#~ msgstr "ATC 警告:车门已关闭,无法踢出乘客。"
+
+#~ msgid "ATC Kick command warning: train moving."
+#~ msgstr "ATC 警告:火车正在移动,无法踢出乘客。"
+
+#~ msgid "ATC Reverse command warning: didn't reverse train, train moving."
+#~ msgstr "ATC 警告:火车正在移动,无法改变行车方向。"
+
+#~ msgid "ATC command parse error: Unknown command: @1"
+#~ msgstr "ATC 语法错误:未知命令:@1"
+
+#~ msgid "ATC command syntax error: I statement not closed: @1"
+#~ msgstr "ATC 语法错误:“I”命令不完整:@1"
+
+#~ msgid "ATC controller"
+#~ msgstr "ATC 控制器"
+
+#~ msgid ""
+#~ "ATC controller, mode @1\n"
+#~ "Channel: @2"
+#~ msgstr ""
+#~ "ATC 控制器\n"
+#~ "模式:@1\n"
+#~ "频道:@2"
+
+#~ msgid ""
+#~ "ATC controller, mode @1\n"
+#~ "Command: @2"
+#~ msgstr ""
+#~ "ATC 控制器\n"
+#~ "模式:@1\n"
+#~ "命令:@2"
+
+#~ msgid "Access to @1"
+#~ msgstr "可前往@1"
+
+#~ msgid "Andrew's Cross"
+#~ msgstr "铁路道口信号灯"
+
+#~ msgid "Back of train would end up off track, cancelling."
+#~ msgstr "火车后部不在轨道上。"
+
+#~ msgid "Big Industrial Train Engine"
+#~ msgstr "大型工业用火车头"
+
+#~ msgid "Boiler"
+#~ msgstr "锅炉"
+
+#~ msgid "Box Wagon"
+#~ msgstr "货运车厢"
+
+#~ msgid "Buffer and Chain Coupler"
+#~ msgstr "链式车钩"
+
+#~ msgid "Bumper"
+#~ msgstr "保险杠"
+
+#~ msgid "Can not couple: The couplers of the trains do not match (@1 and @2)."
+#~ msgstr "您无法连接这两节车厢:这两节车厢使用不同的车钩 (@1和@2)。"
+
+#~ msgid "Can't get on: wagon full or doors closed!"
+#~ msgstr "无法上车:车门已关闭或车厢已满。"
+
+#, fuzzy
+#~ msgid "Can't place: Not enough slope items left (@1 required)"
+#~ msgstr "无法放置斜坡:您没有足够的铁路斜坡放置工具 (您总共需要@1个)"
+
+#, fuzzy
+#~ msgid "Can't place: There's no slope of length @1"
+#~ msgstr "无法放置斜坡:advtrains 不支持长度为@1米的斜坡。"
+
+#, fuzzy
+#~ msgid "Can't place: no supporting node at upper end."
+#~ msgstr "无法放置斜坡:较高端没有支撑方块。"
+
+#, fuzzy
+#~ msgid "Can't place: not pointing at node"
+#~ msgstr "无法放置斜坡:您没有选择任何方块。"
+
+#~ msgid "Can't place: protected position!"
+#~ msgstr "无法放置:此区域已被保护。"
+
+#, fuzzy
+#~ msgid "Can't place: space occupied!"
+#~ msgstr "无法放置斜坡:此区域已被占用。"
+
+#~ msgid "Chimney"
+#~ msgstr "烟囱"
+
+#~ msgid "Command"
+#~ msgstr "命令"
+
+#~ msgid "Command (on)"
+#~ msgstr "命令 (激活时)"
+
+#~ msgid "Default Seat"
+#~ msgstr "默认座位"
+
+#~ msgid "Default Seat (driver stand)"
+#~ msgstr "默认座位 (司机座位)"
+
+#~ msgid "Dep. Speed"
+#~ msgstr "出发速度"
+
+#~ msgid "Deprecated Track"
+#~ msgstr "请不要使用"
+
+#~ msgid "Detailed Steam Engine"
+#~ msgstr "精细的蒸汽机车"
+
+#~ msgid "Detector Rail"
+#~ msgstr "探测轨道"
+
+#~ msgid "Diagonal Diamond Crossing Track"
+#~ msgstr "交叉轨道"
+
+#~ msgid "Digiline channel"
+#~ msgstr "Digiline 频道"
+
+#~ msgid "Door Delay"
+#~ msgstr "车门关闭时间"
+
+#~ msgid ""
+#~ "Doors are closed. Use Sneak+rightclick to ignore the closed doors and get "
+#~ "off."
+#~ msgstr "车门已关闭,请使用潜行+右键单击下车。"
+
+#, fuzzy
+#~ msgid "Driver Stand"
+#~ msgstr "司机座位"
+
+#~ msgid "Driver Stand (left)"
+#~ msgstr "左侧司机座位"
+
+#~ msgid "Driver Stand (right)"
+#~ msgstr "右侧司机座位"
+
+#~ msgid "Driver stand"
+#~ msgstr "司机座位"
+
+#~ msgid "Driver's cab"
+#~ msgstr "驾驶室"
+
+#~ msgid "Get off"
+#~ msgstr "下车"
+
+#~ msgid "Get off (forced)"
+#~ msgstr "强制下车"
+
+#~ msgid "Industrial Train Engine"
+#~ msgstr "工业用火车头"
+
+#~ msgid "Industrial tank wagon"
+#~ msgstr "液体运输车厢"
+
+#~ msgid "Industrial wood wagon"
+#~ msgstr "木材运输车厢"
+
+#~ msgid "Japanese Train Engine"
+#~ msgstr "高速列车车头"
+
+#~ msgid "Japanese Train Inter-Wagon Connection"
+#~ msgstr "日本火车车钩"
+
+#~ msgid "Japanese Train Wagon"
+#~ msgstr "高速列车车厢"
+
+#, fuzzy
+#~ msgid "Japanese signal pole"
+#~ msgstr "高速列车车厢"
+
+#~ msgid "Lampless Signal"
+#~ msgstr "臂板信号机"
+
+#~ msgid "Lock couples"
+#~ msgstr "锁定连接处"
+
+#~ msgid "No such lua entity."
+#~ msgstr "您没有指向一个可以用火车复制工具复制的物体。"
+
+#~ msgid "No such wagon: @1."
+#~ msgstr "ID 为“@1”的车厢不存在。"
+
+#, fuzzy
+#~ msgid "Not allowed to do this."
+#~ msgstr "您不能调整这段轨道。"
+
+#~ msgid "Passenger Wagon"
+#~ msgstr "客车"
+
+#, fuzzy
+#~ msgid "Passenger area"
+#~ msgstr "客车"
+
+#~ msgid ""
+#~ "Passive Component Naming Tool\n"
+#~ "\n"
+#~ "Right-click to name a passive component."
+#~ msgstr ""
+#~ "被动元件命名工具\n"
+#~ "\n"
+#~ "右键单击命名所选元件。"
+
+#~ msgid "Perpendicular Diamond Crossing Track"
+#~ msgstr "垂直交叉轨道"
+
+#~ msgid "Routingcode"
+#~ msgstr "路由码"
+
+#~ msgid "Save wagon properties"
+#~ msgstr "保存车厢属性"
+
+#~ msgid "Scharfenberg Coupler"
+#~ msgstr "Scharfenberg 式车钩"
+
+#~ msgid "Select seat:"
+#~ msgstr "请选择座位:"
+
+#~ msgid "Show Inventory"
+#~ msgstr "显示物品栏"
+
+#~ msgid "Signal"
+#~ msgstr "信号灯"
+
+#~ msgid "Steam Engine"
+#~ msgstr "蒸汽机车"
+
+#~ msgid "Subway Passenger Wagon"
+#~ msgstr "地铁车厢"
+
+#~ msgid "Target:"
+#~ msgstr "目标速度"
+
+#~ msgid "Text displayed inside train"
+#~ msgstr "车厢内部显示"
+
+#~ msgid "Text displayed outside on train"
+#~ msgstr "车厢外部显示"
+
+#, fuzzy
+#~ msgid "That wagon does not exist!"
+#~ msgstr "这节车厢没有座位。"
+
+#~ msgid "The clipboard couldn't access the metadata. Copy failed."
+#~ msgstr "无法复制:剪贴板无法访问元数据。"
+
+#~ msgid "The clipboard couldn't access the metadata. Paste failed."
+#~ msgstr "无法粘贴:剪贴板无法访问元数据。"
+
+#~ msgid "The clipboard is empty."
+#~ msgstr "剪贴板是空的。"
+
+#, fuzzy
+#~ msgid "The track you are trying to place the wagon on is not long enough!"
+#~ msgstr "轨道太短。"
+
+#~ msgid "The track you are trying to place the wagon on is not long enough."
+#~ msgstr "轨道太短。"
+
+#, fuzzy
+#~ msgid "This Wagon ID"
+#~ msgstr "车厢已满。"
+
+#, fuzzy
+#~ msgid "This node can't be changed using the trackworker!"
+#~ msgstr "您不能使用铁路调整工具调整这个方块。"
+
+#, fuzzy
+#~ msgid "This node can't be rotated using the trackworker!"
+#~ msgstr "您不能使用铁路调整工具旋转这个方块。"
+
+#, fuzzy
+#~ msgid "This node can't be rotated using the trackworker,"
+#~ msgstr "您不能使用铁路调整工具旋转这个方块。"
+
+#~ msgid "This position is protected!"
+#~ msgstr "这里已被保护。"
+
+#~ msgid "This track can not be changed."
+#~ msgstr "您不能调整这段轨道。"
+
+#, fuzzy
+#~ msgid "This track can not be removed!"
+#~ msgstr "您不能移除这段轨道。"
+
+#, fuzzy
+#~ msgid "This track can not be rotated!"
+#~ msgstr "您不能旋转这段轨道。"
+
+#~ msgid "This wagon has no seats."
+#~ msgstr "这节车厢没有座位。"
+
+#~ msgid "This wagon is full."
+#~ msgstr "车厢已满。"
+
+#~ msgid "This wagon is owned by @1, you can't destroy it."
+#~ msgstr "这是 @1 的车厢,您不能摧毁它。"
+
+#~ msgid ""
+#~ "Track Worker Tool\n"
+#~ "\n"
+#~ "Left-click: change rail type (straight/curve/switch)\n"
+#~ "Right-click: rotate object"
+#~ msgstr ""
+#~ "铁路调整工具\n"
+#~ "\n"
+#~ "左键单击:切换轨道类型\n"
+#~ "右键单击:旋转方块"
+
+#, fuzzy
+#~ msgid "Train "
+#~ msgstr "已复制列车。"
+
+#~ msgid "Train copied."
+#~ msgstr "已复制列车。"
+
+#~ msgid ""
+#~ "Train copy/paste tool\n"
+#~ "\n"
+#~ "Left-click: copy train\n"
+#~ "Right-click: paste train"
+#~ msgstr ""
+#~ "火车复制工具\n"
+#~ "\n"
+#~ "左键单击:复制\n"
+#~ "右键单击:粘帖"
+
+#~ msgid "Unconfigured ATC controller"
+#~ msgstr "ATC 控制器 (未配置)"
+
+#~ msgid "Unconfigured LuaATC component"
+#~ msgstr "LuaATC 部件 (未配置)"
+
+#~ msgid "Unloading Track"
+#~ msgstr "卸货轨道"
+
+#~ msgid "Use Sneak+rightclick to bypass closed doors!"
+#~ msgstr "请使用潜行+右键上车。"
+
+#, fuzzy
+#~ msgid "Wagon Properties Tool"
+#~ msgstr "车厢属性"
+
+#~ msgid "Wagon properties"
+#~ msgstr "车厢属性"
+
+#~ msgid "Wallmounted Signal (left)"
+#~ msgstr "壁挂式信号灯 (左侧)"
+
+#~ msgid "Wallmounted Signal (right)"
+#~ msgstr "壁挂式信号灯 (右侧)"
+
+#~ msgid "Wallmounted Signal (top)"
+#~ msgstr "悬挂式信号灯"
+
+#~ msgid ""
+#~ "Warning: If you destroy this wagon, you only get some steel back! If you "
+#~ "are sure, hold Sneak and left-click the wagon."
+#~ msgstr ""
+#~ "警告:如果您摧毁此车厢,您只能拿到一些钢方块。如果您确定要摧毁这节车厢,请"
+#~ "按潜行键并左键单击此车厢。"
+
+#~ msgid "Wheel"
+#~ msgstr "车轮"
+
+#~ msgid "Y-turnout"
+#~ msgstr "对称道岔"
+
+#~ msgid "You are not allowed to build near tracks at this protected position."
+#~ msgstr "这里已被保护,您不能在这里的铁路附近建任何东西。"
+
+#~ msgid ""
+#~ "You are not allowed to build near tracks without the track_builder "
+#~ "privilege."
+#~ msgstr "您没有“train_operator”权限,不能在铁路附近建任何东西。"
+
+#~ msgid "You are not allowed to build tracks at this protected position."
+#~ msgstr "这里已被保护,您不能在这里建造铁路。"
+
+#~ msgid ""
+#~ "You are not allowed to build tracks without the track_builder privilege."
+#~ msgstr "您没有“train_operator”权限,不能在这里建造铁路。"
+
+#~ msgid ""
+#~ "You are not allowed to configure this LuaATC component without the @1 "
+#~ "privilege."
+#~ msgstr "您没有“@1”权限,不能配置这个 LuaATC 部件。"
+
+#~ msgid ""
+#~ "You are not allowed to configure this track without the @1 privilege."
+#~ msgstr "您没有“@1”权限,不能调整这段轨道。"
+
+#~ msgid ""
+#~ "You are not allowed to couple trains without the train_operator privilege."
+#~ msgstr "您没有“train_operator”权限,不能连接这两节车厢。"
+
+#, fuzzy
+#~ msgid "You are not allowed to modify this protected track."
+#~ msgstr "这里已被保护,您不能在这里建造铁路。"
+
+#~ msgid ""
+#~ "You are not allowed to name LuaATC passive components without the @1 "
+#~ "privilege."
+#~ msgstr "您没有“@1”权限,不能命名被动元件。"
+
+#~ msgid ""
+#~ "You are not allowed to operate turnouts and signals without the "
+#~ "railway_operator privilege."
+#~ msgstr "您没有“railway_operator”权限,不能控制铁路设施。"
+
+#~ msgid "You do not have the @1 privilege."
+#~ msgstr "您没有“@1”权限。"
+
+#, fuzzy
+#~ msgid "You don't have the train_operator privilege."
+#~ msgstr "您没有“@1”权限。"
+
+#~ msgid ""
+#~ "You need to own at least one neighboring wagon to destroy this couple."
+#~ msgstr "您必须至少拥有其中一节车厢才能分开这两节车厢。"
diff --git a/advtrains_line_automation/locale/advtrains_line_automation.zh_TW.po b/advtrains_line_automation/locale/advtrains_line_automation.zh_TW.po
new file mode 100644
index 0000000..835b4a1
--- /dev/null
+++ b/advtrains_line_automation/locale/advtrains_line_automation.zh_TW.po
@@ -0,0 +1,1193 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: advtrains\n"
+"Report-Msgid-Bugs-To: advtrains-discuss@lists.sr.ht\n"
+"POT-Creation-Date: 2026-03-22 17:25+0100\n"
+"PO-Revision-Date: 2023-10-09 11:31+0200\n"
+"Last-Translator: Y. Wang <yw05@forksworld.de>\n"
+"Language-Team: Chinese (Traditional)\n"
+"Language: zh_TW\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 3.3.2\n"
+
+#: line_editor.lua
+msgid "(departed)"
+msgstr ""
+
+#: line_editor.lua
+msgid "@1 errors while checking line setup!"
+msgstr ""
+
+#: line_editor.lua
+msgid "@1 trains restarted due to changes"
+msgstr ""
+
+#: line_editor.lua
+msgid "At start station:"
+msgstr ""
+
+#: line_editor.lua
+msgid "Back"
+msgstr ""
+
+#: line_editor.lua
+msgid "Cannot delete, because lineval @1 does not yet exist"
+msgstr ""
+
+#: line_editor.lua
+msgid "Cannot replace, because lineval @1 does not yet exist"
+msgstr ""
+
+#: line_editor.lua
+msgid "Code"
+msgstr ""
+
+#: line_editor.lua
+msgid "Continues:"
+msgstr ""
+
+#: line_editor.lua
+msgid "Delete Line"
+msgstr ""
+
+#: line_editor.lua
+msgid "Deletion failed: "
+msgstr ""
+
+#: line_editor.lua
+msgid "Dep."
+msgstr ""
+
+#: line_editor.lua
+msgid "Departure time must lie within 0-3600 seconds!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Dest. Display:"
+msgstr ""
+
+#: line_editor.lua
+msgid "Disable"
+msgstr ""
+
+#: line_editor.lua
+msgid "Duplicate departure time!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Error in line setup: "
+msgstr ""
+
+#: line_editor.lua
+msgid "Field 'Continuation' must contain maximum 1 '/'!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Hidden"
+msgstr ""
+
+#: line_editor.lua
+msgid "Hidden (normal)"
+msgstr ""
+
+#: line_editor.lua
+msgid "Inactive"
+msgstr ""
+
+#: line_editor.lua
+msgid "Incorrect departure time format!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Incorrect format for stop position!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Insufficient permissions to edit '@1'."
+msgstr ""
+
+#: line_editor.lua
+msgid "LINE,ROUTE,VAR."
+msgstr ""
+
+#: line_editor.lua
+msgid "Last passages"
+msgstr ""
+
+#: line_editor.lua
+msgid "Last passages of line @1"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line '@1' successfully deleted!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line '@1' successfully saved!"
+msgstr ""
+
+#: line_editor.lua stoprail.lua
+msgid "Line Editor"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line name must not be empty!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line name must not contain characters '/', '|' or '\\'!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line name must not exceed 16 characters!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line name must not exceed 256 characters!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line owner must not be empty!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Line setup must contain at least 1 terminus stop!"
+msgstr ""
+
+#: line_editor.lua
+#, fuzzy
+msgid "Line:"
+msgstr "火車線路"
+
+#: line_editor.lua
+msgid "Mode"
+msgstr ""
+
+#: line_editor.lua
+msgid "New Line..."
+msgstr ""
+
+#: line_editor.lua
+msgid "No issues found, the line can now be saved!"
+msgstr ""
+
+#: line_editor.lua
+#, fuzzy
+msgid "No such station"
+msgstr "ID 為「@1」的列車不存在。"
+
+#: line_editor.lua
+msgid "Normal"
+msgstr ""
+
+#: line_editor.lua station_editor.lua
+msgid "OWNER"
+msgstr ""
+
+#: line_editor.lua
+msgid "Open line editor"
+msgstr ""
+
+#: line_editor.lua station_editor.lua
+msgid "Owner:"
+msgstr ""
+
+#: line_editor.lua
+msgid "Position"
+msgstr ""
+
+#: line_editor.lua
+msgid "Request Stop (experimental)"
+msgstr ""
+
+#: line_editor.lua
+msgid "Reset changes"
+msgstr ""
+
+#: line_editor.lua
+msgid "Routing code must not contain '/', '|' or '\\'!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Save changes"
+msgstr ""
+
+#: line_editor.lua
+#, fuzzy
+msgid "St.Time"
+msgstr "停站時間"
+
+#: line_editor.lua
+msgid "Starting station code must not be empty!"
+msgstr ""
+
+#: line_editor.lua
+#, fuzzy
+msgid "Station"
+msgstr "車站碼"
+
+#: line_editor.lua stoprail.lua
+msgid "Station Code"
+msgstr "車站碼"
+
+#: line_editor.lua
+msgid "Station code must not contain '/', '|' or '\\'!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Stop position must not exceed 22 characters!"
+msgstr ""
+
+#: line_editor.lua line_functions.lua
+msgid "Terminus"
+msgstr ""
+
+#: line_editor.lua
+msgid "Terminus (continuing)"
+msgstr ""
+
+#: line_editor.lua
+msgid "Terminus (hidden)"
+msgstr ""
+
+#: line_editor.lua station_editor.lua stoprail.lua
+msgid "Track"
+msgstr "軌道"
+
+#: line_editor.lua
+msgid "Train name must not exceed 256 characters!"
+msgstr ""
+
+#: line_editor.lua
+msgid "Travelling:"
+msgstr ""
+
+#: line_editor.lua
+msgid "Unknown reason"
+msgstr ""
+
+#: line_editor.lua
+#, fuzzy
+msgid "Unknown station code!"
+msgstr "車站碼"
+
+#: line_editor.lua
+msgid "Update"
+msgstr ""
+
+#: line_editor.lua
+msgid "Variant:"
+msgstr ""
+
+#: line_editor.lua
+msgid "Verify/Save"
+msgstr ""
+
+#: line_functions.lua
+msgid " (on request)"
+msgstr ""
+
+#: line_functions.lua
+msgid "Next Stop:"
+msgstr ""
+
+#: line_functions.lua
+msgid "Next Stop: "
+msgstr ""
+
+#: line_functions.lua
+msgid "Next stop: "
+msgstr ""
+
+#: line_functions.lua
+msgid "Unknown Station"
+msgstr ""
+
+#: station_editor.lua
+msgid "(all platforms)"
+msgstr ""
+
+#: station_editor.lua
+#, fuzzy
+msgid "(select station)"
+msgstr "ID 為「@1」的列車不存在。"
+
+#: station_editor.lua
+msgid "@1 tracks"
+msgstr ""
+
+#: station_editor.lua
+msgid "Assign"
+msgstr ""
+
+#: station_editor.lua
+#, fuzzy
+msgid "Assign Track"
+msgstr "裝貨軌道"
+
+#: station_editor.lua
+msgid "By Distance"
+msgstr ""
+
+#: station_editor.lua
+msgid "CODE"
+msgstr ""
+
+#: station_editor.lua
+msgid "Code changed, @1 station tracks updated!"
+msgstr ""
+
+#: station_editor.lua
+msgid "Code:"
+msgstr ""
+
+#: station_editor.lua
+msgid "Create New"
+msgstr ""
+
+#: station_editor.lua
+msgid "DISTANCE"
+msgstr ""
+
+#: station_editor.lua
+msgid "Delete"
+msgstr ""
+
+#: station_editor.lua
+msgid "ERROR: Code must not be empty!"
+msgstr ""
+
+#: station_editor.lua
+msgid "ERROR: No stop selected!"
+msgstr ""
+
+#: station_editor.lua
+msgid "ERROR: No such station!"
+msgstr ""
+
+#: station_editor.lua
+msgid "ERROR: Station '@1' already exists!"
+msgstr ""
+
+#: station_editor.lua
+msgid "ERROR: There are station tracks assigned, cannot delete the station!"
+msgstr ""
+
+#: station_editor.lua
+msgid "INFO"
+msgstr ""
+
+#: station_editor.lua
+#, fuzzy
+msgid "Lines"
+msgstr "火車線路"
+
+#: station_editor.lua
+msgid "My Stations (By Distance)"
+msgstr ""
+
+#: station_editor.lua
+msgid "My Stations (Station Code A-Z)"
+msgstr ""
+
+#: station_editor.lua
+msgid "My Stations (Station Name A-Z)"
+msgstr ""
+
+#: station_editor.lua
+msgid "NAME"
+msgstr ""
+
+#: station_editor.lua
+msgid "Name changed!"
+msgstr ""
+
+#: station_editor.lua
+msgid "Name:"
+msgstr ""
+
+#: station_editor.lua
+msgid "No departures for the selected line found in the near future"
+msgstr ""
+
+#: station_editor.lua
+msgid "Nothing has changed."
+msgstr ""
+
+#: station_editor.lua
+msgid "Open station editor"
+msgstr ""
+
+#: station_editor.lua
+msgid "Owner changed!"
+msgstr ""
+
+#: station_editor.lua
+msgid "Owner: "
+msgstr ""
+
+#: station_editor.lua
+msgid "Positions of tracks:"
+msgstr ""
+
+#: station_editor.lua
+msgid "Save Changes"
+msgstr ""
+
+#: station_editor.lua
+msgid "Set"
+msgstr ""
+
+#: station_editor.lua
+#, fuzzy
+msgid "Station Code (A-Z)"
+msgstr "車站碼"
+
+#: station_editor.lua stoprail.lua
+#, fuzzy
+msgid "Station Editor"
+msgstr "車站碼"
+
+#: station_editor.lua
+#, fuzzy
+msgid "Station Name (A-Z)"
+msgstr "車站名稱"
+
+#: station_editor.lua
+#, fuzzy
+msgid "Station Operator: "
+msgstr "車站碼"
+
+#: station_editor.lua
+#, fuzzy
+msgid "Station deleted!"
+msgstr "車站碼"
+
+#: station_editor.lua
+msgid "Station successfully created."
+msgstr ""
+
+#: station_editor.lua
+msgid "Timetable for current station (all lines)"
+msgstr ""
+
+#: station_editor.lua
+msgid "Timetables"
+msgstr ""
+
+#: station_editor.lua
+msgid "Timetables (all lines)"
+msgstr ""
+
+#: station_editor.lua
+msgid "Timetables..."
+msgstr ""
+
+#: station_editor.lua
+msgid "Timetables: "
+msgstr ""
+
+#: station_editor.lua
+msgid "Track successfully assigned!"
+msgstr ""
+
+#: station_editor.lua
+msgid "Update next departures..."
+msgstr ""
+
+#: station_editor.lua
+#, fuzzy
+msgid "[Station Editor]"
+msgstr "車站碼"
+
+#: station_editor.lua
+msgid "in operation"
+msgstr ""
+
+#: station_editor.lua
+msgid "lines"
+msgstr ""
+
+#: station_editor.lua
+msgid "next departures of the selected line in: "
+msgstr ""
+
+#: station_editor.lua
+#, fuzzy
+msgid "unknown state"
+msgstr "車站碼"
+
+#: stoprail.lua
+msgid "(foreign)"
+msgstr ""
+
+#: stoprail.lua
+msgid "(unassigned)"
+msgstr ""
+
+#: stoprail.lua
+msgid "Arrival Actions"
+msgstr ""
+
+#: stoprail.lua
+msgid "Departure Actions"
+msgstr ""
+
+#: stoprail.lua
+msgid "Departure Mode"
+msgstr ""
+
+#: stoprail.lua
+msgid "Do not close the doors when departing, if they are open"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Do not depart immediately, instead first enable ARS and wait until the next "
+"signal ahead clears (ATC G command) before closing the doors and departing."
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Do not disable ARS on approaching. Signals behind the stop rail already set "
+"ARS routes when the train arrives, not just before departure. (currently not "
+"implemented)"
+msgstr ""
+
+#: stoprail.lua
+msgid "Door Side"
+msgstr ""
+
+#: stoprail.lua
+msgid "Interval:"
+msgstr ""
+
+#: stoprail.lua
+msgid "Keep ARS enabled"
+msgstr ""
+
+#: stoprail.lua
+msgid "Keep doors open"
+msgstr ""
+
+#: stoprail.lua
+msgid "Kick out passengers"
+msgstr "踢出乘客"
+
+#: stoprail.lua
+msgid ""
+"List of actions to perform on arrival (currently not implemented, later will "
+"allow actions such as setting line, RC and displays)"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"List of actions to perform on departure (currently not implemented, later "
+"will allow actions such as setting line, RC and displays)"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"No linevars\n"
+"available!"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Non-timetabled trains matching these ARS rules will stop at this position.\n"
+"Note: Train must also match the 'Selector' filter above!"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Non-timetabled trains matching these ARS rules will stop at this position.\n"
+"Trains under timetable will use the timetable's settings."
+msgstr ""
+
+#: stoprail.lua
+msgid "Offset:"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Only trains matching these ARS rules will consider this stop rail as "
+"suitable timing point/stop position.\n"
+"Affects both timetabled and non-timetabled trains.\n"
+"Example: define a stop position for long trains (TL 30) and another for "
+"short trains (TL 0-30)."
+msgstr ""
+
+#: stoprail.lua
+msgid "Reverse train"
+msgstr "改變行車方向"
+
+#: stoprail.lua
+msgid "Save"
+msgstr "儲存"
+
+#: stoprail.lua
+msgid "Select if and on which side the train will open its doors once stopped"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Select the time for departure:\n"
+"Normal: depart immediately after the stop time elapsed\n"
+"Interval: depart at the next time position set by interval and offset\n"
+"Begin Timetable: The train gets the given timetable assigned and departs "
+"according to its settings (currently not implemented)"
+msgstr ""
+
+#: stoprail.lua
+msgid "Selector for stop pos (ARS)"
+msgstr ""
+
+#: stoprail.lua
+msgid "Selector for stop position..."
+msgstr ""
+
+#: stoprail.lua
+#, fuzzy
+msgid "Speed"
+msgstr "速度"
+
+#: stoprail.lua
+msgid "Speed that the train sets when departing. Set 'M' for maximum speed."
+msgstr ""
+
+#: stoprail.lua
+msgid "Station Name"
+msgstr "車站名稱"
+
+#: stoprail.lua
+msgid "Station code '@1' does already exist and is owned by @2"
+msgstr ""
+
+#: stoprail.lua
+msgid "Station/Stop Track"
+msgstr "車站軌道"
+
+#: stoprail.lua
+msgid "Stn. @1 (@2) T. @3"
+msgstr ""
+
+#: stoprail.lua
+msgid "Stop Time"
+msgstr "停站時間"
+
+#: stoprail.lua
+msgid "Stopping trains (ARS)"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"The interval / time distance between departures in seconds. E.g. every two "
+"minutes -> set interval = 120"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"The offset of departures from time 0:00 in seconds. E.g. interval 120 offset "
+"60 -> departure at every odd minute"
+msgstr ""
+
+#: stoprail.lua
+msgid "Track number, for informational purposes"
+msgstr ""
+
+#: stoprail.lua
+msgid "Train will depart in the direction from where it arrived"
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Train will remain stopped with open doors for at least this time before "
+"departure is attempted."
+msgstr ""
+
+#: stoprail.lua
+msgid ""
+"Use when multiple stop rails are located in the same track of a station. "
+"Allows to select a suitable stop position depending on the class of train."
+msgstr ""
+
+#: stoprail.lua
+msgid "Wait for signal to clear"
+msgstr ""
+
+#: stoprail.lua
+msgid "You are not allowed to configure this track."
+msgstr "您不能調整這段軌道。"
+
+#: stoprail.lua
+#, fuzzy
+msgid "closed"
+msgstr "(車門已關閉)"
+
+#: stoprail.lua
+msgid "left"
+msgstr ""
+
+#: stoprail.lua
+msgid "right"
+msgstr ""
+
+#: time_table.lua
+msgid "Timetable"
+msgstr ""
+
+#: time_table.lua
+msgid "Timetable (on pole)"
+msgstr ""
+
+#: time_table.lua
+msgid "Timetable (owner: @1)"
+msgstr ""
+
+#~ msgid "3-way turnout"
+#~ msgstr "三開道岔"
+
+#~ msgid "90+Angle Diamond Crossing Track"
+#~ msgstr "交叉軌道 (其中一條軌道與座標軸平行)"
+
+#~ msgid "<No coupler>"
+#~ msgstr "<無連結器>"
+
+#~ msgid "@1 Platform (45 degree)"
+#~ msgstr "較高的@1月臺 (45°)"
+
+#~ msgid "@1 Platform (high)"
+#~ msgstr "較高的@1月臺"
+
+#~ msgid "@1 Platform (low)"
+#~ msgstr "較低的@1月臺"
+
+#~ msgid "@1 Platform (low, 45 degree)"
+#~ msgstr "較低的@1月臺 (45°)"
+
+#~ msgid "@1 Slope"
+#~ msgstr "@1斜坡"
+
+#~ msgid "ATC Kick command warning: doors are closed."
+#~ msgstr "ATC 警告:車門已關閉,無法踢出乘客。"
+
+#~ msgid "ATC Kick command warning: train moving."
+#~ msgstr "ATC 警告:火車正在移動,無法踢出乘客。"
+
+#~ msgid "ATC Reverse command warning: didn't reverse train, train moving."
+#~ msgstr "ATC 警告:火車正在移動,無法改變行車方向。"
+
+#~ msgid "ATC command parse error: Unknown command: @1"
+#~ msgstr "ATC 語法錯誤:未知命令:@1"
+
+#~ msgid "ATC command syntax error: I statement not closed: @1"
+#~ msgstr "ATC 語法錯誤:「I」命令不完整:@1"
+
+#~ msgid "ATC controller"
+#~ msgstr "ATC 控制器"
+
+#~ msgid ""
+#~ "ATC controller, mode @1\n"
+#~ "Channel: @2"
+#~ msgstr ""
+#~ "ATC 控制器\n"
+#~ "模式:@1\n"
+#~ "頻道:@2"
+
+#~ msgid ""
+#~ "ATC controller, mode @1\n"
+#~ "Command: @2"
+#~ msgstr ""
+#~ "ATC 控制器\n"
+#~ "模式:@1\n"
+#~ "命令:@2"
+
+#~ msgid "Access to @1"
+#~ msgstr "可前往@1"
+
+#~ msgid "Andrew's Cross"
+#~ msgstr "平交道號誌燈"
+
+#~ msgid "Back of train would end up off track, cancelling."
+#~ msgstr "火車後部不在軌道上。"
+
+#~ msgid "Big Industrial Train Engine"
+#~ msgstr "大型工業用火車頭"
+
+#~ msgid "Boiler"
+#~ msgstr "鍋爐"
+
+#~ msgid "Box Wagon"
+#~ msgstr "貨運車廂"
+
+#~ msgid "Buffer and Chain Coupler"
+#~ msgstr "鏈式連結器"
+
+#~ msgid "Bumper"
+#~ msgstr "保險槓"
+
+#~ msgid "Can not couple: The couplers of the trains do not match (@1 and @2)."
+#~ msgstr "您無法連結這兩節車廂:這兩節車廂使用不同的連結器 (@1和@2)。"
+
+#~ msgid "Can't get on: wagon full or doors closed!"
+#~ msgstr "無法上車:車門已關閉或車廂已滿。"
+
+#, fuzzy
+#~ msgid "Can't place: Not enough slope items left (@1 required)"
+#~ msgstr "無法放置斜坡:您沒有足夠的鐵路斜坡放置工具 (您總共需要@1個)"
+
+#, fuzzy
+#~ msgid "Can't place: There's no slope of length @1"
+#~ msgstr "無法放置斜坡:advtrains 不支援長度為@1米的斜坡。"
+
+#, fuzzy
+#~ msgid "Can't place: no supporting node at upper end."
+#~ msgstr "無法放置斜坡:較高階沒有支撐方塊。"
+
+#, fuzzy
+#~ msgid "Can't place: not pointing at node"
+#~ msgstr "無法放置斜坡:您沒有選擇任何方塊。"
+
+#~ msgid "Can't place: protected position!"
+#~ msgstr "無法放置:此區域已被保護。"
+
+#, fuzzy
+#~ msgid "Can't place: space occupied!"
+#~ msgstr "無法放置斜坡:此區域已被佔用。"
+
+#~ msgid "Chimney"
+#~ msgstr "煙囪"
+
+#~ msgid "Command"
+#~ msgstr "命令"
+
+#~ msgid "Command (on)"
+#~ msgstr "命令 (啟用時)"
+
+#~ msgid "Default Seat"
+#~ msgstr "預設座位"
+
+#~ msgid "Default Seat (driver stand)"
+#~ msgstr "預設座位 (司機座位)"
+
+#~ msgid "Dep. Speed"
+#~ msgstr "出發速度"
+
+#~ msgid "Deprecated Track"
+#~ msgstr "請不要使用"
+
+#~ msgid "Detailed Steam Engine"
+#~ msgstr "精細的蒸汽機車"
+
+#~ msgid "Detector Rail"
+#~ msgstr "探測軌道"
+
+#~ msgid "Diagonal Diamond Crossing Track"
+#~ msgstr "交叉軌道"
+
+#~ msgid "Digiline channel"
+#~ msgstr "Digiline 頻道"
+
+#~ msgid "Door Delay"
+#~ msgstr "車門關閉時間"
+
+#~ msgid ""
+#~ "Doors are closed. Use Sneak+rightclick to ignore the closed doors and get "
+#~ "off."
+#~ msgstr "車門已關閉,請使用潛行+右鍵單擊下車。"
+
+#, fuzzy
+#~ msgid "Driver Stand"
+#~ msgstr "司機座位"
+
+#~ msgid "Driver Stand (left)"
+#~ msgstr "左側司機座位"
+
+#~ msgid "Driver Stand (right)"
+#~ msgstr "右側司機座位"
+
+#~ msgid "Driver stand"
+#~ msgstr "司機座位"
+
+#~ msgid "Driver's cab"
+#~ msgstr "駕駛室"
+
+#~ msgid "Get off"
+#~ msgstr "下車"
+
+#~ msgid "Get off (forced)"
+#~ msgstr "強制下車"
+
+#~ msgid "Industrial Train Engine"
+#~ msgstr "工業用火車頭"
+
+#~ msgid "Industrial tank wagon"
+#~ msgstr "液體運輸車廂"
+
+#~ msgid "Industrial wood wagon"
+#~ msgstr "木材運輸車廂"
+
+#~ msgid "Japanese Train Engine"
+#~ msgstr "高速列車車頭"
+
+#~ msgid "Japanese Train Inter-Wagon Connection"
+#~ msgstr "日本火車連結器"
+
+#~ msgid "Japanese Train Wagon"
+#~ msgstr "高速列車車廂"
+
+#, fuzzy
+#~ msgid "Japanese signal pole"
+#~ msgstr "高速列車車廂"
+
+#~ msgid "Lampless Signal"
+#~ msgstr "臂木式號誌機"
+
+#~ msgid "Lock couples"
+#~ msgstr "鎖定連結處"
+
+#~ msgid "No such lua entity."
+#~ msgstr "您沒有指向一個可以用火車複製工具複製的物體。"
+
+#~ msgid "No such wagon: @1."
+#~ msgstr "ID 為「@1」的車廂不存在。"
+
+#, fuzzy
+#~ msgid "Not allowed to do this."
+#~ msgstr "您不能調整這段軌道。"
+
+#~ msgid "Passenger Wagon"
+#~ msgstr "客車"
+
+#, fuzzy
+#~ msgid "Passenger area"
+#~ msgstr "客車"
+
+#~ msgid ""
+#~ "Passive Component Naming Tool\n"
+#~ "\n"
+#~ "Right-click to name a passive component."
+#~ msgstr ""
+#~ "被動元件命名工具\n"
+#~ "\n"
+#~ "右鍵單擊命名所選元件。"
+
+#~ msgid "Perpendicular Diamond Crossing Track"
+#~ msgstr "垂直交叉軌道"
+
+#~ msgid "Routingcode"
+#~ msgstr "路由碼"
+
+#~ msgid "Save wagon properties"
+#~ msgstr "儲存車廂屬性"
+
+#~ msgid "Scharfenberg Coupler"
+#~ msgstr "Scharfenberg 式連結器"
+
+#~ msgid "Select seat:"
+#~ msgstr "請選擇座位:"
+
+#~ msgid "Show Inventory"
+#~ msgstr "顯示物品欄"
+
+#~ msgid "Signal"
+#~ msgstr "色燈號誌機"
+
+#~ msgid "Steam Engine"
+#~ msgstr "蒸汽機車"
+
+#~ msgid "Subway Passenger Wagon"
+#~ msgstr "地鐵車廂"
+
+#~ msgid "Target:"
+#~ msgstr "目標速度"
+
+#~ msgid "Text displayed inside train"
+#~ msgstr "車廂內部顯示"
+
+#~ msgid "Text displayed outside on train"
+#~ msgstr "車廂外部顯示"
+
+#, fuzzy
+#~ msgid "That wagon does not exist!"
+#~ msgstr "這節車廂沒有座位。"
+
+#~ msgid "The clipboard couldn't access the metadata. Copy failed."
+#~ msgstr "無法複製:剪貼簿無法訪問元資料。"
+
+#~ msgid "The clipboard couldn't access the metadata. Paste failed."
+#~ msgstr "無法貼上:剪貼簿無法訪問元資料。"
+
+#~ msgid "The clipboard is empty."
+#~ msgstr "剪貼簿是空的。"
+
+#, fuzzy
+#~ msgid "The track you are trying to place the wagon on is not long enough!"
+#~ msgstr "軌道太短。"
+
+#~ msgid "The track you are trying to place the wagon on is not long enough."
+#~ msgstr "軌道太短。"
+
+#, fuzzy
+#~ msgid "This Wagon ID"
+#~ msgstr "車廂已滿。"
+
+#, fuzzy
+#~ msgid "This node can't be changed using the trackworker!"
+#~ msgstr "您不能使用鐵路調整工具調整這個方塊。"
+
+#, fuzzy
+#~ msgid "This node can't be rotated using the trackworker!"
+#~ msgstr "您不能使用鐵路調整工具旋轉這個方塊。"
+
+#, fuzzy
+#~ msgid "This node can't be rotated using the trackworker,"
+#~ msgstr "您不能使用鐵路調整工具旋轉這個方塊。"
+
+#~ msgid "This position is protected!"
+#~ msgstr "這裡已被保護。"
+
+#~ msgid "This track can not be changed."
+#~ msgstr "您不能調整這段軌道。"
+
+#, fuzzy
+#~ msgid "This track can not be removed!"
+#~ msgstr "您不能移除這段軌道。"
+
+#, fuzzy
+#~ msgid "This track can not be rotated!"
+#~ msgstr "您不能旋轉這段軌道。"
+
+#~ msgid "This wagon has no seats."
+#~ msgstr "這節車廂沒有座位。"
+
+#~ msgid "This wagon is full."
+#~ msgstr "車廂已滿。"
+
+#~ msgid "This wagon is owned by @1, you can't destroy it."
+#~ msgstr "這是 @1 的車廂,您不能摧毀它。"
+
+#~ msgid ""
+#~ "Track Worker Tool\n"
+#~ "\n"
+#~ "Left-click: change rail type (straight/curve/switch)\n"
+#~ "Right-click: rotate object"
+#~ msgstr ""
+#~ "鐵路調整工具\n"
+#~ "\n"
+#~ "左鍵單擊:切換軌道型別\n"
+#~ "右鍵單擊:旋轉方塊"
+
+#, fuzzy
+#~ msgid "Train "
+#~ msgstr "已複製火車。"
+
+#~ msgid "Train copied."
+#~ msgstr "已複製火車。"
+
+#~ msgid ""
+#~ "Train copy/paste tool\n"
+#~ "\n"
+#~ "Left-click: copy train\n"
+#~ "Right-click: paste train"
+#~ msgstr ""
+#~ "火車複製工具\n"
+#~ "\n"
+#~ "左鍵單擊:複製\n"
+#~ "右鍵單擊:粘帖"
+
+#~ msgid "Unconfigured ATC controller"
+#~ msgstr "ATC 控制器 (未配置)"
+
+#~ msgid "Unconfigured LuaATC component"
+#~ msgstr "LuaATC 元件 (未配置)"
+
+#~ msgid "Unloading Track"
+#~ msgstr "卸貨軌道"
+
+#~ msgid "Use Sneak+rightclick to bypass closed doors!"
+#~ msgstr "請使用潛行+右鍵上車。"
+
+#, fuzzy
+#~ msgid "Wagon Properties Tool"
+#~ msgstr "車廂屬性"
+
+#~ msgid "Wagon properties"
+#~ msgstr "車廂屬性"
+
+#~ msgid "Wallmounted Signal (left)"
+#~ msgstr "壁掛式色燈號誌機 (左側)"
+
+#~ msgid "Wallmounted Signal (right)"
+#~ msgstr "壁掛式色燈號誌機 (右側)"
+
+#~ msgid "Wallmounted Signal (top)"
+#~ msgstr "懸掛式色燈號誌機"
+
+#~ msgid ""
+#~ "Warning: If you destroy this wagon, you only get some steel back! If you "
+#~ "are sure, hold Sneak and left-click the wagon."
+#~ msgstr ""
+#~ "警告:如果您摧毀此車廂,您只能拿到一些鋼方塊。如果您確定要摧毀這節車廂,請"
+#~ "按潛行鍵並左鍵單擊此車廂。"
+
+#~ msgid "Wheel"
+#~ msgstr "車輪"
+
+#~ msgid "Y-turnout"
+#~ msgstr "對稱道岔"
+
+#~ msgid "You are not allowed to build near tracks at this protected position."
+#~ msgstr "這裡已被保護,您不能在這裡的鐵路附近建任何東西。"
+
+#~ msgid ""
+#~ "You are not allowed to build near tracks without the track_builder "
+#~ "privilege."
+#~ msgstr "您沒有「train_operator」許可權,不能在鐵路附近建任何東西。"
+
+#~ msgid "You are not allowed to build tracks at this protected position."
+#~ msgstr "這裡已被保護,您不能在這裡建造鐵路。"
+
+#~ msgid ""
+#~ "You are not allowed to build tracks without the track_builder privilege."
+#~ msgstr "您沒有「train_operator」許可權,不能在這裡建造鐵路。"
+
+#~ msgid ""
+#~ "You are not allowed to configure this LuaATC component without the @1 "
+#~ "privilege."
+#~ msgstr "您沒有「@1」許可權,不能配置這個 LuaATC 元件。"
+
+#~ msgid ""
+#~ "You are not allowed to configure this track without the @1 privilege."
+#~ msgstr "您沒有「@1」許可權,不能調整這段軌道。"
+
+#~ msgid ""
+#~ "You are not allowed to couple trains without the train_operator privilege."
+#~ msgstr "您沒有「train_operator」許可權,不能連結這兩節車廂。"
+
+#, fuzzy
+#~ msgid "You are not allowed to modify this protected track."
+#~ msgstr "這裡已被保護,您不能在這裡建造鐵路。"
+
+#~ msgid ""
+#~ "You are not allowed to name LuaATC passive components without the @1 "
+#~ "privilege."
+#~ msgstr "您沒有「@1」許可權,不能命名這個元件。"
+
+#~ msgid ""
+#~ "You are not allowed to operate turnouts and signals without the "
+#~ "railway_operator privilege."
+#~ msgstr "您沒有「railway_operator」許可權,不能控制鐵路設施。"
+
+#~ msgid "You do not have the @1 privilege."
+#~ msgstr "您沒有「@1」許可權。"
+
+#, fuzzy
+#~ msgid "You don't have the train_operator privilege."
+#~ msgstr "您沒有「@1」許可權。"
+
+#~ msgid ""
+#~ "You need to own at least one neighboring wagon to destroy this couple."
+#~ msgstr "您必須至少擁有其中一節車廂才能分開這兩節車廂。"
diff --git a/advtrains_line_automation/mod.conf b/advtrains_line_automation/mod.conf
index e9851c8..b86d81b 100644
--- a/advtrains_line_automation/mod.conf
+++ b/advtrains_line_automation/mod.conf
@@ -4,4 +4,4 @@ description=Tools for automatic train lines
author=orwell96
depends=advtrains_interlocking
-optional_depends=advtrains_train_track
+optional_depends=default,advtrains_train_track,signs_api,unifieddyes
diff --git a/advtrains_line_automation/models/advtrains_tuber.obj b/advtrains_line_automation/models/advtrains_tuber.obj
new file mode 100644
index 0000000..bd17341
--- /dev/null
+++ b/advtrains_line_automation/models/advtrains_tuber.obj
@@ -0,0 +1,150 @@
+# Blender v2.76 (sub 0) OBJ File: 'dark_tuber.blend'
+# www.blender.org
+g tuber
+v 0.068165 0.171006 0.601066
+v 0.068165 0.328994 0.601066
+v -0.068165 0.328994 0.601066
+v -0.068165 0.171006 0.601066
+v 0.184430 0.065570 0.081152
+v 0.184430 0.434431 0.016861
+v -0.190760 0.430332 0.072541
+v -0.184430 0.065570 0.221249
+v 0.111639 0.137188 0.264378
+v 0.108474 0.360762 0.259011
+v -0.131011 0.350268 0.238021
+v -0.114803 0.135139 0.328379
+v 0.050415 0.195602 0.451854
+v 0.050415 0.304398 0.466035
+v -0.058854 0.298933 0.440372
+v -0.050415 0.195602 0.469734
+v 0.132013 0.116200 0.277490
+v 0.132013 0.383800 0.248250
+v -0.132013 0.383800 0.277490
+v -0.132013 0.116200 0.355945
+v 0.000000 0.171006 0.601066
+v 0.000000 0.019494 0.166419
+v 0.000000 0.118180 0.299225
+v 0.000000 0.184188 0.460794
+v 0.000000 0.091796 0.320542
+v -0.000000 0.328994 0.601066
+v -0.003165 0.478457 0.029481
+v -0.012851 0.373499 0.245669
+v -0.004220 0.313080 0.453203
+v -0.000000 0.408204 0.259046
+v -0.068165 0.250000 0.601066
+v -0.233671 0.247951 0.162114
+v -0.143497 0.241679 0.281741
+v -0.064484 0.247267 0.455053
+v -0.156417 0.250000 0.320542
+v 0.068165 0.250000 0.601066
+v 0.230506 0.250000 0.033787
+v 0.130646 0.250000 0.263154
+v 0.060264 0.250000 0.458944
+v 0.156417 0.250000 0.259046
+vt 1.000000 1.000000
+vt 0.937500 1.000000
+vt 0.875000 1.000000
+vt 0.875000 0.937500
+vt 0.875000 0.875000
+vt 0.937500 0.875000
+vt 1.000000 0.875000
+vt 1.000000 0.937500
+vt 0.750000 1.000000
+vt 0.750000 0.500000
+vt 0.875000 0.500000
+vt 0.625000 0.500000
+vt 0.625000 1.000000
+vt 0.500000 1.000000
+vt 0.500000 0.500000
+vt 0.375000 0.500000
+vt 0.375000 1.000000
+vt 0.250000 1.000000
+vt 0.250000 0.500000
+vt 0.125000 0.500000
+vt 0.125000 1.000000
+vt -0.000000 1.000000
+vt 0.000000 0.500000
+vt 0.875000 -0.000000
+vt 1.000000 0.000000
+vt 1.000000 0.500000
+vt 1.000000 0.750000
+vt 1.000000 0.812500
+vt 0.875000 0.812500
+vt 0.875000 0.750000
+vt 0.937500 0.750000
+vt 0.125000 -0.000000
+vt -0.000000 -0.000000
+vt 0.375000 -0.000000
+vt 0.250000 -0.000000
+vt 0.625000 0.000000
+vt 0.500000 -0.000000
+vt 0.750000 0.000000
+vn 0.000000 -1.000000 -0.000000
+vn 0.764800 0.518100 -0.383000
+vn 0.930800 -0.283500 0.230800
+vn -0.161500 -0.277500 0.947000
+vn -0.905200 -0.416000 -0.086500
+vn -0.072500 -0.254700 -0.964300
+vn 0.010500 0.576200 0.817300
+vn -0.165900 0.384900 -0.907900
+vn -0.905900 0.402100 0.132600
+vn 0.035600 0.997300 -0.063700
+vn -0.087800 -0.403600 -0.910700
+vn -0.956900 -0.283400 -0.062600
+vn -0.099700 -0.205600 0.973500
+vn 0.967500 -0.221400 0.122200
+vn -0.075100 0.278700 -0.957400
+vn -0.923500 0.343200 0.171400
+vn 0.889600 0.387400 -0.241800
+vn 0.065900 0.396300 0.915700
+vn -0.266100 0.364700 0.892300
+vn 0.338400 -0.356100 -0.871000
+vn -0.375700 0.505200 0.776900
+vn 0.166400 -0.230300 -0.958800
+vn 0.235500 0.298600 -0.924900
+vn 0.129200 -0.199200 0.971400
+vn 0.153800 0.447300 -0.881100
+vn 0.220500 -0.269400 0.937500
+vn 0.900900 0.426900 0.078000
+vn -0.953500 -0.254700 0.160900
+vn -0.867100 -0.365900 0.338100
+vn 0.816200 0.577700 0.008700
+vn -0.930700 0.321200 -0.174700
+vn 0.969100 -0.229000 -0.091300
+vn -0.898400 0.371600 -0.234200
+vn 0.942500 -0.300400 -0.146600
+s off
+f 1/1/1 36/2/1 2/3/1 26/4/1 3/5/1 31/6/1 4/7/1 21/8/1
+f 32/3/2 7/9/2 11/10/2 33/11/2
+f 40/12/3 37/13/3 6/14/3 18/15/3
+f 30/16/4 27/17/4 7/18/4 19/19/4
+f 35/20/5 32/21/5 8/22/5 20/23/5
+f 25/11/6 21/24/6 4/25/6 20/26/6
+f 22/21/7 8/22/7 12/23/7 23/20/7
+f 27/13/8 6/14/8 10/15/8 28/12/8
+f 37/17/9 5/18/9 9/19/9 38/16/9
+f 13/27/10 24/28/10 16/7/10 34/6/10 15/5/10 29/29/10 14/30/10 39/31/10
+f 22/3/11 25/11/11 20/26/11 8/1/11
+f 31/32/12 35/20/12 20/23/12 4/33/12
+f 26/34/13 30/16/13 19/19/13 3/35/13
+f 36/36/14 40/12/14 18/15/14 2/37/14
+f 28/12/15 10/15/15 14/37/15 29/36/15
+f 38/16/16 9/19/16 13/35/16 39/34/16
+f 33/11/17 11/10/17 15/38/17 34/24/17
+f 23/20/18 12/23/18 16/33/18 24/32/18
+f 9/19/19 23/20/19 24/32/19 13/35/19
+f 5/9/20 17/10/20 25/11/20 22/3/20
+f 5/18/21 22/21/21 23/20/21 9/19/21
+f 17/10/22 1/38/22 21/24/22 25/11/22
+f 11/10/23 28/12/23 29/36/23 15/38/23
+f 2/37/24 18/15/24 30/16/24 26/34/24
+f 7/9/25 27/13/25 28/12/25 11/10/25
+f 18/15/26 6/14/26 27/17/26 30/16/26
+f 12/26/27 33/11/27 34/24/27 16/25/27
+f 3/35/28 19/19/28 35/20/28 31/32/28
+f 19/19/29 7/18/29 32/21/29 35/20/29
+f 8/1/30 32/3/30 33/11/30 12/26/30
+f 10/15/31 38/16/31 39/34/31 14/37/31
+f 1/38/32 17/10/32 40/12/32 36/36/32
+f 6/14/33 37/17/33 38/16/33 10/15/33
+f 17/10/34 5/9/34 37/13/34 40/12/34
diff --git a/advtrains_line_automation/models/license.txt b/advtrains_line_automation/models/license.txt
new file mode 100644
index 0000000..c76bd96
--- /dev/null
+++ b/advtrains_line_automation/models/license.txt
@@ -0,0 +1,5 @@
+advtrains_tuber.obj
+ Author: Hume2
+ Source: https://gitlab.com/h2mm/underch underch_dark_tuber.obj (Underground Challenge)
+ Modified (rotated, scaled)
+ License: CC0
diff --git a/advtrains_line_automation/railwaytime.lua b/advtrains_line_automation/railwaytime.lua
index 258009e..2667014 100644
--- a/advtrains_line_automation/railwaytime.lua
+++ b/advtrains_line_automation/railwaytime.lua
@@ -5,38 +5,71 @@
-- - Server stops/restarts
-- However, this means that implementing a "timetable" system using the "real time" is not practical. Therefore,
-- we introduce a custom time system, the RWT(Railway Time), which has nothing to do with RLT(Real-Life Time)
--- RWT has a time cycle of 1 hour. This should be sufficient for most train lines that will ever be built in Minetest.
--- A RWT looks like this: 37;25
--- The ; is to distinguish it from a normal RLT (which has colons e.g. 12:34:56). Left number is minutes, right number is seconds.
--- The minimum RWT is 00;00, the maximum is 59;59.
--- It is OK to leave one places out at either end, esp. when writing relative times, such as:
--- 43;3 22;0 2;30 0;10 ;10
--- Those places are then filled with zeroes. Indeed, ";" would be valid for 00;00 .
-
+-- RWT has a time cycle of 1 day. This should be sufficient for most train lines that will ever be built in Minetest.
+-- A RWT looks like this: 14;37;25
+-- The ; is to distinguish it from a normal RLT (which has colons e.g. 12:34:56). Left number is hours, middle number is minutes, right number is seconds.
+-- The minimum RWT is 00;00;00, the maximum is 23;59;59.
-- There is an "adapt mode", which was proposed by gpcf, and results in RWT automatically adapting itself to real-world time.
--- It works by shifting the minute/second after the realtime minute/second, adjusting the cycle value as needed.
+-- It works by shifting the hour/minute/second after the realtime hour/minute/second, adjusting the cycle value as needed.
+--[[
+There is an important distinction between:
--- Using negative times is discouraged. If you need a negative time, you may insert a minus (-) ONLY in the "c" place
+## Time (absolute time) ##
+Represents a time instant.
+It is identified by the 4 values cycle (day), hour, minute and second. These values are never negative.
---[[
-1;23;45 = {
- s=45,
- m=23,
- c=1, -- Cycle(~hour), not displayed most time
-}
+In string form, it is written as C;HH;MM;SS.
+The following short forms are allowed to display a RWT (but they do not uniquely identify a RWT):
+HH;MM;SS
+HH;MM
+It is discouraged to use the string form to store RWTs, the table form or seconds form is better.
+
+In table form:
+{ s=45, m=23, h=12, c=1 }
+
+In seconds form:
+c*24*60*60 + h*60*60 + m*60 + s
-Railway times can exist in 3 forms:
-- as table (see above)
-- as string (like "12;34")
-- as number (of seconds)
+Absolute time wraps around at a boundary of 7 cycles (valid cycle values are 0 to 6). If the difference between instants A and B
+is < 3.5 days, B is considered in the future, otherwise B is considered in the past.
+The RWT functions take this wrapping into account.
-Forms are automagically converted as needed by the converter functions to_*
-To be sure a rwt is in the required form, explicitly use a converter.
+## Interval (relative time) ##
+Represents a difference between times.
+
+It is commonly represented in seconds form as a number of seconds.
+It can be formatted as a string e.g.
+ 90 seconds = "+01;30"
+-90 seconds = "-01;30"
+When converting to a string, a + or - must be prepended.
+When parsing a string it is permissible to leave out the + if it is clear from the context that
+an interval is parsed.
+The meaning of string short forms differ from the time instant case:
+[+-]MM;SS (meaning when interval is parsed FROM a string, and the default when converting to string and HH==0 and C==0)
+[+-]HH;MM;SS (when HH!=0 and C==0)
+[+-]C;HH;MM;SS (when all !=0)
+[+-]HH;MM (permissible only when converting TO a string, to be used when it is displayed alongside an instant e.g. 05;30+00;04)
+
+
+]]--
-]]
local rwt = {}
+local CYCLE = 24*60*60
+local NCYC = 7
+local MODULUS = CYCLE*NCYC
+local MODULUS_H = MODULUS / 2
+
+rwt.CYCLE = CYCLE
+rwt.NCYC = NCYC
+rwt.MODULUS = MODULUS
+
+-- adjust so that it is in range [-MODULUS/2, MODULUS/2)
+local function i_adjust(sec)
+ return ((sec + MODULUS_H) % MODULUS) - MODULUS_H
+end
+
--Time Stamp (Seconds since start of world)
local e_time = 0
local e_has_loaded = false
@@ -62,7 +95,7 @@ local function adapt_real_time()
atlog("[lines][rwt] Skipping",secsfwd,"seconds forward to sync rwt (",rwt.to_string(rwttab),") to real time (",os.date("%H:%M:%S"),")")
- e_time = e_time + secsfwd
+ e_time = (e_time + secsfwd) % MODULUS
end
function rwt.set_time(t)
@@ -87,14 +120,14 @@ function rwt.step(dt)
if setting_rwt_real=="independent" then
-- Regular stepping with dtime
- e_time = e_time + dt
+ e_time = (e_time + dt) % MODULUS
else
-- advance with real-world time
local diff = os.time() - e_last_epoch
e_last_epoch = os.time()
if diff>0 then
- e_time = e_time + diff
+ e_time = (e_time + diff) % MODULUS
end
end
end
@@ -103,17 +136,35 @@ function rwt.now()
return rwt.to_table(e_time)
end
-function rwt.new(c, m, s)
+function rwt.new_t(c, h, m, s)
+ assert(c>=0 and c<7 and c==math.floor(c))
+ assert(h>=0 and h<24 and h==math.floor(h))
+ assert(m>=0 and m<60 and m==math.floor(m))
+ assert(s>=0 and s<60)
return {
c = c or 0,
+ h = h or 0,
m = m or 0,
s = s or 0
}
end
+
+function rwt.new_i(sign, c, h, m, s)
+ assert(math.abs(sign)==1)
+ assert(c>=0 and c<3 and c==math.floor(c)) -- interval may be max. +-3 days to avoid overflow!
+ assert(h>=0 and h<24 and h==math.floor(h))
+ assert(m>=0 and m<60 and m==math.floor(m))
+ assert(s>=0 and s<60)
+
+ return sign * (c*24*60*60 + h*60*60 + m*60 + s)
+end
+
+
function rwt.copy(rwtime)
local rwtimet = rwt.to_table(rwtime)
return {
c = rwtimet.c or 0,
+ h = rwtimet.h or 0,
m = rwtimet.m or 0,
s = rwtimet.s or 0
}
@@ -123,186 +174,276 @@ function rwt.to_table(rwtime)
if type(rwtime) == "table" then
return rwtime
elseif type(rwtime) == "string" then
- return rwt.parse(rwtime)
+ return rwt.parse_t(rwtime)
elseif type(rwtime) == "number" then
local res = {}
local seconds = atfloor(rwtime)
res.s = seconds % 60
local minutes = atfloor(seconds/60)
res.m = minutes % 60
- res.c = atfloor(minutes/60)
+ local hours = atfloor(minutes/60)
+ res.h = hours % 24
+ res.c = atfloor(hours/24)
return res
end
end
-function rwt.to_secs(rwtime, c_over)
+local function intv_to_table(rwintp)
+ if type(rwintp) == "number" then
+ local res = {}
+ local rwint = math.abs(rwintp)
+ if rwint~=0 then
+ res.sign = rwintp/rwint -- 1 or -1
+ else
+ res.sign = 1
+ end
+ local seconds = atfloor(rwint)
+ res.s = seconds % 60
+ local minutes = atfloor(seconds/60)
+ res.m = minutes % 60
+ local hours = atfloor(minutes/60)
+ res.h = hours % 24
+ res.c = atfloor(hours/24)
+ return res
+ else
+ error("intv_to_table needs number")
+ end
+end
+
+-- time instant to seconds
+function rwt.t_sec(rwtime)
local res = rwtime
if type(rwtime) == "string" then
- res = rwt.parse(rwtime)
+ res = rwt.parse_t(rwtime)
elseif type(rwtime) == "number" then
return rwtime
end
if type(res)=="table" then
- return (c_over or res.c)*60*60 + res.m*60 + res.s
+ return res.c*60*60*24 + res.h*60*60 + res.m*60 + res.s
end
end
-function rwt.to_string(rwtime_p, no_cycle)
+-- interval to seconds
+function rwt.i_sec(rwint)
+ if type(rwint) == "string" then
+ return rwt.parse_i(rwint)
+ elseif type(rwint) == "number" then
+ return rwint
+ elseif type(rwint)=="table" then
+ return rwint.sign * (rwint.c*60*60*24 + rwint.h*60*60 + rwint.m*60 + rwint.s)
+ end
+end
+rwt.to_secs = rwt.i_sec -- deprecated alias
+
+-- time to string
+-- fmt:
+-- 0, nil or false: full format C;HH;MM;SS
+-- 1 or true: format HH;MM;SS
+-- 2: format MM;SS
+-- 3: format HH;MM
+function rwt.t_str(rwtime_p, fmt)
local rwtime = rwt.to_table(rwtime_p)
- if rwtime.c~=0 and not no_cycle then
- return string.format("%d;%02d;%02d", rwtime.c, rwtime.m, rwtime.s)
- else
+ if fmt==0 or not fmt then
+ return string.format("%d;%02d;%02d;%02d", rwtime.c, rwtime.h, rwtime.m, rwtime.s)
+ elseif fmt==1 or fmt==true then
+ return string.format("%02d;%02d;%02d", rwtime.h, rwtime.m, rwtime.s)
+ elseif fmt==2 then
return string.format("%02d;%02d", rwtime.m, rwtime.s)
+ elseif fmt==3 then
+ return string.format("%02d;%02d", rwtime.h, rwtime.m)
+ end
+end
+-- compatibility alias
+rwt.to_string = rwt.t_str
+
+-- interval to string
+function rwt.i_str(rwint_p, omit_plus, omit_second)
+ local rwint = intv_to_table(rwint_p)
+ -- sign
+ local sic = rwint.sign==1 and (omit_plus and "" or "+") or "-"
+ -- find out formatting
+ if omit_second then
+ if rwint.c~=0 then
+ return string.format("%s%d;%02d;%02d", sic, rwint.c, rwint.h, rwint.m)
+ else
+ return string.format("%s%02d;%02d", sic, rwint.h, rwint.m)
+ end
+ else
+ if rwint.c~=0 then
+ return string.format("%s%d;%02d;%02d;%02d", sic, rwint.c, rwint.h, rwint.m, rwint.s)
+ elseif rwint.h~=0 then
+ return string.format("%s%02d;%02d;%02d", sic, rwint.h, rwint.m, rwint.s)
+ else
+ return string.format("%s%02d;%02d", sic, rwint.m, rwint.s)
+ end
end
end
---
-local function v_n(str, cpl)
- if not str then return nil end
+local function v_n(str)
if str == "" then
return 0
end
- local n = tonumber(str)
- if not cpl and (n<0 or n>59) then
- return nil
- end
- return n
+ return tonumber(str)
end
+-- parse an interval (the default case - parsing an instant is rare)
function rwt.parse(str)
--atdebug("parse",str)
+ --4-value form
+ local sic, str_c, str_h, str_m, str_s = string.match(str, "^([%-%+]?)(%d?%d?);(%d%d);(%d%d);(%d?%d?)$")
+ if sic and str_c and str_h and str_m and str_s then
+ --atdebug("4v", sic, str_c, str_h, str_m, str_s)
+ local c, h, m, s = v_n(str_c), v_n(str_h), v_n(str_m), v_n(str_s)
+ if c and h and m and s then
+ return rwt.new_i(sic=="-" and -1 or 1, c,h,m,s)
+ end
+ end
--3-value form
- local str_c, str_m, str_s = string.match(str, "^(%-?%d?%d?);(%d%d);(%d?%d?)$")
- if str_c and str_m and str_s then
- --atdebug("3v",str_c, str_m, str_s)
- local c, m, s = v_n(str_c, true), v_n(str_m), v_n(str_s)
- if c and m and s then
- return rwt.new(c,m,s)
+ local sic, str_h, str_m, str_s = string.match(str, "^([%-%+]?)(%d?%d?);(%d%d);(%d?%d?)$")
+ if sic and str_h and str_m and str_s then
+ --atdebug("3v", sic, str_h, str_m, str_s)
+ local c, h, m, s = 0, v_n(str_h), v_n(str_m), v_n(str_s)
+ if c and h and m and s then
+ return rwt.new_i(sic=="-" and -1 or 1, c,h,m,s)
end
end
--2-value form
- local str_m, str_s = string.match(str, "^(%d?%d?);(%d?%d?)$")
- if str_m and str_s then
- --atdebug("2v",str_m, str_s)
- local m, s = v_n(str_m), v_n(str_s)
- if m and s then
- return rwt.new(0,m,s)
+ local sic, str_m, str_s = string.match(str, "^([%-%+]?)(%d?%d?);(%d?%d?)$")
+ if sic and str_m and str_s then
+ --atdebug("2v", sic, str_m, str_s)
+ local c, h, m, s = 0, 0, v_n(str_m), v_n(str_s)
+ if c and h and m and s then
+ return rwt.new_i(sic=="-" and -1 or 1, c,h,m,s)
end
end
end
+rwt.parse_i = rwt.parse
----
-
-function rwt.add(t1, t2)
- local t1s = rwt.to_secs(t1)
- local t2s = rwt.to_secs(t2)
- return rwt.to_table(t1s + t2s)
+-- parse a time instant - only the 4-value form is allowed!
+function rwt.parse_t(str)
+ --atdebug("parse",str)
+ --4-value form
+ local str_c, str_h, str_m, str_s = string.match(str, "^(%d?%d?);(%d%d);(%d%d);(%d?%d?)$")
+ if str_c and str_h and str_m and str_s then
+ --atdebug("4v", str_c, str_h, str_m, str_s)
+ local c, h, m, s = v_n(str_c), v_n(str_h), v_n(str_m), v_n(str_s)
+ if c and h and m and s then
+ return rwt.new_t(c,h,m,s)
+ end
+ end
end
--- How many seconds FROM t1 TO t2
-function rwt.diff(t1, t2)
- local t1s = rwt.to_secs(t1)
- local t2s = rwt.to_secs(t2)
- return t2s - t1s
-end
+---
--- Subtract t2 from t1 (inverted argument order compared to diff())
-function rwt.sub(t1, t2)
- return rwt.to_table(rwt.diff(t2, t1))
+-- add a time and an interval. The result is a time (table form)
+function rwt.add(t1, i)
+ local t1s = rwt.t_sec(t1)
+ local t2s = rwt.i_sec(i)
+ return rwt.to_table( (t1s + t2s) % MODULUS )
end
--- Adjusts t2 by thresh and then returns time from t1 to t2
-function rwt.adj_diff(t1, t2, thresh)
- local newc = rwt.adjust_cycle(t2, thresh, t1)
- local t1s = rwt.to_secs(t1)
- local t2s = rwt.to_secs(t2, newc)
- return t1s - t2s
+-- subtract a time and an interval. The result is a time (table form)
+function rwt.sub(t1, i)
+ local t1s = rwt.t_sec(t1)
+ local t2s = rwt.i_sec(i)
+ return rwt.to_table( (t1s - t2s) % MODULUS )
end
-
--- Threshold values
--- "reftime" is the time to which this is made relative and defaults to now.
-rwt.CA_FUTURE = 60*60 - 1 -- Selected so that time lies at or in the future of reftime (at nearest point in time)
-rwt.CA_FUTURES = 60*60 -- Same, except when times are equal, advances one full cycle
-rwt.CA_PAST = 0 -- Selected so that time lies at or in the past of reftime
-rwt.CA_PASTS = -1 -- Same, except when times are equal, goes back one full cycle
-rwt.CA_CENTER = 30*60 -- If time is within past 30 minutes of reftime, selected as past, else selected as future.
-
--- Adjusts the "cycle" value of a railway time to be in some relation to reftime.
--- Returns new cycle
-function rwt.adjust_cycle(rwtime, reftime_p, thresh)
- local reftime = reftime_p or rwt.now()
-
- local reftimes = rwt.to_secs(reftime)
-
- local rwtimes = rwt.to_secs(rwtime, 0)
- local timeres = reftimes + thresh - rwtimes
- local cycles = atfloor(timeres / (60*60))
-
- return cycles
+-- How many seconds FROM t1 TO t2 (two time instants, result is an interval)
+function rwt.diff(t1, t2)
+ local t1s = rwt.t_sec(t1)
+ local t2s = rwt.t_sec(t2)
+ return i_adjust(t2s - t1s)
end
-function rwt.adjust(rwtime, reftime, thresh)
- local cp = rwt.copy(rwtime)
- cp.c = rwt.adjust_cycle(rwtime, reftime, thresh)
- return cp
+-- Whether t1 is (strictly) after t2
+function rwt.is_after(t1, t2)
+ return rwt.diff(t2,t1) > 0
end
--- Useful for departure times: returns time (in seconds)
--- until the next (adjusted FUTURE) occurence of deptime is reached
--- in this case, rwtime is used as reftime and deptime should lie in the future of rwtime
--- rwtime defaults to NOW
-function rwt.get_time_until(deptime, rwtime_p)
- local rwtime = rwtime_p or rwt.now()
- return rwt.adj_diff(rwtime, deptime, rwt.CA_FUTURE)
+-- Whether t1 is (strictly) before t2
+function rwt.is_before(t1, t2)
+ return rwt.diff(t1,t2) > 0
end
-
-- Helper functions for handling "repeating times" (rpt)
-- Those are generic declarations for time intervals like "every 5 minutes", with an optional offset
--- ( /02;00-00;45 in timetable syntax
+-- Note the following:
+-- - rwtime is a time instant, rpt_interval and rpt_offset are intervals
+-- - repeating times are hard-capped at cycle (24-hour) boundary
+-- - if rpt_interval is given as nil, there is exactly 1 match per cycle and it is at X;00;00;00 + offset ( equals a time-of-day)
+-- - the offset determines where the "reference cycle" starts e.g. if the off=05;00;00 and int=03;45;00, starting from 0;05;00 the times would be
+-- 05;00, 08;45, ..., 20;00, 23;45, 1;03;30, then next cycle starts 1;05;00
+-- - if the cycle is not a multiple of the interval like in the previous example, the very last instance is not considered when it is closer than interval/2 to the cycle boundary
+-- in the example above the distance between 1;03;30 and 1;05;00 is only 90s, which is smaller than interval/2
+-- It is preferred to therefore have a longer interval
+-- and the actual sequence will be ..., 20;00, 23;45, 1;05;00
+
+-- helper func to return a table of {
+-- rwtime_s, rpti_s, rpto_s (rwtime, interval and offset in seconds)
+-- ctime (time into current relative cycle [rpto; rpto+CYCLE) )
+-- rtime (last/next occurence of the rpt (time into cycle))
+-- cycle ( number of relative cycle = cycle no of the current cycle start time)
+-- inst ( instance number within the cycle )
+-- }
+function rwt.rpt_getinfo(rwtime, rpt_interval, rpt_offset, next)
+ if not rpt_interval then rpt_interval = CYCLE end
+ local t = {}
+ t.rwtime = rwt.t_sec(rwtime)
+ t.rpti = rwt.i_sec(rpt_interval)
+ t.rpto = rwt.i_sec(rpt_offset)
+ -- reduce to cycle
+ local trel = (t.rwtime - t.rpto) % MODULUS
+ t.cycle = atfloor(trel / CYCLE)
+ t.ctime = trel % CYCLE -- time into current cycle, offset by the rpt offset
+ t.rtime = t.ctime - (t.ctime % t.rpti) -- last rpt occurence time into cycle
+ if next then
+ -- next requested, cutoff to cycle
+ t.rtime = t.rtime + t.rpti -- next rpt occurence time into cycle
+ if t.rtime > (CYCLE - t.rpti/2) then -- last time cutoff rule, and overflow of cycle
+ t.rtime = CYCLE
+ t.cycle = (t.cycle + 1) % NCYC
+ end
+ else
+ if t.rtime > (CYCLE - t.rpti/2) then -- last time cutoff rule
+ t.rtime = t.rtime - t.rpti
+ end
+ end
+ -- determine instance
+ if t.rtime == CYCLE then -- next rounded up case
+ t.inst = 0
+ else
+ t.inst = atfloor(t.rtime / t.rpti) -- this should be exact, theoretically no need for floor
+ end
+ return t
+end
-- Get the time (in seconds) until the next time this rpt occurs
function rwt.time_to_next_rpt(rwtime, rpt_interval, rpt_offset)
- local rpti_s = rwt.to_secs(rpt_interval)
-
- return (rpti_s - rwt.time_from_last_rpt(rwtime, rpti_s, rpt_offset)) % rpti_s
- -- Modulo is just there to clip a false value of rpti_s to 0
+ local t = rwt.rpt_getinfo(rwtime, rpt_interval, rpt_offset, true)
+ return t.rtime - t.ctime, t.cycle, t.inst
end
-- Get the time (in seconds) since the last time this rpt occured
function rwt.time_from_last_rpt(rwtime, rpt_interval, rpt_offset)
- local rwtime_s = rwt.to_secs(rwtime)
- local rpti_s = rwt.to_secs(rpt_interval)
- local rpto_s = rwt.to_secs(rpt_offset)
-
- return ((rwtime_s - rpto_s) % rpti_s)
+ local t = rwt.rpt_getinfo(rwtime, rpt_interval, rpt_offset, false)
+ return t.ctime - t.rtime, t.cycle, t.inst
end
--- From rwtime, get the next time that is divisible by rpt_interval offset by rpt_offset
+-- From rwtime, get the next time that this rpt matches
function rwt.next_rpt(rwtime, rpt_interval, rpt_offset)
- local rwtime_s = rwt.to_secs(rwtime)
- local rpti_s = rwt.to_secs(rpt_interval)
- local time_from_last = rwt.time_from_last_rpt(rwtime_s, rpti_s, rpt_offset)
-
- local res_s = rwtime_s - time_from_last + rpti_s
-
- return rwt.to_table(res_s)
+ local time_to_next, c, i = rwt.time_to_next_rpt(rwtime, rpt_interval, rpt_offset)
+ return rwt.add(rwtime, time_to_next), c, i
end
--- from rwtime, get the last time that this rpt matched (which is actually just next_rpt - rpt_offset
+-- from rwtime, get the last time that this rpt matched
function rwt.last_rpt(rwtime, rpt_interval, rpt_offset)
- local rwtime_s = rwt.to_sec(rwtime)
- local rpti_s = rwt.to_sec(rpt_interval)
- local time_from_last = rwt.time_from_last_rpt(rwtime, rpt_interval, rpt_offset)
-
- local res_s = rwtime_s - time_from_last
-
- return rwt.to_table(res_s)
+ local time_from_last, c, i = rwt.time_from_last_rpt(rwtime, rpt_interval, rpt_offset)
+ return rwt.sub(rwtime, time_from_last), c, i
end
-
advtrains.lines.rwt = rwt
diff --git a/advtrains_line_automation/scheduler.lua b/advtrains_line_automation/scheduler.lua
index 6025b02..de58b3b 100644
--- a/advtrains_line_automation/scheduler.lua
+++ b/advtrains_line_automation/scheduler.lua
@@ -9,6 +9,15 @@ local sched = {}
local UNITS_THRESH = 10
local MAX_PER_ITER = 10
+local MODULUS = ln.rwt.MODULUS
+local MODULUS_H = MODULUS / 2
+
+-- true if a > b (mod MODULUS)
+local function gt_mod(a, b)
+ local d = a - b -- d>0 -> a>b
+ return ((d + MODULUS_H) % MODULUS) > MODULUS_H
+end
+
local callbacks = {}
-- Register a handler callback to handle scheduler items.
@@ -53,7 +62,7 @@ function sched.run()
local ucn, elem
while cnt <= MAX_PER_ITER do
elem = queue[1]
- if elem and elem.t <= ctime then
+ if elem and not gt_mod(elem.t,ctime) then
table.remove(queue, 1)
if callbacks[elem.e] then
-- run it
@@ -79,7 +88,7 @@ end
-- used to prevent expotentially growing "scheduler bombs"
-- unitlim: Custom override for UNITS_THRESH (see there)
function sched.enqueue(rwtime, handler, evtdata, unitid, unitlim)
- local qtime = ln.rwt.to_secs(rwtime)
+ local qtime = ln.rwt.t_sec(rwtime)
assert(type(handler)=="string")
assert(type(unitid)=="string")
assert(type(unitlim)=="number")
@@ -96,7 +105,7 @@ function sched.enqueue(rwtime, handler, evtdata, unitid, unitlim)
while true do
elem = queue[cnt]
- if not elem or elem.t > qtime then
+ if not elem or gt_mod(elem.t, qtime) then
table.insert(queue, cnt, {
t=qtime,
e=handler,
@@ -111,10 +120,9 @@ function sched.enqueue(rwtime, handler, evtdata, unitid, unitlim)
end
-- See enqueue(). Same meaning, except that rwtime is relative to now.
-function sched.enqueue_in(rwtime, handler, evtdata, unitid, unitlim)
+function sched.enqueue_in(rwint, handler, evtdata, unitid, unitlim)
local ctime = ln.rwt.get_time()
- local rwtime_s = ln.rwt.to_secs(rwtime)
- sched.enqueue(ctime + rwtime_s, handler, evtdata, unitid, unitlim)
+ sched.enqueue(ln.rwt.add(ctime, rwint), handler, evtdata, unitid, unitlim)
end
-- Discards all schedules for unit "unitid" (removes them from the queue)
diff --git a/advtrains_line_automation/station_announcement.lua b/advtrains_line_automation/station_announcement.lua
new file mode 100644
index 0000000..1875962
--- /dev/null
+++ b/advtrains_line_automation/station_announcement.lua
@@ -0,0 +1,1583 @@
+local al = advtrains.lines
+local F = core.formspec_escape
+local ch_core = al.ch_core
+--[[
+Jednoduchá funkce, která vyhodnotí condition jako podmínku
+a podle výsledku vrátí buď true_result, nebo false_result.
+]]
+local function ifthenelse(condition, true_result, false_result)
+ if condition then
+ return true_result
+ else
+ return false_result
+ end
+end
+local rwt = assert(advtrains.lines.rwt)
+local def
+local function CF(s)
+ if s ~= nil then return F(s) else return "" end
+end
+local has_signs_api = core.get_modpath("signs_api")
+local has_unifieddyes = core.get_modpath("unifieddyes")
+local rozhlas_node_name = "advtrains_line_automation:stanicni_rozhlas"
+
+local RMODE_DEP = 1
+local RMODE_ARR = 2
+local RMODE_BOTH = 3
+
+local PAGE_SETUP_1 = 1
+local PAGE_SETUP_2 = 2
+local PAGE_OWNERSHIP = 3
+
+local hl_texty = {
+ {
+ id = "vcpp",
+ sample = "Vážení cestující, prosíme pozor!",
+ default = "",
+ }, {
+ id = "tvl",
+ sample = "{TYPVLAKU}",
+ }, {
+ id = "vlk",
+ sample = "Vlak",
+ }, {
+ id = "lnky",
+ sample = "linky {LINKA}",
+ }, {
+ id = "jmvlku",
+ sample = "{JMVLAKU}",
+ }, {
+ id = "zesm",
+ sample = "ze směru {VYCHOZI}",
+ }, {
+ id = "prijnk",
+ sample = "přijíždí na kolej {KOLEJ}.",
+ }, {
+ id = "prisnk",
+ sample = "bude přistaven na kolej {KOLEJ}.",
+ }, {
+ id = "zpoz",
+ sample = "Vlak má {ZPOZDENI} sekund zpoždění.",
+ default = "",
+ }, {
+ id = "zpozz",
+ sample = "Vlak má -{ZPOZDENI} sekund zpoždění.",
+ default = "",
+ }, {
+ id = "vkonc",
+ sample = "Vlak zde jízdu končí.",
+ }, {
+ id = "pokrnc",
+ sample = "Vlak dále pokračuje směr {NASL} a {CIL}",
+ }, {
+ id = "pokrc",
+ sample = "Vlak pokračuje směr {CIL}",
+ }, {
+ id = "ozasek",
+ sample = ", odjezd za {ODJZA} sekund.",
+ }, {
+ id = "dek",
+ sample = "Děkujeme, že používáte naše služby.",
+ default = "",
+ }
+}
+local hl_texty_id_to_idx = function()
+ local result = {}
+ for i, def in ipairs(hl_texty) do
+ local id = assert(def.id)
+ if result[id] ~= nil then
+ error("Duplicity: id = "..id.."!")
+ end
+ def.fs_sample = F(def.sample)
+ def.fs_default = F(def.default or def.sample)
+ result[id] = i
+ end
+ return result
+end
+hl_texty_id_to_idx = hl_texty_id_to_idx()
+
+local punch_context = {--[[
+ [player_name] = {
+ stn = string,
+ epos = string,
+ i = int,
+ }
+]]}
+
+local function dist2(a, b)
+ local x, y, z = a.x - b.x, a.y - b.y, a.z - b.z
+ return x * x + y * y + z * z
+end
+
+local function goa(t, k) -- goa = get or add
+ local result = t[k]
+ if result == nil then
+ result = {}
+ t[k] = result
+ end
+ return result
+end
+
+--[[
+ Vrací:
+ - success = bool
+ - min = int or nil (pro success == false vždy nil)
+ - max = int or nil (pro success == false vždy nil)
+ - align = "left" or "right" or "center"
+]]
+local function lengths_from_string(s)
+ if s == "" or s == "-" then
+ return true, nil, nil
+ end
+ local l = #s
+ s = s:gsub("^ +", "")
+ local left = #s < l
+ l = #s
+ s = s:gsub(" +$", "")
+ local right = #s < l
+ local align
+ if not left then
+ align = "left" -- mezery vpravo, nebo žádné mezery
+ elseif right then
+ align = "center" -- mezery na obou stranách
+ else
+ align = "right" -- mezery jen vlevo
+ end
+ local n = s:match("^%d+$")
+ if n ~= nil then
+ n = assert(tonumber(n))
+ if n > 256 then
+ n = 256
+ end
+ return true, n, n, align
+ end
+ local min, max = s:match("^(%d*)-(%d*)$")
+ if min == nil then
+ return false, nil, nil, nil -- bad format
+ end
+ min, max = tonumber(min), tonumber(max)
+ if min ~= nil and min > 256 then min = 256 end
+ if max ~= nil and max > 256 then max = 256 end
+ if min ~= nil and max ~= nil and min > max then
+ min = max
+ end
+ return true, min, max, align
+end
+
+--[[ (obsolete)
+local function lengths_to_string(min, max)
+ if min == nil then
+ if max ~= nil then
+ return "-"..max
+ else
+ return ""
+ end
+ elseif max == nil then
+ return min.."-"
+ elseif min == max then
+ return tostring(min)
+ else
+ return min.."-"..max
+ end
+end
+]]
+
+local alphanum_chars_set = {
+ ["a"] = true, ["A"] = true, ["á"] = true, ["Á"] = true, ["ä"] = true, ["Ä"] = true, ["b"] = true, ["B"] = true, ["č"] = true,
+ ["Č"] = true, ["d"] = true, ["D"] = true, ["ď"] = true, ["Ď"] = true, ["e"] = true, ["E"] = true, ["é"] = true, ["É"] = true,
+ ["ě"] = true, ["Ě"] = true, ["f"] = true, ["F"] = true, ["g"] = true, ["G"] = true, ["h"] = true, ["H"] = true, ["i"] = true,
+ ["I"] = true, ["í"] = true, ["Í"] = true, ["j"] = true, ["J"] = true, ["k"] = true, ["K"] = true, ["l"] = true, ["L"] = true,
+ ["ĺ"] = true, ["Ĺ"] = true, ["ľ"] = true, ["Ľ"] = true, ["m"] = true, ["M"] = true, ["n"] = true, ["N"] = true, ["ň"] = true,
+ ["Ň"] = true, ["o"] = true, ["O"] = true, ["ó"] = true, ["Ó"] = true, ["ô"] = true, ["Ô"] = true, ["p"] = true, ["P"] = true,
+ ["q"] = true, ["Q"] = true, ["r"] = true, ["R"] = true, ["ŕ"] = true, ["Ŕ"] = true, ["ř"] = true, ["Ř"] = true, ["s"] = true,
+ ["S"] = true, ["š"] = true, ["Š"] = true, ["t"] = true, ["T"] = true, ["ť"] = true, ["Ť"] = true, ["u"] = true, ["U"] = true,
+ ["ú"] = true, ["Ú"] = true, ["ů"] = true, ["Ů"] = true, ["v"] = true, ["V"] = true, ["w"] = true, ["W"] = true, ["x"] = true,
+ ["X"] = true, ["y"] = true, ["Y"] = true, ["ý"] = true, ["Ý"] = true, ["z"] = true, ["Z"] = true, ["ž"] = true, ["Ž"] = true,
+ ["0"] = true, ["1"] = true, ["2"] = true, ["3"] = true, ["4"] = true, ["5"] = true, ["6"] = true, ["7"] = true, ["8"] = true,
+ ["9"] = true,
+}
+
+local function dosadit(format, data, defaults)
+ assert(type(format) == "string")
+ assert(type(data) == "table")
+ if defaults == nil then
+ defaults = {}
+ end
+ local result = {}
+ local i = 1
+ local e = 0
+ local b = format:find("{", e + 1, true)
+ while b ~= nil do
+ if e < b - 1 then
+ table.insert(result, format:sub(e + 1, b - 1))
+ end
+ e = format:find("}", b + 1, true)
+ if e == nil then
+ core.log("warning", "[advtrains_line_automation] dosadit(): invalid format: <"..format..">")
+ table.insert(result, format:sub(b, -1))
+ break
+ end
+ local tag = format:sub(b + 1, e - 1)
+ local tag_name = tag
+ local tagfmt, tagalt = ""
+ local b2 = tag:find("[:|]")
+ if b2 == nil then
+ tag_name, tagfmt = tag, ""
+ else
+ tag_name = tag:sub(1, b2 - 1)
+ repeat
+ local e2 = tag:find("[:|]", b2 + 1) or (#tag + 1)
+ local c = tag:sub(b2, b2)
+ if c == ":" then
+ tagfmt = tag:sub(b2 + 1, e2 - 1)
+ elseif c == "|" then
+ tagalt = tag:sub(b2 + 1, e2 - 1)
+ end
+ b2 = e2
+ until b2 >= #tag
+ end
+ local min, max, align
+ if tagfmt ~= "" then
+ local success
+ success, min, max, align = lengths_from_string(tagfmt)
+ end
+ tag = tag_name
+ if tag:len() < 4 and ch_core.utf8_length(tag) == 1 and alphanum_chars_set[tag] == nil then
+ -- speciální případ: zopakovat znak alespoň min-krát
+ if min ~= nil then
+ table.insert(result, string.rep(tag, min))
+ else
+ table.insert(result, tag)
+ end
+ else
+ local value = data[tag] or tagalt or defaults[tag] or "ERR"
+ local len = ch_core.utf8_length(value)
+ if min ~= nil and len < min then
+ -- řetězec je kratší než minimum => prodloužit
+ local missing = min - len
+ if align == "left" then
+ table.insert(result, value)
+ table.insert(result, string.rep(" ", missing))
+ elseif align == "right" then
+ table.insert(result, string.rep(" ", missing))
+ table.insert(result, value)
+ else
+ table.insert(result, string.rep(" ", math.floor(missing / 2)))
+ table.insert(result, value)
+ table.insert(result, string.rep(" ", missing - math.floor(missing / 2)))
+ end
+ elseif max ~= nil and len > max then
+ -- řetězec je delší než maximum => oříznout
+ if align == "left" then
+ local pos = assert(ch_core.utf8_seek(value, 1, max))
+ table.insert(result, value:sub(1, pos - 1))
+ elseif align == "right" then
+ local pos = assert(ch_core.utf8_seek(value, 1, len - max))
+ table.insert(result, value:sub(pos, -1))
+ else
+ local overflow = len - max
+ local half = math.floor(overflow / 2)
+ local pos1 = assert(ch_core.utf8_seek(value, 1, half))
+ local pos2 = (ch_core.utf8_seek(value, pos1, len - overflow) or 0) - 1
+ table.insert(result, value:sub(pos1, pos2))
+ end
+ else
+ -- řetězec odpovídá
+ table.insert(result, value)
+ end
+ end
+ b = format:find("{", e + 1, true)
+ end
+ table.insert(result, format:sub(e + 1, -1))
+ return table.concat(result)
+end
+
+-- Vrátí neuspořádaný seznam čísel řádků, které musejí být zformátovány pro daný formátovací řetězec.
+local function ktere_radky(s, empty_as_string)
+ local set = {}
+ local list = {}
+ for match in s:gmatch("{[1-9][:|}]") do
+ local n = tonumber(match:sub(2,2))
+ if n ~= nil and not set[n] then
+ set[n] = true
+ table.insert(list, n)
+ end
+ end
+ if list[1] == nil and empty_as_string then
+ return ""
+ else
+ return list
+ end
+end
+
+local function sestavit_hlaseni(settings, settings_override, data, defaults)
+ local parts = {}
+ local function a(s)
+ table.insert(parts, s)
+ end
+ local function t(id)
+ if id == nil then
+ return ""
+ end
+ local key = "tx_"..id
+ local result = settings_override[key] or settings[key]
+ if result == nil then
+ local def = assert(hl_texty[hl_texty_id_to_idx[id]])
+ result = assert(def.default or def.sample)
+ end
+ return result
+ end
+ assert(settings)
+ if settings_override == nil then
+ settings_override = {}
+ end
+ assert(data)
+ a(t("vcpp"))
+ a("{SEP}")
+ a(t(ifthenelse(data.TYPVLAKU ~= nil, "tvl", "vlk")))
+ a("{SEP}")
+ if data.LINKA ~= nil then
+ a(t("lnky"))
+ a("{SEP}")
+ end
+ if data.VYCHOZI ~= nil then
+ a(t("zesm"))
+ a("{SEP}")
+ a(t("prijnk"))
+ else
+ a(t("prisnk"))
+ end
+ a("{SEP}")
+ if data.typ_zpozdeni == "+" then
+ a(t("zpoz"))
+ a("{SEP}")
+ elseif data.typ_zpozdeni == "-" then
+ a(t("zpozz"))
+ a("{SEP}")
+ end
+ if not data.CIL then
+ a(t("vkonc"))
+ elseif data.NASL then
+ a(t("pokrnc"))
+ else
+ a(t("pokrc"))
+ end
+ if data.ODJZA then
+ a(t("ozasek"))
+ else
+ a(".")
+ end
+ a("{SEP}")
+ a(t("dek"))
+ data = table.copy(data)
+ data.SEP = "{SEP}"
+ local s = table.concat(parts)
+ s = assert(dosadit(s, data, defaults))
+ s = s:gsub(" *{SEP} *", "{SEP}")
+ while true do
+ t = s:gsub("{SEP}{SEP}", "{SEP}")
+ if t:len() == s:len() then
+ break
+ end
+ s = t
+ end
+ s = s:gsub("^{SEP}", "")
+ s = s:gsub("{SEP}$", "")
+ s = s:gsub("{SEP}", " ")
+ return s
+end
+
+local function get_or_add_anns(stn)
+ local station = advtrains.lines.stations[stn]
+ if station == nil then
+ return nil -- dopravna neexistuje!
+ end
+ local anns = station.anns
+ if anns == nil then
+ anns = {}
+ station.anns = anns
+ end
+ return anns
+end
+
+local cedule_default_settings = {
+ empty = "{-:5}",
+ fs = "",
+ pos = vector.zero(),
+ row = "{LINKA: 3} za {ODJZA: 2-3} s",
+ text = "{ZDE} - odjezdy\n{1}\n{2}",
+ text_rtf = {1, 2},
+}
+
+local function init_ann_data(stn, epos)
+ local anns = get_or_add_anns(stn)
+ if anns == nil then
+ return
+ end
+ local result = {
+ cedule = {
+ table.copy(cedule_default_settings), table.copy(cedule_default_settings),
+ table.copy(cedule_default_settings), table.copy(cedule_default_settings)},
+ chat_dosah = 50,
+ fmt_delay = "{}",
+ fmt_negdelay = "-{}",
+ fmt_nodelay = "",
+ fn_firstupper = false,
+ fs_koleje = "",
+ koleje = "",
+ owner = "",
+ version = 3,
+ }
+ anns[epos] = result
+ return result
+end
+
+local function get_ann_data(stn, epos, make_copy)
+ local anns = get_or_add_anns(stn)
+ if anns == nil then
+ core.log("error", "get_ann_data() called on non-existent stn '"..tostring(stn).."'!")
+ return nil
+ end
+ local ann = assert(anns[epos] or init_ann_data(stn, epos))
+ if make_copy then
+ ann = table.copy(ann)
+ local cedule = {}
+ for i, v in ipairs(ann.cedule) do
+ cedule[i] = table.copy(v)
+ end
+ ann.cedule = cedule
+ end
+ return ann
+end
+
+local function set_ann_data(stn, epos, data)
+ local anns = get_or_add_anns(stn)
+ if anns == nil then
+ return false
+ end
+ local ann = anns[epos]
+ if ann ~= nil then
+ for k, v in pairs(data) do
+ ann[k] = v
+ end
+ else
+ anns[epos] = table.copy(data)
+ end
+ return true
+end
+
+local function attach_sign(stn, epos, i, sign_pos)
+ -- zkontrolovat rozhlas:
+ local rozhl_pos = advtrains.decode_pos(epos)
+ core.load_area(rozhl_pos)
+ local rozhl_node = core.get_node(rozhl_pos)
+ if rozhl_node.name ~= rozhlas_node_name then
+ return false, "Staniční rozhlas se nenachází na očekávané pozici."
+ end
+ local rozhl_meta = core.get_meta(rozhl_pos)
+ if rozhl_meta:get_string("stn") ~= stn then
+ return false, "Staniční rozhlas přísluší k jiné dopravně." -- vnitřní chyba!
+ end
+ local data = get_ann_data(stn, epos, false)
+ if data == nil then
+ return false, "Data staničního rozhlasu nebyla nalezena."
+ end
+
+ -- zkontrolovat ceduli:
+ core.load_area(sign_pos)
+ local sign_node = core.get_node_or_nil(sign_pos)
+ if sign_node == nil or core.get_item_group(sign_node.name, "display_api") == 0 then
+ return false, "Toto není podporovaná cedule."
+ end
+
+ -- zkontrolovat vzdálenost:
+ if vector.distance(rozhl_pos, sign_pos) > 1024 then
+ return false, "Cedule je příliš daleko. Vzdálenost může být max. 1024 metrů."
+ end
+
+ -- zkontrolovat zadání:
+ local cedule = data.cedule[i]
+ if cedule == nil then
+ return false, "Chybný index."
+ end
+
+ -- připojit:
+ local s = string.format("%d,%d,%d", sign_pos.x, sign_pos.y, sign_pos.z)
+ local fs = F(s)
+ cedule.fs = fs
+ cedule.pos = sign_pos
+ return true, "Cedule úspěšně připojena ke staničnímu rozhlasu."
+end
+
+local function detach_sign(stn, epos, i)
+ -- zkontrolovat rozhlas:
+ local rozhl_pos = advtrains.decode_pos(epos)
+ core.load_area(rozhl_pos)
+ local rozhl_node = core.get_node(rozhl_pos)
+ if rozhl_node.name ~= rozhlas_node_name then
+ return false, "Staniční rozhlas se nenachází na očekávané pozici."
+ end
+ local rozhl_meta = core.get_meta(rozhl_pos)
+ if rozhl_meta:get_string("stn") ~= stn then
+ return false, "Staniční rozhlas přísluší k jiné dopravně." -- vnitřní chyba!
+ end
+ local data = get_ann_data(stn, epos, false)
+ if data == nil then
+ return false, "Data staničního rozhlasu nebyla nalezena."
+ end
+
+ -- zkontrolovat zadání:
+ local cedule = data.cedule[i]
+ if cedule == nil then
+ return false, "Chybný index."
+ end
+
+ if cedule.fs == "" then
+ return false, "Cedule není připojena."
+ end
+
+ -- odpojit:
+ cedule.fs = ""
+ cedule.pos = vector.zero()
+ return true, "Cedule úspěšně odpojena."
+end
+
+
+local function init_formspec_callback(custom_state, player, formname, fields)
+ local player_name = player:get_player_name()
+ local pos = custom_state.pos
+ local node = core.get_node(pos)
+ if node.name ~= rozhlas_node_name then
+ core.chat_send_player(player_name, "CHYBA: staniční rozhlas nenalezen!")
+ return
+ end
+ if not core.check_player_privs(player, "railway_operator") then
+ core.chat_send_player(player_name, "*** K instalaci staničního rozhlasu je nutné právo railway_operator!")
+ return
+ end
+ if fields.dopravna then
+ local event = core.explode_textlist_event(fields.dopravna)
+ local new_index = tonumber(event.index)
+ if new_index ~= nil and custom_state.list[new_index] ~= nil then
+ custom_state.selection_index = new_index
+ end
+ if event.type == "DCL" then
+ fields.zvolit_dopravnu = "true"
+ end
+ end
+ if fields.zvolit_dopravnu and custom_state.selection_index ~= nil then
+ local stn = assert(custom_state.list[custom_state.selection_index].stn)
+ local stdata = advtrains.lines.stations[stn]
+ if stdata ~= nil then
+ local meta = core.get_meta(pos)
+ meta:set_string("infotext", "staniční rozhlas ("..(stdata.name or "???")..")")
+ meta:set_string("owner", player_name)
+ meta:set_string("stn", stn)
+ init_ann_data(stn, custom_state.epos)
+ core.chat_send_player(player_name, "*** Úspěšně nastaveno.")
+ end
+ end
+end
+
+local function get_setup_formspec(custom_state)
+ local player_name = assert(custom_state.player_name)
+ local page = assert(custom_state.page)
+ local stations = assert(custom_state.stations)
+ local stn = custom_state.stn
+ local data = custom_state.data
+
+ local formspec = {
+ "formspec_version[6]"..
+ "size[15,16.5]"..
+ -- "style_type[textarea;font=mono]"..
+ "tabheader[0,0;0.75;tab;Nastavení 1,Nastavení 2",
+ ifthenelse(custom_state.is_admin, ",Vlastnictví;", ";"),
+ custom_state.page..";false;true]"..
+ "button_exit[14,0.25;0.75,0.75;close;X]"..
+ "item_image[0.5,0.5;1,1;"..rozhlas_node_name.."]"..
+ "label[1.75,1;staniční rozhlas]"..
+ "label[9,0.75;vlastník/ice:\n",
+ ch_core.prihlasovaci_na_zobrazovaci(custom_state.owner),
+ "]",
+ }
+ local function a(x)
+ if type(x) == "table" then
+ for _, s in ipairs(x) do
+ table.insert(formspec, s)
+ end
+ else
+ table.insert(formspec, x)
+ end
+ end
+ if page == PAGE_SETUP_1 then
+ a( "container[0.5,1.5]"..
+ "label[0,0.5;dopravna:]"..
+ "dropdown[1.75,0.2;5,0.6;dopravna;")
+ for i, station in ipairs(stations) do
+ a(ifthenelse(i ~= 1, ",", "")..F(station.stn).." | "..F(station.name))
+ end
+ a{";"..custom_state.station_index..";true]"..
+ "label[7,0.5;omezit jen na koleje:]"..
+ "field[10,0.2;4,0.6;koleje;;",
+ data.fs_koleje or "",
+ "]label[0,1.25;režim:]"..
+ "dropdown[1.75,1;3,0.6;rmode;odjezdy,příjezdy,odjezdy i příjezdy;",
+ tostring(data.rmode),
+ ";true]container_end[]",
+ -- ----
+ "container[0.5,3.25]"..
+ "checkbox[0,0.25;fn_firstupper;první písmeno řádky odjezdu vždy velké;",
+ ifthenelse(ifthenelse(custom_state.fn_firstupper ~= nil, custom_state.fn_firstupper, data.fn_firstupper), "true", "false"),
+ "]field[0,1;3.25,0.75;fmt_nodelay;bez zpoždění;", F(data.fmt_nodelay or ""), "]"..
+ "field[4,1;3.25,0.75;fmt_delay;zpoždění ({} = číslo);", F(data.fmt_delay or "{}"), "]"..
+ "field[8,1;3.25,0.75;fmt_negdelay;záp.zpoždění ({} = číslo);", F(data.fmt_negdelay or "-{}"), "]"..
+ "tooltip[fmt_nodelay;Text pro značku {ZPOZDENI} v případě\\, že vlak jede bez zpoždění.]"..
+ "tooltip[fmt_delay;Formát pro značku {ZPOZDENI} v případě\\, že vlak má (kladné) zpoždění.\n"..
+ "Značka {} se nahradí počtem sekund zpoždění.]"..
+ "tooltip[fmt_negdelay;Formát pro značku {ZPOZDENI} v případě\\, že vlak má záporné zpoždění.\n"..
+ "Značka {} se nahradí absolutní hodnotou počtu sekund záporného zpoždění.]"..
+ "container_end[]"..
+ "container[0.5,10.5]"..
+ "box[0,0.15;14,0.05;#000000FF]"}
+ --[[
+ -- hlášení do četu (zatím neimplementováno):
+ a{ "label[7,0.5;dosah hlášení v četu \\[m\\] (0=vyp):]"..
+ "field[11.5,0.25;2,0.5;chat_dosah;;",
+ tostring(data.chat_dosah or "50"),
+ "]"..
+ "tooltip[chat_dosah;Dosah je současně limitován doslechem jednotlivých hráčských postav.]"..
+ "label[0,0.5;texty pro hlášení příjezdu/přistavení vlaku v četu:]"..
+ "tablecolumns[text;text]"..
+ "table[0,0.75;14,2;texty;"}
+ for _, def in ipairs(hl_texty) do
+ local id = "tx_"..def.id
+ a(def.fs_sample)
+ a(",")
+ a(F(data[id] or def.default or def.sample))
+ a(",")
+ end
+ formspec[#formspec] = ";"..(custom_state.tx_index or "").."]"
+ a("label[0.1,3.125;text:]".."field[0.75,2.75;10,0.75;preklad;;")
+ if custom_state.tx_index ~= nil then
+ local def = assert(hl_texty[custom_state.tx_index])
+ local id = "tx_"..def.id
+ local s = data[id]
+ if s ~= nil then
+ a(F(s))
+ else
+ a(def.fs_default)
+ end
+ end
+ a( "]"..
+ "button[11,2.75;3,0.75;preklad_set;nastavit]"..
+ "tooltip[preklad;V levém sloupci tabulky jsou vzorové texty\\, v pravém sloupci jsou texty\\,\n"..
+ "které budou na jejich místě použity pro tento staniční rozhlas (ty můžete měnit).]"..
+ "textarea[0,3.5;14,1;;;příklad: ")
+ local hlaseni = sestavit_hlaseni(data, custom_state, {
+ LINKA = "S1",
+ VYCHOZI = "Praha hl. n.",
+ typ_zpozdeni = "+",
+ CIL = "Bratislava hl. st.",
+ NASL = "Pardubice hl. n.",
+ ODJZA = "60",
+ ZPOZDENI = "13",
+ JMVLAKU = "Testovací expres",
+ KOLEJ = "A",
+ })
+ a(F(hlaseni))
+ a("]")
+ ]]
+ a("container_end[]"--[[..
+ -- ----
+ "container[0.5,9.25]"..
+ "label[0,0.25;Formáty řádků ({1}, {2} atd.):]"..
+ "container_end[]" ]]
+ )
+ a("button[0.5,15;14,1;btn_save;Uložit]")
+ elseif page == PAGE_SETUP_2 then
+ a( "textarea[0.5,2;14,2;;;"..F("Pro nápovědu a použitou syntaxi viz wiki Českého hvozdu (článek „Staniční rozhlas“).").."]"..
+ "container[0.5,4]")
+ for i = 1, 4 do
+ local cedule = data.cedule[i]
+ local s = tostring(i)
+ a{ "container[0,", string.format("%f", 2.5 * (i - 1)),
+ "]label[0,0.3;cedule ", s, ":]"..
+ "field[0,0.9;9.75,0.75;fmt_cedule", s, "_row;formát řádky / prázdný řádek:;",
+ F(cedule.row),
+ "]field[0,1.75;9.75,0.75;fmt_cedule", s, "_empty;;", F(cedule.empty),
+ "]textarea[10,0.5;4,2;fmt_cedule", s, ";;"..F(cedule.text),
+ "]field[2,0;4.5,0.5;pos_cedule", s, ";;", cedule.fs,
+ "]button_exit[10,0;3,0.5;zam_cedule", s,
+ ";zaměřit...]button[6.75,0;3,0.5;",
+ ifthenelse(cedule.fs ~= "", "odp_cedule"..s..";odpojit", "pri_cedule"..s..";připojit"),
+ "]container_end[]",
+ }
+ end
+ a{ "container_end[]"..
+ "label[0.5,14.5;", CF(custom_state.message), "]"..
+ "button[0.5,15;14,1;btn_save;Uložit]",
+ }
+ elseif custom_state.is_admin and page == PAGE_OWNERSHIP then
+ a{
+ "field[0.5,2.5;5,0.75;owner;vlastník/ice:;",
+ ch_core.prihlasovaci_na_zobrazovaci(custom_state.owner),
+ "]button[5.75,2.5;3,0.75;set_owner;nastavit]"..
+ "label[0.5,13;",
+ CF(custom_state.message),
+ "]button_exit[0.5,15;14,1;close2;zavřít]",
+ }
+ end
+ return table.concat(formspec)
+end
+
+local function setup_formspec_callback(custom_state, player, formname, fields)
+ assert(player:get_player_name() == custom_state.player_name)
+ local node = core.get_node(custom_state.pos)
+ if node.name ~= rozhlas_node_name then
+ return
+ end
+ local is_admin = custom_state.is_admin
+ local page = custom_state.page
+ local stn = custom_state.stn
+ local data = custom_state.data
+
+ if page == PAGE_SETUP_1 then
+ if
+ fields.dopravna and
+ fields.dopravna ~= tostring(custom_state.station_index) and
+ tonumber(fields.dopravna) ~= nil and
+ custom_state.stations[tonumber(fields.dopravna)] ~= nil
+ then
+ -- přepnout dopravnu
+ custom_state.station_index = tonumber(fields.dopravna)
+ end
+ if fields.rmode then
+ local new_rmode = tonumber(fields.rmode)
+ if new_rmode ~= nil and new_rmode ~= data.rmode then
+ data.rmode = new_rmode
+ end
+ end
+
+ -- zaškrtávací pole:
+ if fields.fn_firstupper then
+ data.fn_firstupper = ifthenelse(fields.fn_firstupper == "true", true, false)
+ end
+
+ -- koleje:
+ if fields.koleje and F(fields.koleje) ~= data.fs_koleje then
+ local parts = string.split(fields.koleje, ",", false)
+ local list, set = {}, {}
+ for _, part in ipairs(parts) do
+ if not set[part] then
+ set[part] = true
+ table.insert(list, part)
+ end
+ end
+ if #list == 0 then
+ -- všechny koleje
+ data.fs_koleje = ""
+ data.koleje = ""
+ elseif #list == 1 then
+ data.fs_koleje = F(list[1])
+ data.koleje = list[1]
+ else
+ table.sort(list, function(a, b) return a < b end)
+ data.fs_koleje = F(table.concat(list, ","))
+ data.koleje = set
+ end
+ end
+ if fields.fmt_delay then
+ data.fmt_delay = fields.fmt_delay
+ end
+ if fields.fmt_nodelay then
+ data.fmt_nodelay = fields.fmt_nodelay
+ end
+ if fields.fmt_negdelay then
+ data.fmt_negdelay = fields.fmt_negdelay
+ end
+
+ -- texty
+ if fields.texty then
+ local event = core.explode_table_event(fields.texty)
+ if (event.type == "CHG" or event.type == "DCL") and event.row ~= custom_state.tx_index and hl_texty[event.row] ~= nil then
+ custom_state.tx_index = event.row
+ end
+ end
+
+ if fields.preklad_set and custom_state.tx_index then
+ local def = assert(hl_texty[custom_state.tx_index])
+ custom_state.data["tx_"..def.id] = assert(fields.preklad)
+ return get_setup_formspec(custom_state)
+ end
+ if fields.chat_dosah and tonumber(fields.chat_dosah) ~= nil then
+ local new_dosah = tonumber(fields.chat_dosah)
+ if new_dosah ~= nil and new_dosah == math.floor(new_dosah) and new_dosah >= 0 and new_dosah < 1024 then
+ custom_state.data.chat_dosah = new_dosah
+ end
+ end
+
+ -- uložit?
+ if fields.btn_save then
+ local new_stn = custom_state.stations[custom_state.station_index].stn
+ if new_stn ~= stn then
+ -- přesunout rozhlas na jinou dopravnu
+ local meta = assert(core.get_meta(custom_state.pos))
+ local old_anns = get_or_add_anns(stn)
+ local new_anns = get_or_add_anns(new_stn)
+ if old_anns ~= nil and new_anns ~= nil then
+ local epos = custom_state.epos
+ new_anns[epos] = old_anns[epos]
+ old_anns[epos] = nil
+ meta:set_string("stn", new_stn)
+ stn = new_stn
+ custom_state.stn = new_stn
+ end
+ end
+ set_ann_data(stn, custom_state.epos, data)
+ custom_state.data = get_ann_data(stn, custom_state.epos, true)
+ -- update infotext:
+ local meta = core.get_meta(custom_state.pos)
+ local station_name = al.get_station_name(meta:get_string("stn"))
+ local koleje = custom_state.data.fs_koleje
+ if koleje ~= "" then
+ koleje = " ["..koleje:gsub("\\", "").."]"
+ end
+ meta:set_string("infotext", "staniční rozhlas\n"..station_name..koleje)
+ end
+ elseif page == PAGE_SETUP_2 then
+ -- update fields:
+ for i = 1, 4 do
+ local cedule = data.cedule[i]
+ local s = fields["fmt_cedule"..i]
+ if s ~= nil then
+ cedule.text = s
+ cedule.text_rtf = ktere_radky(s, true)
+ end
+ s = fields["fmt_cedule"..i.."_row"]
+ if s ~= nil then
+ cedule.row = s
+ end
+ s = fields["fmt_cedule"..i.."_empty"]
+ if s ~= nil then
+ cedule.empty = s
+ end
+ end
+ if fields.btn_save then
+ local new_cedule = {}
+ for i = 1, 4 do
+ new_cedule[i] = table.copy(data.cedule[i])
+ end
+ get_ann_data(stn, custom_state.epos, false).cedule = new_cedule
+ return get_setup_formspec(custom_state)
+ else
+ for i = 1, 4 do
+ if fields["pri_cedule"..i] then
+ -- připojit ceduli:
+ local pos_cedule_str = fields["pos_cedule"..i]
+ local x, y, z = pos_cedule_str:match("^(-?%d+),(-?%d+),(-?%d+)$")
+ if x == nil or y == nil or z == nil then
+ custom_state.message = "Chybný formát pozice: "..pos_cedule_str
+ return get_setup_formspec(custom_state)
+ end
+ local pos_cedule = vector.new(tonumber(x), tonumber(y), tonumber(z))
+ local success, message = attach_sign(stn, custom_state.epos, i, pos_cedule)
+ if success then
+ local current_data = get_ann_data(stn, custom_state.epos, true)
+ if current_data ~= nil then
+ custom_state.data = current_data
+ end
+ custom_state.message = "Cedule úspěšně připojena."
+ else
+ custom_state.message = "CHYBA: "..message
+ end
+ return get_setup_formspec(custom_state)
+ end
+ if fields["odp_cedule"..i] then
+ local success, message = detach_sign(stn, custom_state.epos, i)
+ if success then
+ local current_data = get_ann_data(stn, custom_state.epos, true)
+ if current_data ~= nil then
+ custom_state.data = current_data
+ end
+ custom_state.message = "Cedule úspěšně odpojena."
+ else
+ custom_state.message = "CHYBA: "..message
+ end
+ return get_setup_formspec(custom_state)
+ end
+ if fields["zam_cedule"..i] then
+ local player_name = player:get_player_name()
+ local stack = player:get_wielded_item()
+ if stack:is_empty() then
+ player:set_wielded_item("advtrains_line_automation:sign_selector")
+ core.chat_send_player(player_name, "*** Levým klikem vyberte ceduli k připojení...")
+ else
+ player:get_inventory():add_item("main", "advtrains_line_automation:sign_selector")
+ core.chat_send_player(player_name, "*** Levým klikem výběrovým nástrojem vyberte ceduli k připojení...")
+ end
+ punch_context[player_name] = {stn = assert(custom_state.stn), epos = custom_state.epos, i = i}
+ return
+ end
+ end
+ end
+ elseif page == PAGE_OWNERSHIP then
+ if is_admin and fields.set_owner then
+ local new_owner = ch_core.jmeno_na_existujici_prihlasovaci(fields.owner or "")
+ if new_owner == nil then
+ custom_state.message = "Postava '"..(fields.owner or "").."' neexistuje!"
+ else
+ local ann_data = assert(get_ann_data(stn, custom_state.epos, false))
+ ann_data.owner = new_owner
+ core.load_area(custom_state.pos)
+ local meta = core.get_meta(custom_state.pos)
+ meta:set_string("owner", new_owner)
+ custom_state.owner = new_owner
+ end
+ return get_setup_formspec(custom_state)
+ end
+ end
+ if fields.tab then
+ -- přepnout stránku
+ local new_tab = tonumber(fields.tab)
+ if new_tab ~= nil and new_tab ~= page and (
+ new_tab == PAGE_SETUP_1 or new_tab == PAGE_SETUP_2 or (is_admin and new_tab == PAGE_OWNERSHIP)
+ ) then
+ custom_state.page = new_tab
+ custom_state.message = "" -- smazat zprávu
+ end
+ return get_setup_formspec(custom_state)
+ end
+ if not fields.quit then
+ return get_setup_formspec(custom_state)
+ end
+end
+
+local function fill(line, prefix, rwtime_now, rwtime_value)
+ if rwtime_value == nil then
+ return
+ end
+ local secs = math.ceil((rwtime_value - rwtime_now) / 5) * 5
+ if secs < 0 then
+ secs = -secs
+ line[prefix.."_Z"] = "-"
+ end
+ local n_s = secs % 60
+ local n_m = (secs - n_s) / 60
+ local s = tostring(n_s)
+ local m = tostring(n_m)
+ line[prefix] = tostring(secs)
+ line[prefix.."_M"] = m
+ line[prefix.."_S"] = s
+ if n_m < 10 then
+ line[prefix.."_MM"] = "0"..m
+ else
+ line[prefix.."_MM"] = m
+ end
+ if n_s < 10 then
+ line[prefix.."_SS"] = "0"..s
+ else
+ line[prefix.."_SS"] = s
+ end
+end
+
+--[[
+ stn -- kód dopravny, jejíž příjezdy/odjezdy se budou zapisovat na cedule
+ epos -- kódovaná pozice st. rozhlasu (pro načtení dat)
+ signs -- (volitelný) seznam až 4 pozic cedulí, které se budou aktualizovat
+ records -- viz níže
+ rwtime -- aktuální žel. čas (číselná forma)
+ ---
+ records je tabulka záznamů z al.predict_train(), doplněných o následující pole:
+ start = string or nil, -- název výchozí zastávky, pokud vlak odněkud přijíždí, jinak ""
+ destination = string, -- název cílové zastávky, pokud vlak někam pokračuje, jinak ""
+ prev_stop = string, -- název předchozí zastávky, pokud vlak odněkud přijíždí a pokud jde o jinou zastávku než 'start', jinak ""
+ next_stop = string, -- název násl. zast., pokud vlak pokračuje a pokud jde o jinou zastávku než 'destination', jinak ""
+ last_pos = string, -- název poslední známé polohy vlaku, nebo ""
+ --
+ stn = string, track = string, delay = int,
+ stdata = table or nil,
+ dep = int or nil, dep_linevar_def = table or nil, dep_index = int or nil,
+ arr = int or nil, arr_linevar_def = table or nil, arr_index = int or nil,
+]]
+
+local function update_ann(stn, epos, signs, records, rwtime)
+ local ann = get_ann_data(stn, epos)
+ if ann == nil then
+ core.log("error", "update_ann() called for "..stn.."/"..epos..", but ann is nil!")
+ return
+ end
+ local tracks
+ local any_line = {
+ ZDE = al.get_station_name(stn),
+ }
+ if ann.fs_koleje ~= "" then
+ any_line.KOLEJE = ann.fs_koleje:gsub("\\", "")
+ tracks = ann.koleje
+ if tracks ~= nil and type(tracks) ~= "table" then
+ if tracks == "" then
+ tracks = nil
+ else
+ tracks = {[tracks] = true}
+ end
+ end
+ end
+ local lines = {}
+ for _, record in ipairs(records) do
+ assert(record.start ~= nil)
+ assert(record.destination ~= nil)
+ assert(record.prev_stop ~= nil)
+ assert(record.next_stop ~= nil)
+ assert(record.last_pos ~= nil)
+ if
+ (tracks == nil or tracks[record.track]) and (
+ (ann.rmode == RMODE_ARR and record.arr ~= nil) or
+ (ann.rmode == RMODE_DEP and record.dep ~= nil) or
+ (ann.rmode == RMODE_BOTH and (record.arr ~= nil or record.dep ~= nil))
+ )
+ then
+ local linevar_def, index
+ if record.dep ~= nil then
+ linevar_def, index = record.dep_linevar_def, record.dep_index
+ else
+ linevar_def, index = record.arr_linevar_def, record.arr_index
+ end
+ local stops = linevar_def.stops
+ local line = setmetatable({}, {__index = any_line})
+ line.LINKA = advtrains.lines.linevar_decompose(linevar_def.name)
+ assert(line.LINKA)
+ if record.start ~= "" then
+ line.VYCHOZI = record.start
+ end
+ if record.destination ~= "" then
+ line.CIL = record.destination
+ end
+ if record.track ~= "" then
+ line.KOLEJ = record.track
+ end
+ fill(line, "PRIJZA", rwtime, record.arr)
+ fill(line, "ODJZA", rwtime, record.dep)
+ local abs_delay = math.abs(record.delay)
+ if abs_delay < 5 then
+ line.ZPOZDENI = ann.fmt_nodelay or ""
+ else
+ line.ZPOZDENI = dosadit(
+ ifthenelse(record.delay > 0, ann.fmt_delay or "{}", ann.fmt_negdelay or "-{}"),
+ {[""] = tostring(5 * math.ceil(abs_delay / 5))}
+ )
+ end
+ -- PREDCH
+ if record.prev_stop ~= "" then
+ line.PREDCH = record.prev_stop
+ end
+ -- NASL
+ if record.next_stop ~= "" then
+ line.NASL = record.next_stop
+ end
+ -- POLOHA
+ if record.last_pos ~= "" then
+ line.POLOHA = record.last_pos
+ end
+ -- JMVLAKU
+ if linevar_def.train_name ~= nil then
+ line.JMVLAKU = linevar_def.train_name
+ end
+ -- TYP
+ line.TYP = "Os"
+ -- TYPVLAKU
+ line.TYPVLAKU = "osobní vlak"
+ table.insert(lines, line)
+ end
+ end
+ if signs ~= nil then
+ local empty_table = {}
+ for i = 1, 4 do
+ local cedule = ann.cedule[i]
+ local sign_pos = signs[i]
+ if sign_pos ~= nil and core.compare_block_status(sign_pos, "active") then
+ local formatted_lines = setmetatable({}, {__index = any_line})
+ if type(cedule.text_rtf) == "table" then
+ for _, i_row in ipairs(cedule.text_rtf) do
+ if lines[i_row] == nil then
+ -- prázdný řádek
+ formatted_lines[tostring(i_row)] = dosadit(cedule.empty, empty_table)
+ else
+ -- řádek odjezdu
+ local s = dosadit(cedule.row, lines[i_row])
+ if s ~= "" and ann.fn_firstupper then
+ local l = ch_core.utf8_seek(s, 1, 1)
+ if l == nil then
+ s = ch_core.na_velka_pismena(s)
+ else
+ local c = s:sub(1, l - 1)
+ local uc = ch_core.na_velka_pismena(c)
+ if uc ~= c then
+ s = uc..s:sub(l, -1)
+ end
+ end
+ end
+ formatted_lines[tostring(i_row)] = s
+ end
+ end
+ end
+ local s = dosadit(cedule.text, formatted_lines)
+ if has_signs_api then
+ signs_api.set_display_text(sign_pos, s)
+ end
+ end
+ end
+ end
+end
+
+local globalstep_time = -5
+local first_run = true
+
+local function first_globalstep()
+ for stn, stdata in pairs(advtrains.lines.stations) do
+ local anns = stdata.anns
+ if stdata.anns ~= nil then
+ for rozh_epos, ann in pairs(stdata.anns) do
+ if ann.version < 2 then
+ -- upgrade version 1 to version 2:
+ ann.rmode = RMODE_DEP
+ ann.version = 2
+ end
+ if ann.version < 3 then
+ local pos = advtrains.decode_pos(rozh_epos)
+ core.load_area(pos)
+ local meta = core.get_meta(pos)
+ ann.owner = meta:get_string("owner")
+ core.log("action", "strozhlas at position "..core.pos_to_string(pos).." upgraded to metadata version 3 (owner "..ann.owner..")")
+ ann.version = 3
+ end
+ end
+ end
+ end
+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})
+ if result == "???" then
+ result = ""
+ end
+ cache[linevar_def.name] = result
+ end
+ return result
+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})
+ if result == "???" then
+ result = ""
+ end
+ cache[linevar_def.name] = result
+ end
+ return result
+end
+
+local function get_name_by_stn(cache, stn, alt)
+ local result = cache[stn]
+ if result == nil then
+ result = al.get_station_name(stn)
+ if result == "???" then
+ result = ""
+ end
+ cache[stn] = result
+ end
+ if result == "" then
+ return alt
+ else
+ return result
+ end
+end
+
+local function globalstep(dtime)
+ globalstep_time = globalstep_time + dtime
+ if globalstep_time < 0 then
+ return
+ end
+ globalstep_time = globalstep_time - 5
+
+ if first_run then
+ first_run = false
+ return first_globalstep()
+ end
+
+ local rwtime = rwt.to_secs(rwt.get_time())
+ local rwtime_limit = rwtime + 3600
+ -- Shromáždit rozhlasy:
+ local subscriptions = {--[[
+ [stn] = {{
+ rozh_pos = vector,
+ rozh_epos = string,
+ rozh_def = table,
+ signs = {[1..4] = vector or nil} or nil,
+ }...}
+ ]]}
+ local signs = {}
+ for stn, stdata in pairs(advtrains.lines.stations) do
+ local anns = stdata.anns
+ if stdata.anns ~= nil then
+ for rozh_epos, ann in pairs(stdata.anns) do
+ local rozh_pos = advtrains.decode_pos(rozh_epos)
+ local is_admin = core.check_player_privs(assert(ann.owner), "protection_bypass")
+ local signs_count = 0
+ for i = 1, 4 do
+ local cedule = assert(ann.cedule[i])
+ local s = cedule.fs
+ if s ~= nil and s ~= "" then
+ local sign_pos = assert(cedule.pos)
+ if core.compare_block_status(sign_pos, "active") then
+ signs[i] = sign_pos
+ signs_count = signs_count + 1
+ if not is_admin then
+ local sign_meta = core.get_meta(sign_pos)
+ local sign_owner = sign_meta:get_string("owner")
+ if sign_meta:get_int("access_level") ~= 1 and sign_owner ~= "" and ann.owner ~= sign_owner then
+ -- unauthorized access to the sign
+ core.log("warning", "Station announcement "..core.pos_to_string(rozh_pos).." owned by '"..
+ ann.owner.."' cannot write to sign at "..core.pos_to_string(sign_pos).." owned by '"..
+ sign_owner.."'! Access denied.")
+ signs[i] = nil
+ signs_count = signs_count - 1
+ end
+ end
+ end
+ end
+ end
+ if signs_count > 0 then
+ -- nějaké cedule jsou aktivní
+ table.insert(goa(subscriptions, stn), {rozh_pos = rozh_pos, rozh_epos = rozh_epos, rozh_def = ann, signs = signs})
+ signs = {}
+ elseif core.compare_block_status(rozh_pos, "active") then
+ -- cedule nejsou aktivní, ale rozhlas ano
+ table.insert(goa(subscriptions, stn), {rozh_pos = rozh_pos, rozh_epos = rozh_epos, rozh_def = ann})
+ end
+ end
+ end
+ end
+
+ -- Shromáždit vlaky:
+ local by_stn = {}
+ for stn, _ in pairs(subscriptions) do
+ by_stn[stn] = {}
+ end
+ local start_by_linevar = {}
+ local destination_by_linevar = {}
+ local name_by_stn = {}
+
+ for _, train in pairs(advtrains.trains) do
+ local ls, linevar_def = al.get_line_status(train)
+ if linevar_def ~= nil then
+ local prediction = al.predict_train(ls, linevar_def, rwtime, true)
+ local last_pos = al.get_last_pos_station_name(ls) or ""
+ for i, record in ipairs(prediction) do
+ local records = by_stn[record.stn]
+ if
+ records ~= nil and
+ (record.dep ~= nil or record.arr ~= nil) and
+ (record.dep == nil or record.dep < rwtime_limit) and
+ (record.arr == nil or record.arr < rwtime_limit)
+ then
+ -- nutno doplnit: start, destination, prev_stop, next_stop, last_pos
+ record.last_pos = last_pos -- název poslední dopravny, kde byl vlak spatřen
+ if record.final and record.arr ~= nil and record.dep ~= nil and record.arr_linevar_def.name ~= record.dep_linevar_def.name then
+ -- změna linky => rozdělit na příjezd a odjezd
+ local record2 = table.copy(record)
+ record2.dep = nil
+ record2.dep_linevar_def = nil
+ record2.dep_index = nil
+ record2.start = get_start_by_linevar_def(start_by_linevar, record.arr_linevar_def)
+ local other_index, other_data = al.get_prev_stop(record.arr_linevar_def, record.arr_index, false)
+ if other_index ~= nil then
+ record2.prev_stop = get_name_by_stn(name_by_stn, other_data.stn, "")
+ end
+ record2.next_stop = ""
+ record2.destination = get_destination_by_linevar_def(destination_by_linevar, record.arr_linevar_def)
+ table.insert(records, record2)
+ record.arr = nil
+ record.arr_linevar_def = nil
+ record.arr_index = nil
+ record.start = get_start_by_linevar_def(start_by_linevar, record.dep_linevar_def)
+ record.prev_stop = ""
+ other_index, other_data = al.get_next_stop(record.dep_linevar_def, record.dep_index, false)
+ if other_index ~= nil then
+ record.next_stop = get_name_by_stn(name_by_stn, other_data.stn, "")
+ end
+ record.destination = get_destination_by_linevar_def(destination_by_linevar, record.dep_linevar_def)
+ table.insert(records, record)
+ elseif record.dep ~= nil then
+ -- odjezd nebo příjezd/odjezd (ale na stejné lince!)
+ local linevar_def = record.dep_linevar_def
+ local index = record.dep_index
+ record.start = get_start_by_linevar_def(start_by_linevar, linevar_def)
+ record.destination = get_destination_by_linevar_def(destination_by_linevar, linevar_def)
+ record.prev_stop = ""
+ record.next_stop = ""
+ local other_index, other_data
+ if record.arr ~= nil then
+ other_index, other_data = al.get_prev_stop(linevar_def, index, false)
+ if other_index ~= nil then
+ record.prev_stop = get_name_by_stn(name_by_stn, other_data.stn, "")
+ end
+ end
+ other_index, other_data = al.get_next_stop(linevar_def, index, false)
+ if other_index ~= nil then
+ record.next_stop = get_name_by_stn(name_by_stn, other_data.stn, "")
+ end
+ record.destination = get_destination_by_linevar_def(destination_by_linevar, linevar_def)
+ table.insert(records, record)
+ elseif record.arr ~= nil then
+ -- jen příjezd
+ local linevar_def = record.arr_linevar_def
+ local index = record.arr_index
+ record.start = get_start_by_linevar_def(start_by_linevar, linevar_def)
+ local other_index, other_data = al.get_prev_stop(linevar_def, index, false)
+ if other_index ~= nil then
+ record.prev_stop = get_name_by_stn(name_by_stn, other_data.stn, "")
+ else
+ record.prev_stop = ""
+ end
+ record.next_stop = ""
+ record.destination = get_destination_by_linevar_def(destination_by_linevar, linevar_def)
+ table.insert(records, record)
+ end
+ end
+ end
+ end
+ end
+
+ -- Aktualizovat rozhlasy:
+ for stn, records in pairs(by_stn) do
+ local deps = records
+ local arrs = table.copy(records)
+ table.sort(deps, function(a, b)
+ return assert(a.dep or a.arr) < assert(b.dep or b.arr)
+ end)
+ table.sort(arrs, function(a, b)
+ return (a.arr or 1.0e+100) < (b.arr or 1.0e+100)
+ end)
+ for i = #arrs, 1, -1 do
+ if arrs[i].arr == nil then
+ arrs[i] = nil -- ponechat jen příjezdy v rámci nejbližší hodiny
+ end
+ end
+ for _, ann in ipairs(subscriptions[stn]) do
+ if ann.rmode ~= RMODE_ARR then
+ update_ann(assert(stn), assert(ann.rozh_epos), ann.signs, deps, rwtime)
+ else
+ update_ann(assert(stn), assert(ann.rozh_epos), ann.signs, arrs, rwtime)
+ end
+ end
+ end
+end
+
+core.register_globalstep(globalstep)
+
+local function can_dig(pos, player)
+ if player ~= nil and core.is_player(player) then
+ local owner = core.get_meta(pos):get_string("owner")
+ local player_name = player:get_player_name()
+ return owner == "" or owner == player_name or core.check_player_privs(player_name, "protection_bypass")
+ end
+ return false
+end
+
+local function on_construct(pos)
+ local meta = core.get_meta(pos)
+ meta:set_string("infotext", "staniční rozhlas")
+end
+
+local function on_destruct(pos)
+ local meta = core.get_meta(pos)
+ local stn = meta:get_string("stn")
+ if stn ~= "" then
+ local epos = advtrains.encode_pos(pos)
+ local stdata = advtrains.lines.stations[stn]
+ if stdata ~= nil then
+ (stdata.anns or {})[epos] = nil -- odstranit data staničního rozhlasu
+ end
+ end
+end
+
+local function on_dig(pos, node, digger)
+ -- TODO?
+ -- return core.node_dig(pos, node, digger)
+ if not can_dig(pos, digger) then
+ return false
+ end
+ if has_unifieddyes then
+ return unifieddyes.on_dig(pos, node, digger)
+ else
+ return core.node_dig(pos, node, digger)
+ end
+end
+
+local function on_rightclick(pos, node, clicker, itemstack, pointed_thing)
+ if clicker == nil or not clicker:is_player() then
+ return
+ end
+ local player_name = assert(clicker:get_player_name())
+ local meta = core.get_meta(pos)
+ local owner = meta:get_string("owner")
+ local stn = meta:get_string("stn")
+ local epos = advtrains.encode_pos(pos)
+ local stdata = advtrains.lines.stations[stn]
+ if owner == "" or stn == "" or stdata == nil or stdata.anns == nil or stdata.anns[epos] == nil then
+ if not core.check_player_privs(clicker, "railway_operator") then
+ core.chat_send_player(player_name, "*** K instalaci staničního rozhlasu je nutné právo railway_operator!")
+ return
+ end
+ local limit = 256 * 256
+ local stations = advtrains.lines.load_stations_for_formspec()
+ local list = {}
+ for i, station_data in ipairs(stations) do
+ local d2 = limit
+ for _, stop in ipairs(station_data.tracks) do
+ local d2new = dist2(pos, stop.pos)
+ if d2new < d2 then
+ d2 = d2new
+ end
+ end
+ if d2 < limit then
+ table.insert(list, {
+ stn = assert(station_data.stn),
+ name = assert(station_data.name),
+ distance = math.floor(math.sqrt(d2)),
+ })
+ end
+ end
+ table.sort(list, function(a, b) return a.distance < b.distance end)
+ local custom_state = {
+ pos = pos,
+ epos = advtrains.encode_pos(pos),
+ list = list,
+ }
+ local formspec = {
+ "formspec_version[6]"..
+ "size[15,8]"..
+ "button_exit[14,0.25;0.75,0.75;close;X]"..
+ "item_image[0.5,0.5;1,1;"..rozhlas_node_name.."]"..
+ "label[1.75,1;staniční rozhlas]"..
+ "label[0.5,2.25;vyberte dopravnu:]"..
+ "button_exit[0.5,6.75;14,1;zvolit_dopravnu;Zvolit]"..
+ "textlist[0.5,2.5;14,4;dopravna;",
+ }
+ if #list > 0 then
+ for i, candidate in ipairs(list) do
+ if i ~= 1 then
+ table.insert(formspec, ",")
+ end
+ table.insert(formspec, F(candidate.stn.." | "..candidate.name.." ("..candidate.distance.." m)"))
+ end
+ custom_state.selection_index = 1
+ table.insert(formspec, ";1]")
+ else
+ table.insert(formspec, ";]")
+ end
+ ch_core.show_formspec(clicker, "advtrains_line_automation:init_rozhlas", table.concat(formspec), init_formspec_callback, custom_state, {})
+ return
+ end
+ if player_name ~= owner and not core.check_player_privs(player_name, "protection_bypass") then -- train_admin?
+ core.chat_send_player(player_name, "Nemáte oprávnění nastavovat tento staniční rozhlas!")
+ return
+ end
+ local stations = advtrains.lines.load_stations_for_formspec()
+ local selection_index
+ for i, station in ipairs(stations) do
+ if station.stn == stn then
+ selection_index = i
+ break
+ end
+ end
+ if selection_index == nil then
+ core.log("error", "Cannot determine selection index for the station '"..stn.."' in the list of stations!")
+ core.chat_send_player(player_name, "CHYBA: Vnitřní chyba: dopravna nenalezena ve výpisu!")
+ return
+ end
+ local custom_state = {
+ player_name = player_name,
+ is_admin = ch_core.get_player_role(player_name) == "admin",
+ pos = pos,
+ epos = epos,
+ owner = owner,
+ stn = assert(stn), -- kam byl staniční rozhlas dosud přiřazen
+ stations = stations, -- pro dropdown[]
+ station_index = selection_index, -- pro dropdown[]
+ data = assert(get_ann_data(stn, epos, true)),
+ page = PAGE_SETUP_1,
+ }
+ ch_core.show_formspec(clicker, "advtrains_line_automation:rozhlas", get_setup_formspec(custom_state),
+ setup_formspec_callback, custom_state, {})
+end
+
+local function selector_on_use(itemstack, user, pointed_thing)
+ if pointed_thing.type ~= "node" then
+ return
+ end
+ if user ~= nil then
+ local player_name = user:get_player_name()
+ local pc = punch_context[player_name]
+ if pc ~= nil then
+ local success, message = attach_sign(assert(pc.stn), assert(pc.epos), assert(pc.i), assert(pointed_thing.under))
+ if not success then
+ message = message.." Zaměřování bude zrušeno."
+ end
+ core.chat_send_player(player_name, message)
+ end
+ end
+ return ItemStack()
+end
+
+local box = {
+ type = "fixed",
+ fixed = {
+ {-0.125, 0.125, 0.25, 0.125, 0.5, 0.5},
+ {-0.25, 0.05, 0, 0.25, 0.45, 0.25},
+ },
+}
+
+def = {
+ description = "staniční rozhlas",
+ tiles = {{name = "default_steel_block.png", backface_culling = true}},
+ drawtype = "mesh",
+ mesh = "advtrains_tuber.obj",
+ paramtype = "light",
+ paramtype2 = "4dir",
+ selection_box = box,
+ collision_box = box,
+ groups = {oddly_breakable_by_hand = 3, ud_param2_colorable = 1},
+ sounds = default.node_sound_metal_defaults(),
+ can_dig = can_dig,
+ on_dig = on_dig,
+ on_construct = on_construct,
+ on_destruct = on_destruct,
+ on_rightclick = on_rightclick,
+}
+if has_unifieddyes then
+ def.paramtype2 = "color4dir"
+ def.palette = "unifieddyes_palette_color4dir.png"
+end
+core.register_node(rozhlas_node_name, def)
+
+def = {
+ description = "levým klikem zvolte ceduli pro připojení",
+ groups = {not_in_creative_inventory = 1, tool = 1},
+ inventory_image = "[combine:16x16:7,0=blank.png\\^[noalpha\\^[resize\\:2x16:0,7=blank.png\\^[noalpha\\^[resize\\:16x2",
+ wield_image = "blank.png",
+ on_use = selector_on_use,
+}
+
+core.register_tool("advtrains_line_automation:sign_selector", def)
+
+core.register_craft({
+ output = rozhlas_node_name,
+ recipe = {
+ {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
+ {"default:steel_ingot", "mesecons_noteblock:noteblock", "default:steel_ingot"},
+ {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
+ },
+})
diff --git a/advtrains_line_automation/station_editor.lua b/advtrains_line_automation/station_editor.lua
new file mode 100644
index 0000000..8de6919
--- /dev/null
+++ b/advtrains_line_automation/station_editor.lua
@@ -0,0 +1,1069 @@
+local def
+local F = minetest.formspec_escape
+local ch_core = advtrains.lines.ch_core
+--[[
+Jednoduchá funkce, která vyhodnotí condition jako podmínku
+a podle výsledku vrátí buď true_result, nebo false_result.
+]]
+local function ifthenelse(condition, true_result, false_result)
+ if condition then
+ return true_result
+ else
+ return false_result
+ end
+end
+local rwt = assert(advtrains.lines.rwt)
+
+-- Get current translator
+local S = advtrains.lines.translate
+
+-- Singularis-Merge: Emulate certain ch functionality
+local function systemovy_kanal(pname, message)
+ core.chat_send_player(pname, S("[Station Editor]")..message)
+end
+local function prihlasovaci_na_zobrazovaci(prihlasovaci)
+ return prihlasovaci -- no-op. On CH used to colorize the name to reflect the rank of the player
+end
+
+local function load_stations()
+ local result = {}
+ local by_stn = {}
+ local all_lines_set = {["*"] = true}
+ local lines_set = {}
+ for stn, data in pairs(advtrains.lines.stations) do
+ local new_station = {
+ stn = stn,
+ name = data.name or "",
+ owner = data.owner or "",
+ tracks = {},
+ }
+ by_stn[stn] = new_station
+ lines_set[stn] = {}
+ table.insert(result, new_station)
+ end
+ for epos, data in pairs(advtrains.lines.stops) do
+ if data.stn ~= nil and data.stn ~= "" and by_stn[data.stn] ~= nil then
+ local st = by_stn[data.stn]
+ local new_track = {
+ epos = epos,
+ pos = assert(advtrains.decode_pos(epos)),
+ track = data.track or "",
+ }
+ table.insert(st.tracks, new_track)
+ local ars = data.ars
+ if ars ~= nil then
+ if ars.default then
+ lines_set[data.stn] = all_lines_set
+ else
+ local set = lines_set[data.stn]
+ for _, rule in ipairs(ars) do
+ if not rule.n and rule.ln ~= nil then
+ set[rule.ln] = true
+ end
+ end
+ end
+ end
+ end
+ end
+ for _, st in ipairs(result) do
+ local set = lines_set[st.stn]
+ if set["*"] then
+ st.lines = {"*"}
+ else
+ local lines = {}
+ for line, _ in pairs(set) do
+ table.insert(lines, line)
+ end
+ table.sort(lines)
+ st.lines = lines
+ end
+ end
+ table.sort(result, function(a, b) return a.stn < b.stn end)
+ return result
+end
+
+advtrains.lines.load_stations_for_formspec = load_stations
+
+local function station_distance(player_pos, st)
+ if st.tracks[1] == nil then
+ return -- no tracks
+ end
+ local distance = vector.distance(player_pos, st.tracks[1].pos)
+ for i = 2, #st.tracks do
+ local d2 = vector.distance(player_pos, st.tracks[i].pos)
+ if d2 < distance then
+ distance = d2
+ end
+ end
+ return distance
+end
+
+local function station_distance_s(player_pos, st)
+ local result = station_distance(player_pos, st)
+ if result ~= nil then
+ return string.format("%d m", result)
+ else
+ return ""
+ end
+end
+
+
+local function filter_all()
+ return true
+end
+
+local function filter_mine(a, player_info)
+ return a.owner == player_info.name
+end
+
+local function sort_by_distance(a, b, player_info)
+ return (station_distance(player_info.pos, a) or 1.0e+20) < (station_distance(player_info.pos, b) or 1.0e+20)
+end
+
+local function sort_by_stn(a, b)
+ return tostring(a.stn) < tostring(b.stn)
+end
+
+local function sort_by_name(a, b)
+ local a_key, b_key = ch_core.utf8_radici_klic(a.name, false), ch_core.utf8_radici_klic(b.name, false)
+ if a_key ~= b_key then
+ return a_key < b_key
+ else
+ return sort_by_stn(a, b)
+ end
+end
+
+local filters = {
+ {
+ description = S("By Distance"),
+ -- filter = filter_all,
+ sorter = sort_by_distance,
+ },
+ {
+ description = S("Station Code (A-Z)"),
+ -- filter = filter_all,
+ sorter = sort_by_stn,
+ },
+ {
+ description = S("Station Name (A-Z)"),
+ -- filter = filter_all,
+ sorter = sort_by_name,
+ },
+ {
+ description = S("My Stations (Station Code A-Z)"),
+ filter = filter_mine,
+ sorter = sort_by_stn,
+ },
+ {
+ description = S("My Stations (Station Name A-Z)"),
+ filter = filter_mine,
+ sorter = sort_by_name,
+ },
+ {
+ description = S("My Stations (By Distance)"),
+ filter = filter_mine,
+ sorter = sort_by_distance,
+ },
+}
+
+
+local function get_formspec(custom_state)
+ local pinfo = ch_core.normalize_player(assert(custom_state.player_name))
+ if pinfo.player == nil then
+ minetest.log("error", "Expected player not in game!")
+ return ""
+ end
+ local player_info = {
+ name = assert(custom_state.player_name),
+ pos = assert(custom_state.player_pos),
+ }
+
+ local stations = custom_state.stations
+ if stations == nil then
+ local filter = filters[custom_state.active_filter]
+ local filter_func = filter.filter or filter_all
+ local sorter_func = filter.sorter
+ stations = {}
+ for _, st in ipairs(load_stations()) do
+ if filter_func(st, player_info) then
+ table.insert(stations, st)
+ end
+ end
+ table.sort(stations, function(a, b) return sorter_func(a, b, player_info) end)
+ custom_state.stations = stations
+ if custom_state.selection_index ~= nil and custom_state.selection_index > #stations + 1 then
+ custom_state.selection_index = nil
+ end
+ end
+
+ local selection_index = custom_state.selection_index
+ local formspec = {
+ ch_core.formspec_header({formspec_version = 6, size = {20, 10}, auto_background = true}),
+ "label[0.5,0.6;"..S("Station Editor").."]",
+ }
+
+ table.insert(formspec, "tablecolumns[image,"..
+ "0=ch_core_empty.png,"..
+ "1=basic_materials_padlock.png\\^[resize:16x16"..
+ ";text;text,width=25;color,span=1;text,width=7;text;text]"..
+ "table[0.5,1.25;19,5;dopravna;0,"..S("CODE")..","..S("NAME")..",#ffffff,"..S("OWNER")..","..S("DISTANCE")..","..S("INFO").."")
+ for _, st in ipairs(stations) do
+ local n_tracks = #st.tracks
+ table.insert(formspec, ",0,"..F(st.stn)..","..F(st.name)..",#ffffff,"..F(prihlasovaci_na_zobrazovaci(st.owner))..","..
+ F(station_distance_s(custom_state.player_pos, st))..", "..S("@1 tracks", n_tracks))
+ if n_tracks > 0 then
+ table.insert(formspec, "\\, "..S("lines").." " ..F(table.concat(st.lines, ",")))
+ end
+ end
+ table.insert(formspec, ";"..(selection_index or "").."]")
+
+ -- rozbalovací pole s volbou filtru a řazení
+ table.insert(formspec, "dropdown[8,0.3;7,0.6;filter;"..F(assert(filters[1].description)))
+ for i = 2, #filters do
+ table.insert(formspec, ","..F(filters[i].description))
+ end
+ table.insert(formspec, ";"..custom_state.active_filter..";true]")
+
+ table.insert(formspec, "button_exit[18.75,0.3;0.75,0.75;close;X]")
+
+ local st = selection_index ~= nil and stations[selection_index - 1]
+ local stn, nazev, spravuje
+ if st then
+ stn = F(st.stn)
+ nazev = F(st.name)
+ spravuje = F(prihlasovaci_na_zobrazovaci(st.owner))
+ else
+ stn, nazev, spravuje = "", "", F(pinfo.viewname)
+ end
+ table.insert(formspec,
+ "field[0.5,7;2.5,0.75;stn;"..S("Code:")..";"..stn.."]"..
+ "field[3.25,7;7,0.75;name;"..S("Name:")..";"..nazev.."]"..
+ ifthenelse(pinfo.role == "admin", "field[10.5,7;4,0.75;owner;"..S("Owner:")..";", "label[10.5,6.75;"..S("Owner:").."\n")..
+ spravuje.."]")
+ if pinfo.role ~= "new" then
+ table.insert(formspec, "button[0.5,8;4.5,0.75;vytvorit;"..S("Create New").."]"..
+ "button[10,8;4.5,0.75;jrad;"..S("Timetables...").."]")
+ if st and (pinfo.role == "admin" or st.owner == pinfo.player_name) then
+ table.insert(formspec, "button[5.25,8;4.5,0.75;ulozit;"..S("Save Changes").."]")
+ if st.tracks[1] == nil then
+ table.insert(formspec, "button[15.25,8;3,0.75;smazat;"..S("Delete").."]")
+ end
+ if custom_state.linevars[1] ~= nil then
+ table.insert(formspec, "label[0.5,9.4;"..S("Assign Track").."]"..
+ "field[2.75,9.1;1,0.6;"..S("Track")..";;]"..
+ "label[3.9,9.4;"..S("Lines").."]"..
+ "dropdown[5,9.1;5,0.6;klinevar;")
+ for i, lvar in ipairs(custom_state.linevars) do
+ if i ~= 1 then
+ table.insert(formspec, ",")
+ end
+ table.insert(formspec, F(lvar.linevar.." | "..lvar.dep.." "..stn.." ["..lvar.track.."]"))
+ end
+ table.insert(formspec, ";"..custom_state.current_linevar..";true]"..
+ "button[10.25,9;4.25,0.75;priradit_kolej;"..S("Assign").."]"..
+ "tooltip[klinevar;")
+ table.insert(formspec, F("Vysvětlení formátu:\n<linka>/<kód vých.dop.>/<sm.kód> | <odjezd> <kód dop.> [<stávající kolej>]"))
+ table.insert(formspec, "]")
+ end
+ end
+ end
+ if st and st.tracks[1] ~= nil then
+ table.insert(formspec, "textarea[14.75,7;4.75,2.5;;"..S("Positions of tracks:")..";"..F(minetest.pos_to_string(st.tracks[1].pos)))
+ for i = 2, #st.tracks do
+ table.insert(formspec, "\n"..F(minetest.pos_to_string(st.tracks[i].pos)))
+ end
+ table.insert(formspec, "]")
+ end
+ return table.concat(formspec)
+end
+
+local function formspec_callback(custom_state, player, formname, fields)
+ local update_formspec = false
+ if fields.vytvorit then
+ local new_stn, new_name, new_owner = fields.stn, fields.name or "", fields.owner
+ local pinfo = ch_core.normalize_player(player)
+ if pinfo.role ~= "admin" or new_owner == nil or new_owner == "" then
+ new_owner = pinfo.player_name
+ else
+ --new_owner = ch_core.jmeno_na_prihlasovaci(new_owner)
+ end
+ if new_stn == nil or new_stn == "" then
+ systemovy_kanal(custom_state.player_name, S("ERROR: Code must not be empty!"))
+ return
+ end
+ local als = advtrains.lines.stations
+ if als[new_stn] ~= nil then
+ systemovy_kanal(custom_state.player_name, S("ERROR: Station '@1' already exists!", new_stn))
+ return
+ end
+ als[new_stn] = {name = assert(new_name), owner = assert(new_owner)}
+ custom_state.stations = nil
+ update_formspec = true
+ systemovy_kanal(custom_state.player_name, S("Station successfully created."))
+ elseif fields.ulozit then
+ local new_stn, new_name, new_owner = fields.stn, fields.name or "", fields.owner
+ local pinfo = ch_core.normalize_player(player)
+ local st = custom_state.stations[(custom_state.selection_index or 0) - 1]
+ if st == nil then
+ systemovy_kanal(custom_state.player_name, S("ERROR: No such station!"))
+ return
+ end
+ local change_stn, change_name = st.stn ~= new_stn, st.name ~= new_name
+ local change_owner = pinfo.role == "admin" and fields.owner ~= nil and fields.owner ~= "" and
+ fields.owner ~= st.owner -- ch_core.jmeno_na_prihlasovaci(fields.owner) ~= st.owner
+ if not change_stn and not change_name and not change_owner then
+ systemovy_kanal(custom_state.player_name, S("Nothing has changed."))
+ return
+ end
+ local t = advtrains.lines.stations[st.stn]
+ if t == nil then
+ systemovy_kanal(custom_state.player_name, "CHYBA: zastávka k úpravě nebyla nalezena! Toto je pravděpodobně vnitřní chyba editoru.")
+ return
+ end
+ if change_stn then
+ -- zkontrolovat, že cílový kód je volný
+ if advtrains.lines.stations[new_stn] ~= nil then
+ systemovy_kanal(custom_state.player_name, S("ERROR: Station '@1' already exists!", new_stn))
+ return
+ end
+ end
+ if change_owner then
+ t.owner = fields.owner -- ch_core.jmeno_na_prihlasovaci(fields.owner)
+ systemovy_kanal(custom_state.player_name, S("Owner changed!"))
+ end
+ if change_name then
+ t.name = new_name
+ systemovy_kanal(custom_state.player_name, S("Name changed!"))
+ end
+ if change_stn then
+ advtrains.lines.stations[new_stn] = t
+ local stops = advtrains.lines.stops
+ local count = 0
+ for _, trackinfo in ipairs(st.tracks) do
+ local stop = stops[trackinfo.epos]
+ if stop == nil then
+ minetest.log("error", "Expected track at position "..trackinfo.epos.." not found!")
+ elseif stop.stn ~= st.stn then
+ minetest.log("error", "Track at position "..trackinfo.epos.." has unexpected stn '"..tostring(stop.stn).."' instead of '"..st.stn.."'!")
+ else
+ stop.stn = new_stn
+ count = count + 1
+ end
+ end
+ advtrains.lines.stations[st.stn] = nil
+ systemovy_kanal(custom_state.player_name, S("Code changed, @1 station tracks updated!", count))
+ end
+ custom_state.stations = nil
+ update_formspec = true
+ elseif fields.smazat then
+ local pinfo = ch_core.normalize_player(player)
+ local st = custom_state.stations[(custom_state.selection_index or 0) - 1]
+ if st == nil then
+ systemovy_kanal(custom_state.player_name, S("ERROR: No stop selected!"))
+ return
+ end
+ if st.tracks[1] ~= nil then
+ systemovy_kanal(custom_state.player_name, S("ERROR: There are station tracks assigned, cannot delete the station!"))
+ return
+ end
+ local t = advtrains.lines.stations[st.stn]
+ if t == nil then
+ systemovy_kanal(custom_state.player_name, "CHYBA: zastávka k úpravě nebyla nalezena! Toto je pravděpodobně vnitřní chyba editoru.")
+ return
+ end
+ advtrains.lines.stations[st.stn] = nil
+ systemovy_kanal(custom_state.player_name, S("Station deleted!"))
+ custom_state.stations = nil
+ update_formspec = true
+ elseif fields.jrad then
+ local st = custom_state.stations[(custom_state.selection_index or 0) - 1]
+ if st == nil then
+ systemovy_kanal(custom_state.player_name, S("ERROR: No stop selected!"))
+ return
+ end
+ advtrains.lines.show_jr_formspec(player, nil, assert(st.stn))
+ return
+ elseif fields.priradit_kolej then
+ local st = custom_state.stations[(custom_state.selection_index or 0) - 1]
+ if st == nil then
+ systemovy_kanal(custom_state.player_name, S("ERROR: No stop selected!"))
+ return
+ end
+ local linevar_to_change = custom_state.linevars[custom_state.current_linevar]
+ if linevar_to_change == nil then
+ systemovy_kanal(custom_state.player_name, "CHYBA: vnitřní chyba 1!")
+ return
+ end
+ local linevar_def = advtrains.lines.try_get_linevar_def(linevar_to_change.linevar, linevar_to_change.stn)
+ if linevar_def == nil then
+ systemovy_kanal(custom_state.player_name, "CHYBA: vnitřní chyba 2!")
+ return
+ end
+ local stop = linevar_def.stops[linevar_to_change.linevar_index]
+ if stop == nil then
+ systemovy_kanal(custom_state.player_name, "CHYBA: vnitřní chyba 3!")
+ return
+ end
+ if stop.stn ~= st.stn then
+ systemovy_kanal(custom_state.player_name, "CHYBA: vnitřní chyba 4!")
+ return
+ end
+ stop.track = tostring(fields.kolej)
+ linevar_to_change.track = stop.track
+ systemovy_kanal(custom_state.player_name, S("Track successfully assigned!"))
+ update_formspec = true
+ elseif fields.quit then
+ return
+ end
+
+ if fields.dopravna then
+ local event = minetest.explode_table_event(fields.dopravna)
+ if event.type == "CHG" then
+ custom_state.selection_index = ifthenelse(event.row > 1, event.row, nil)
+ local st = custom_state.stations[(custom_state.selection_index or 0) - 1]
+ local new_linevars = {}
+ custom_state.linevars = new_linevars
+ custom_state.current_linevar = 1
+ if st ~= nil then
+ for _, r in ipairs(advtrains.lines.get_linevars_by_station(st.stn)) do
+ local line, stn = advtrains.lines.linevar_decompose(r.linevar)
+ for _, i in ipairs(r.indices) do
+ local stop = r.linevar_def.stops[i]
+ table.insert(new_linevars, {
+ stn = stn,
+ linevar = r.linevar,
+ linevar_index = i,
+ dep = assert(stop.dep),
+ track = stop.track or "",
+ })
+ end
+ end
+ end
+ update_formspec = true
+ end
+ end
+
+ if fields.klinevar then
+ local n = tonumber(fields.klinevar)
+ if n ~= nil and custom_state.linevars[n] ~= nil then
+ custom_state.current_linevar = n
+ end
+ end
+
+ -- filter (must be the last)
+ if fields.filter then
+ local new_filter = tonumber(fields.filter)
+ if filters[new_filter] ~= nil and new_filter ~= custom_state.active_filter then
+ custom_state.active_filter = new_filter
+ custom_state.stations = nil
+ update_formspec = true
+ end
+ end
+ if update_formspec then
+ return get_formspec(custom_state)
+ end
+end
+
+local function show_formspec(player)
+
+ local custom_state = {
+ player_name = assert(player:get_player_name()),
+ player_pos = vector.round(player:get_pos()),
+ active_filter = 1,
+ -- selection_index = nil,
+ linevars = {--[[
+ {stn = string, linevar = string, linevar_index = int, track = string}...
+ ]]},
+ current_linevar = 1,
+ }
+ -- ch_core.show_formspec(player_or_player_name, formname, formspec, formspec_callback, custom_state, options)
+ ch_core.show_formspec(player, "advtrains_line_automation:editor_dopraven", get_formspec(custom_state), formspec_callback, custom_state, {})
+end
+
+advtrains.lines.open_station_editor = show_formspec
+
+def = {
+ -- params = "",
+ description = S("Open station editor"),
+ privs = {railway_operator = true},
+ func = function(player_name, param) show_formspec(minetest.get_player_by_name(player_name)) end,
+}
+core.register_chatcommand("station_editor", def)
+
+
+-- Jízdní řád
+
+--[[
+ custom_state = {
+ pos = vector or nil, -- node position (will use metadata to determine the owner)
+ player_name = string, -- player to whom the formspec is to be shown (will use this to determine privs)
+ stn = int, -- station selection from stns
+ stns = {
+ {stn = "", fs = "(vyberte dopravnu)", name_fs = ""},
+ {stn = string, fs = string, name_fs = string}...
+ }, -- the list of stations to select from; the first must be "", which means no station
+ track = int, -- selection of track from "tracks" list
+ tracks = {"", string...}, -- the list of tracks to select from; the first must be "", which means all tracks
+ linevar = int,
+ linevars = {{
+ stn = string, -- station from linevar
+ linevar = string, -- linevar
+ line_fs = string, -- line for formspec
+ target_fs = string, -- terminus name for formspec
+ track_fs = string, -- track info for formspec ("" if not available)
+ status_fs = string, -- line status for formspec (including color column)
+ train_name_fs = string, -- train name for formspec ("" if not available)
+ linevar_index = int, -- index of the selected station (stn) in linevar_def.stops of this linevar
+ }...},
+ stop = int,
+ stops = {{
+ stn = string,
+ name_fs = string,
+ track_fs = string,
+ dep = int,
+ wait = int,
+ linevar_index = int, -- index of this stop in linevar_def.stops
+ }...},
+ message = string, -- message for label[] on the bottom; "" to disable
+ }
+]]
+
+local all_stations_record = {stn = "", fs = S("(select station)"), name_fs = ""}
+local is_visible_mode = assert(advtrains.lines.is_visible_mode)
+
+-- refresh custom_state.stops according to custom_state.linevar
+local function jr_refresh_stops(custom_state, stn_to_select)
+ if stn_to_select == "" then
+ stn_to_select = nil
+ end
+ local linevar_info = custom_state.linevars[custom_state.linevar]
+ local index_to_select = 0
+ local result = {}
+ if linevar_info ~= nil then
+ local linevar_def = advtrains.lines.try_get_linevar_def(linevar_info.linevar, linevar_info.stn)
+ if linevar_def == nil then
+ -- invalid linevar => no stops
+ core.log("error", "Player "..custom_state.player_name.." selected invalid linevar "..linevars[linevar].linevar.."!")
+ else
+ local stops = linevar_def.stops
+ for linevar_index, stop_data in ipairs(linevar_def.stops) do
+ if is_visible_mode(stop_data.mode) then
+ local r = {
+ stn = assert(stop_data.stn),
+ name_fs = F(advtrains.lines.get_station_name(stop_data.stn)),
+ track_fs = stop_data.track or "",
+ dep = stop_data.dep,
+ wait = stop_data.wait or 10,
+ linevar_index = linevar_index,
+ }
+ if r.track_fs ~= "" then
+ r.track_fs = F("["..r.track_fs.."]")
+ end
+ table.insert(result, r)
+ if stn_to_select ~= nil and index_to_select == 0 and r.stn == stn_to_select then
+ index_to_select = #result -- stop selected
+ end
+ end
+ end
+ end
+ end
+ if index_to_select == 0 and result[1] ~= nil then
+ index_to_select = 1
+ end
+ custom_state.stop = index_to_select
+ custom_state.stops = result
+ custom_state.message = ""
+end
+
+local function get_all_linevars()
+ local result = {}
+ local empty_table = {}
+ local trains_by_linevar = advtrains.lines.get_trains_by_linevar()
+ 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}))
+ local status_fs
+ if trains_by_linevar[linevar] ~= nil then
+ status_fs = "#00ff00,"..S("in operation")
+ else
+ status_fs = "#999999,"..S("unknown state")
+ end
+ table.insert(result, {
+ stn = stn,
+ linevar = linevar,
+ line_fs = F(line),
+ target_fs = target_fs,
+ track_fs = "",
+ status_fs = status_fs,
+ train_name_fs = F(linevar_def.train_name or ""),
+ linevar_index = 1,
+ })
+ end
+ end
+ table.sort(result, function(a, b) return a.linevar < b.linevar end)
+ return result
+end
+
+--[[
+ stn_filter = string,
+ track_filter = string or nil,
+]]
+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}
+ local trains_by_linevar = advtrains.lines.get_trains_by_linevar()
+ assert(stn_filter)
+ if track_filter == "" then
+ track_filter = nil
+ end
+ for stn, stdata in pairs(advtrains.lines.stations) do
+ for linevar, linevar_def in pairs(stdata.linevars or empty_table) do
+ local last_stop_index = advtrains.lines.get_last_stop(linevar_def, false)
+ if last_stop_index ~= nil then
+ for linevar_index = 1, last_stop_index - 1 do -- NOTE: the last visible station is intentionally ignored here!
+ local stop_data = linevar_def.stops[linevar_index]
+ local initialized = false
+ local line, stn, line_fs, target_fs, status_fs
+ if
+ stop_data.stn == stn_filter and
+ is_visible_mode(stop_data.mode) and
+ (track_filter == nil or track_filter == stop_data.track)
+ then
+ if not initialized then
+ initialized = true
+ line, stn = advtrains.lines.linevar_decompose(linevar)
+ line_fs = F(line)
+ target_fs = F(advtrains.lines.get_line_description(linevar_def, line_description_options))
+ if trains_by_linevar[linevar] ~= nil then
+ status_fs = "#00ff00,"..S("in operation")
+ else
+ status_fs = "#999999,"..S("unknown state")
+ end
+ end
+ local track_fs = stop_data.track
+ if track_fs == nil or track_fs == "" then
+ track_fs = ""
+ else
+ track_fs = F("["..track_fs.."]")
+ end
+ table.insert(result, {
+ stn = stn,
+ linevar = linevar,
+ line_fs = line_fs,
+ target_fs = target_fs,
+ track_fs = track_fs,
+ status_fs = status_fs,
+ train_name_fs = F(linevar_def.train_name or ""),
+ linevar_index = assert(linevar_index),
+ })
+ end
+ end
+ end
+ end
+ end
+ table.sort(result, function(a, b)
+ if a.linevar ~= b.linevar then
+ return a.linevar < b.linevar
+ else
+ return a.linevar_index < b.linevar_index
+ end
+ end)
+ return result
+end
+
+local function is_jr_node_name(name)
+ return core.get_item_group(name, "ch_jrad") ~= 0
+end
+
+-- refresh custom_state.linevars according to custom_state.stn and custom_state.track
+local function jr_refresh_linevars(custom_state, linevar_to_select, linevar_index_to_select)
+ if linevar_to_select == "" then
+ linevar_to_select = nil
+ end
+ assert(linevar_index_to_select == nil or type(linevar_index_to_select) == "number")
+ local stn = assert(custom_state.stn)
+ local stn_info = assert(custom_state.stns[stn])
+ local track = assert(custom_state.track)
+ local tracks = assert(custom_state.tracks)
+
+ local new_linevars
+ if stn_info.stn == "" then
+ new_linevars = get_all_linevars()
+ else
+ new_linevars = get_linevars_by_filter(stn_info.stn, assert(tracks[track]))
+ end
+ local index_to_select = 1
+ if linevar_to_select ~= nil then
+ for i, r in ipairs(new_linevars) do
+ if r.linevar == linevar_to_select and (linevar_index_to_select == nil or r.linevar_index == linevar_index_to_select) then
+ index_to_select = i
+ break
+ end
+ end
+ end
+ if new_linevars[index_to_select] == nil then
+ index_to_select = 0
+ end
+ custom_state.linevars = new_linevars
+ custom_state.linevar = index_to_select
+ custom_state.message = ""
+
+ local pos = custom_state.pos
+ if pos ~= nil and is_jr_node_name(core.get_node(pos).name) then
+ local meta = core.get_meta(pos)
+ meta:set_string("stn", custom_state.stns[custom_state.stn].stn)
+ meta:set_string("track", custom_state.tracks[custom_state.track])
+ local infotext = {"jízdní řád\n"}
+ if stn_info.stn == "" then
+ table.insert(infotext, "<všechny linky>")
+ else
+ table.insert(infotext, advtrains.lines.get_station_name(stn_info.stn))
+ if custom_state.tracks[custom_state.track] ~= "" then
+ table.insert(infotext, " ["..custom_state.tracks[custom_state.track].."]")
+ end
+ end
+ if new_linevars[1] ~= nil then
+ local prefix = "\n"
+ local set = {[""] = true}
+ for _, linevar_info in ipairs(new_linevars) do
+ local line = advtrains.lines.linevar_decompose(linevar_info.linevar)
+ if not set[line] then
+ set[line] = true
+ table.insert(infotext, prefix.."["..line.."]")
+ prefix = " "
+ end
+ end
+ end
+ meta:set_string("infotext", table.concat(infotext))
+ end
+end
+
+-- refresh custom_state.tracks according to custom_state.stn
+-- and selects a specified track, if available
+local function jr_refresh_tracks(custom_state, track_to_select)
+ if track_to_select == "" then
+ track_to_select = nil
+ end
+ local result = {""}
+ local index_to_select = 1
+ local current_stn = custom_state.stns[custom_state.stn].stn
+ if current_stn ~= "" and advtrains.lines.stations[current_stn] ~= nil then
+ local track_set = {[""] = true}
+ -- search for tracks:
+ for epos, stdata in pairs(advtrains.lines.stops) do
+ if stdata.stn == current_stn and stdata.track ~= nil and not track_set[stdata.track] then
+ track_set[stdata.track] = true
+ table.insert(result, tostring(stdata.track))
+ end
+ end
+ if #result > 1 then
+ table.sort(result)
+ assert(result[1] == "")
+ if track_to_select ~= nil then
+ for i, track in ipairs(result) do
+ if track_to_select == track then
+ index_to_select = i
+ end
+ end
+ end
+ end
+ end
+ custom_state.tracks = result
+ custom_state.track = index_to_select
+ custom_state.message = ""
+end
+
+--[[
+ -- will refresh custom_state.stns[] and (optionally) select a wanted station if it's on the list,
+ -- otherwise the default 'select station' option will be chosen
+ custom_state = table,
+ stn_to_select = string or nil,
+]]
+local function jr_refresh_stns(custom_state, stn_to_select)
+ if stn_to_select == "" then
+ stn_to_select = nil
+ end
+ local result = {all_stations_record}
+ local index_to_select = 1
+ for i, st in ipairs(load_stations()) do
+ result[1 + i] = {
+ stn = assert(st.stn),
+ fs = F(st.stn.." | "..st.name),
+ name_fs = F(st.name),
+ }
+ if stn_to_select ~= nil and st.stn == stn_to_select then
+ index_to_select = 1 + i
+ end
+ end
+ custom_state.stns = result
+ custom_state.stn = index_to_select
+ custom_state.message = ""
+end
+
+-- will refresh a departure message according to linevar + stop
+local function jr_refresh_departure(custom_state)
+ local linevar_info = custom_state.linevars[custom_state.linevar]
+ local stop_info = custom_state.stops[custom_state.stop]
+ if linevar_info == nil or stop_info == nil then
+ custom_state.message = ""
+ return
+ end
+ local linevar_def = advtrains.lines.try_get_linevar_def(linevar_info.linevar)
+ if linevar_def == nil then
+ custom_state.message = ""
+ return
+ end
+ local rwtime = rwt.now()
+ local prediction = advtrains.lines.predict_station_departures(linevar_def, assert(stop_info.linevar_index), rwtime)
+ if #prediction == 0 then
+ custom_state.message = S("No departures for the selected line found in the near future")
+ return
+ end
+ local deps = {}
+ for i, pred in ipairs(prediction) do
+ deps[i] = tostring(rwt.diff(rwtime, pred.dep))
+ end
+ custom_state.message = S("next departures of the selected line in: ")..table.concat(deps, ", ").." s"
+end
+
+local function get_jr_formspec(custom_state)
+ local formspec = {
+ ch_core.formspec_header({
+ formspec_version = 6,
+ size = {20, 12},
+ auto_background = true,
+ })
+ }
+ local access_level = "player" -- player | owner | admin
+ local node_owner
+ if custom_state.pos ~= nil then
+ node_owner = core.get_meta(custom_state.pos):get_string("owner")
+ if node_owner == "" then
+ node_owner = nil
+ end
+ end
+ local stn, stn_owner
+ if custom_state.stn > 1 and custom_state.stns[custom_state.stn] ~= nil then
+ stn_owner = (advtrains.lines.stations[custom_state.stns[custom_state.stn].stn] or {}).owner -- may be nil
+ end
+
+ if not custom_state.force_unprivileged then
+ if core.check_player_privs(custom_state.player_name, {protection_bypass=true}) then -- TODO make a lines admin privilege
+ access_level = "admin"
+ elseif custom_state.player_name == node_owner or custom_state.player_name == stn_owner then
+ access_level = "owner"
+ end
+ end
+
+ if node_owner ~= nil then
+ if access_level ~= "player" then
+ -- admin or owner:
+ table.insert(formspec, "label[0.5,0.6;"..S("Timetables").."]"..
+ "dropdown[5,0.3;10,0.6;dopravna;")
+ for i, r in ipairs(custom_state.stns) do
+ table.insert(formspec, ifthenelse(i == 1, r.fs, ","..r.fs))
+ end
+ table.insert(formspec, ";"..custom_state.stn..";true]"..
+ "dropdown[15.25,0.3;3.5,0.6;kolej;")
+ for i, r in ipairs(custom_state.tracks) do
+ if i == 1 then
+ table.insert(formspec, S("(all platforms)"))
+ else
+ table.insert(formspec, ","..F(r))
+ end
+ end
+ table.insert(formspec, ";"..custom_state.track..";true]")
+ else
+ -- player (including 'new' players)
+ local stn_info = custom_state.stns[custom_state.stn]
+ if stn_info.stn == "" then
+ table.insert(formspec, "label[0.5,0.6;"..S("Timetables (all lines)").."]")
+ else
+ local track = custom_state.tracks[custom_state.track]
+ if track ~= "" then
+ track = F(" ["..track.."]")
+ end
+ table.insert(formspec, "label[0.5,0.6;"..S("Timetables: ")..stn_info.name_fs..track.."]")
+ end
+ end
+ if access_level ~= "admin" then
+ -- player/owner
+ table.insert(formspec, "label[0.5,1.65;"..S("Owner: "))
+ table.insert(formspec, prihlasovaci_na_zobrazovaci(node_owner))
+ if stn_owner ~= nil then
+ table.insert(formspec, " | "..S("Station Operator: "))
+ table.insert(formspec, prihlasovaci_na_zobrazovaci(stn_owner))
+ end
+ table.insert(formspec, "]")
+ else
+ -- admin only
+ table.insert(formspec, "label[0.5,1.65;"..S("Owner: ").."]"..
+ "field[2.75,1.25;5,0.75;owner;;")
+ table.insert(formspec, prihlasovaci_na_zobrazovaci(node_owner))
+ table.insert(formspec, "]button[8,1.25;3,0.75;setowner;"..S("Set").."]")
+ if stn_owner ~= nil then
+ table.insert(formspec, "label[11.25,1.65;"..S("Station Operator: ")..prihlasovaci_na_zobrazovaci(stn_owner).."]")
+ end
+ end
+ else
+ table.insert(formspec, "label[0.5,0.6;"..S("Timetable for current station (all lines)").."]")
+ end
+
+ table.insert(formspec, "tablecolumns[text,align=right,tooltip=Line;text,width=12,tooltip=Terminus;text,tooltip=Track;color,span=1;text,tooltip=Status;color,span=1;text,tooltip=Train Name]"..
+ "table[0.5,2.25;11,5;linka;")
+ for i, r in ipairs(custom_state.linevars) do
+ if i > 1 then
+ table.insert(formspec, ",")
+ end
+ table.insert(formspec, r.line_fs..","..r.target_fs..","..r.track_fs..","..r.status_fs..",#cccccc,"..r.train_name_fs)
+ end
+ table.insert(formspec, ifthenelse(custom_state.linevar > 0, ";"..custom_state.linevar.."]", ";]"))
+ table.insert(formspec, "tablecolumns[text,align=right;text;text]"..
+ "table[12.5,2.25;7,8.75;zastavka;")
+ if custom_state.stops[1] ~= nil then
+ local selected_stop_index = custom_state.stop
+ if custom_state.stops[selected_stop_index] == nil then
+ selected_stop_index = 1
+ end
+ local base_dep
+ for i, r in ipairs(custom_state.stops) do
+ if i > 1 then
+ table.insert(formspec, ",")
+ end
+ if i >= selected_stop_index then
+ if i == selected_stop_index then
+ base_dep = assert(r.dep)
+ table.insert(formspec, "0,")
+ else
+ table.insert(formspec, (r.dep - base_dep)..",")
+ end
+ else
+ table.insert(formspec, " ,")
+ end
+ table.insert(formspec, r.name_fs..","..r.track_fs)
+ end
+ table.insert(formspec, ";"..selected_stop_index.."]")
+ else
+ table.insert(formspec, ";]") -- empty list
+ end
+ table.insert(formspec, "button_exit[18.75,0.3;0.75,0.75;close;X]")
+ if custom_state.message ~= "" then
+ table.insert(formspec, "label[5.25,11.35;"..F(custom_state.message).."]")
+ end
+ table.insert(formspec, "button[0.5,11;4.5,0.75;refresh;"..S("Update next departures...").."]")
+ return table.concat(formspec)
+end
+
+local function jr_formspec_callback(custom_state, player, formname, fields)
+ if fields.dopravna then
+ local new_stn = tonumber(fields.dopravna)
+ if new_stn ~= nil and new_stn ~= custom_state.stn and custom_state.stns[new_stn] ~= nil then
+ custom_state.stn = new_stn
+ local current_track = custom_state.tracks[custom_state.track] or ""
+ local current_linevar_info = custom_state.linevars[custom_state.linevar]
+ jr_refresh_tracks(custom_state, current_track)
+ if current_linevar_info ~= nil then
+ jr_refresh_linevars(custom_state, current_linevar_info.linevar, current_linevar_info.linevar_index)
+ else
+ jr_refresh_linevars(custom_state)
+ end
+ jr_refresh_stops(custom_state, custom_state.stns[new_stn].stn)
+ jr_refresh_departure(custom_state)
+ return get_jr_formspec(custom_state)
+ end
+ end
+ if fields.kolej then
+ local new_track = tonumber(fields.kolej)
+ if new_track ~= nil and new_track ~= custom_state.track and custom_state.tracks[new_track] ~= nil then
+ custom_state.track = new_track
+ local current_linevar_info = custom_state.linevars[custom_state.linevar]
+ if current_linevar_info ~= nil then
+ jr_refresh_linevars(custom_state, current_linevar_info.linevar, current_linevar_info.linevar_index)
+ else
+ jr_refresh_linevars(custom_state)
+ end
+ jr_refresh_stops(custom_state, custom_state.stns[custom_state.stn].stn)
+ jr_refresh_departure(custom_state)
+ return get_jr_formspec(custom_state)
+ end
+ end
+ if fields.setowner and custom_state.pos ~= nil and is_jr_node_name(core.get_node(custom_state.pos).name) then
+ local meta = core.get_meta(custom_state.pos)
+ local jm = fields.owner -- ch_core.jmeno_na_existujici_prihlasovaci(fields.owner)
+ if jm ~= nil then
+ meta:set_string("owner", jm)
+ else
+ core.chat_send_player(custom_state.player_name, "*** Postava '"..fields.owner.."' neexistuje!")
+ end
+ return get_jr_formspec(custom_state)
+ end
+ if fields.linka then
+ local event = core.explode_table_event(fields.linka)
+ local new_line
+ if event.type == "CHG" or event.type == "DCL" then
+ new_line = tonumber(event.row)
+ end
+ if new_line ~= nil and new_line ~= custom_state.linevar then
+ local new_linevar_info = custom_state.linevars[new_line]
+ if new_linevar_info ~= nil then
+ jr_refresh_linevars(custom_state, new_linevar_info.linevar, new_linevar_info.linevar_index)
+ else
+ jr_refresh_linevars(custom_state)
+ end
+ jr_refresh_stops(custom_state, custom_state.stns[custom_state.stn].stn)
+ jr_refresh_departure(custom_state)
+ return get_jr_formspec(custom_state)
+ end
+ end
+ if fields.zastavka then
+ local event = core.explode_table_event(fields.zastavka)
+ if event.type == "CHG" or event.type == "DCL" then
+ local new_stop = tonumber(event.row)
+ if new_stop ~= nil and new_stop ~= custom_state.stop and custom_state.stops[new_stop] ~= nil then
+ custom_state.stop = new_stop
+ if event.type == "DCL" then
+ jr_refresh_departure(custom_state)
+ end
+ return get_jr_formspec(custom_state)
+ end
+ end
+ end
+ if fields.refresh then
+ jr_refresh_departure(custom_state)
+ return get_jr_formspec(custom_state)
+ end
+end
+
+function advtrains.lines.show_jr_formspec(player, pos, stn, track, linevar, stop_stn, force_unprivileged)
+ assert(core.is_player(player))
+ local custom_state = {
+ player_name = player:get_player_name(),
+ stn = 1,
+ stns = {all_stations_record},
+ track = 1,
+ tracks = {""},
+ linevar = 0,
+ linevars = {},
+ stop = 0,
+ stops = {},
+ message = "",
+ force_unprivileged = force_unprivileged,
+ }
+ if pos ~= nil then
+ custom_state.pos = pos
+ end
+ jr_refresh_stns(custom_state, stn)
+ jr_refresh_tracks(custom_state, track)
+ jr_refresh_linevars(custom_state, linevar)
+ if stop_stn == nil then
+ stop_stn = custom_state.stns[custom_state.stn].stn
+ end
+ jr_refresh_stops(custom_state, stop_stn)
+ jr_refresh_departure(custom_state)
+
+ -- show formspec:
+ return ch_core.show_formspec(player, "advtrains_line_automation:jizdni_rad",
+ get_jr_formspec(custom_state), jr_formspec_callback, custom_state, {})
+end
diff --git a/advtrains_line_automation/stoprail.lua b/advtrains_line_automation/stoprail.lua
index 55a4785..0841946 100644
--- a/advtrains_line_automation/stoprail.lua
+++ b/advtrains_line_automation/stoprail.lua
@@ -1,6 +1,10 @@
-- stoprail.lua
-- adds "stop rail". Recognized by lzb. (part of behavior is implemented there)
+-- Get current translator
+local S = advtrains.lines.translate
+
+local rwt = assert(advtrains.lines.rwt)
local function to_int(n)
--- Disallow floating-point numbers
@@ -16,26 +20,107 @@ local function updatemeta(pos)
local stdata = advtrains.lines.stops[pe]
if not stdata then
meta:set_string("infotext", "Error")
+ return
end
+ local stn = advtrains.lines.stations[stdata.stn]
+ local stn_viewname = stn and stn.name or "-"
- meta:set_string("infotext", "Stn. "..stdata.stn.." T. "..stdata.track)
+ meta:set_string("infotext", S("Stn. @1 (@2) T. @3", stn_viewname, stdata.stn or "", stdata.track or ""))
end
local door_dropdown = {L=1, R=2, C=3}
-local door_dropdown_rev = {Right="R", Left="L", Closed="C"}
+--local door_dropdown_rev = {Right="R", Left="L", Closed="C"} -- Code review : why are the value in an order different than the one in the dropdown box ?
+local door_dropdown_code = {"L", "R", "C"} -- switch to numerical index of selection : for conversion of the numerical index in the opening side selection dropdown box to the internal codification
+
+local function get_stn_dropdown(stn, player_name)
+ local stations = advtrains.lines.load_stations_for_formspec()
+ local selected_index
+ local result = {"dropdown[0.5,1.3;6.7,0.8;stn;"..S("(unassigned)")}
+ local right_mark
+ for i, st in ipairs(stations) do
+ if player_name ~= nil and player_name ~= st.owner then
+ right_mark = S("(foreign)")
+ else
+ right_mark = ""
+ end
+ table.insert(result, ","..right_mark..minetest.formspec_escape(st.stn.." | "..st.name))
+ if st.stn == stn then
+ selected_index = i + 1
+ end
+ end
+ table.insert(result, ";"..(selected_index or "1")..";true]")
+ return table.concat(result)
+end
+
+--[[
+formspec_version[6]
+size[12,12.3]
+label[0.5,0.5;Station/Stop Track -486\,3\,367]
+style[ars,arr_action,dep_action;font=mono]
+label[0.5,1.1;Station Code | Station Name]
+dropdown[0.5,1.3;6.7,0.8;stn;(nepřiřazeno),Brp | Brpigcelerefern,Drp | Drpa,Hik | Hikieg,Kek | Kekonen,Log | Logremlake,ME | Memironpa,Orgp | Orgpen,Qrl | Quriblake,Shi | Shipcotio,Shr | Shiponrumott,Van | Vannde;8;true]
+field[0.5,2.6;1.5,0.8;track;Track;2W]
+tooltip[track;Track number\, for informational purposes]
+button[3.5,2.3;3.7,1.1;editstn;Station Editor]
+textarea[7.5,1.3;4,2.1;selector_ars;Position for (ARS);]
+tooltip[selector_ars;Only trains matching these ARS rules will consider this stop rail as suitable timing point/stop position. Affects both timetabled and non-timetabled trains. Example: define a stop position for long trains (TL 30) and another for short trains (TL 0-30).]
+tooltip[ars;Non-timetabled trains matching these ARS rules will stop at this position. Note: Train must also match the 'Position For' filter!]
+button[7.5,1.3;4,0.8;selector_ars_enable;Selector for stop position...]
+tooltip[selector_ars_enable;Use when multiple stop rails are located in the same track of a station. Allows to select a suitable stop position depending on the class of train.]
+tooltip[ars;Non-timetabled trains matching these ARS rules will stop at this position. Trains under timetable will use the timetable's settings.]
+textarea[0.5,4.3;4,1.3;ars;Stopping trains (ARS);]
+field[0.5,6.1;1.5,0.8;wait;Stop Time;10]
+tooltip[wait;Train will remain stopped with open doors for at least this time before departure is attempted.]
+label[2.4,5.9;Door Side]
+dropdown[2.4,6.1;1.9,0.8;doors;left,right,closed;2;true]
+tooltip[doors;Select if and on which side the train will open its doors once stopped]
+checkbox[0.5,7.3;reverse;Reverse train;false]
+tooltip[reverse;Train will depart in the direction from where it arrived]
+checkbox[0.5,7.9;kick;Kick out passengers;false]
+checkbox[0.5,8.5;arskeepen;Keep ARS enabled;false]
+tooltip[arskeepen;Do not disable ARS on approaching. Signals behind the stop rail already set ARS routes when the train arrives\, not just before departure. (currently not implemented)]
+textarea[0.5,9.3;5.3,1.5;arr_action;Arrival Actions;<not yet implemented>]
+tooltip[arr_action;List of actions to perform on arrival (currently not implemented\, later will allow actions such as setting line\, RC and displays)]
+field[9.2,4.3;1.1,0.8;speed;Speed;M]
+tooltip[speed;Speed that the train sets when departing. Set 'M' for maximum speed.]
+label[6.2,4.1;Departure Mode]
+dropdown[6.2,4.3;2.5,0.8;depmode;Normal,Interval,Begin Timetable;2;true]
+tooltip[depmode;Select the time for departure:
+Normal: depart immediately after the stop time elapsed
+Interval: depart at the next time position set by interval and offset
+Begin Timetable: The train gets the given timetable assigned and departs according to its settings (currently not implemented)]
+field[6.2,5.6;1.8,0.8;interval;Interval:;60]
+tooltip[interval;The interval / time distance between departures in seconds. E.g. every two minutes -> set interval = 120]
+field[8.2,5.6;1.8,0.8;ioffset;Offset:;0]
+tooltip[ioffset;The offset of departures from time 0:00 in seconds. E.g. interval 120 offset 60 -> departure at every odd minute]
+checkbox[6.2,8.5;keepopen;Keep doors open;false]
+tooltip[keepopen;Do not close the doors when departing\, if they are open]
+checkbox[6.2,7.9;waitsig;Wait for signal to clear;true]
+tooltip[waitsig;Do not depart immediately\, instead first enable ARS and wait until the next signal ahead clears (ATC G command) before closing the doors and departing.]
+textarea[6.2,9.3;5.3,1.5;dep_action;Departure Actions;<not yet implemented>]
+tooltip[dep_action;List of actions to perform on departure (currently not implemented\, later will allow actions such as setting line\, RC and displays)]
+button_exit[0.5,11.2;11,0.8;save;Save]
+box[0.5,3.6;11,0.1;#dddddd]
+dropdown[6.2,6.6;3.8,0.8;linevar;asdf,dsdf;1;true]
+]]
+-- editor: https://luk3yx.gitlab.io/minetest-formspec-editor/
+local depmode_to_dropdown = { normal=1, interval=2, ttbegin=3 }
+local dropdown_to_depmode = { "normal", "interval", "ttbegin" }
+
+local player_to_stn_override = {}
local function show_stoprailform(pos, player)
local pe = advtrains.encode_pos(pos)
local pname = player:get_player_name()
if minetest.is_protected(pos, pname) then
- minetest.chat_send_player(pname, "Position is protected!")
+ minetest.chat_send_player(pname, S("You are not allowed to configure this track."))
return
end
local stdata = advtrains.lines.stops[pe]
if not stdata then
advtrains.lines.stops[pe] = {
- stn="", track="", doors="R", wait=10, ars={default=true}, ddelay=1,speed="M"
+ stn="", track="", doors="R", wait=10, ars={default=true}, speed="M"
}
stdata = advtrains.lines.stops[pe]
end
@@ -49,22 +134,90 @@ local function show_stoprailform(pos, player)
stdata.speed = "M"
end
- local form = "size[8,7]"
- form = form.."style[stn,ars;font=mono]"
- form = form.."field[0.8,0.8;2,1;stn;"..attrans("Station Code")..";"..minetest.formspec_escape(stdata.stn).."]"
- form = form.."field[2.8,0.8;5,1;stnname;"..attrans("Station Name")..";"..minetest.formspec_escape(stnname).."]"
- form = form.."field[0.80,2.0;1.75,1;ddelay;"..attrans("Door Delay")..";"..minetest.formspec_escape(stdata.ddelay).."]"
- form = form.."field[2.55,2.0;1.75,1;speed;"..attrans("Dep. Speed")..";"..minetest.formspec_escape(stdata.speed).."]"
- form = form.."field[4.30,2.0;1.75,1;track;"..attrans("Track")..";"..minetest.formspec_escape(stdata.track).."]"
- form = form.."field[6.05,2.0;1.75,1;wait;"..attrans("Stop Time")..";"..stdata.wait.."]"
- form = form.."label[0.5,2.6;"..attrans("Door Side").."]"
- form = form.."dropdown[0.51,3.0;2;doors;Left,Right,Closed;"..door_dropdown[stdata.doors].."]"
- form = form.."checkbox[3.00,2.7;reverse;"..attrans("Reverse train")..";"..(stdata.reverse and "true" or "false").."]"
- form = form.."checkbox[3.00,3.1;kick;"..attrans("Kick out passengers")..";"..(stdata.kick and "true" or "false").."]"
- form = form.."textarea[0.8,4.2;7,2;ars;Trains stopping here (ARS rules);"..advtrains.interlocking.ars_to_text(stdata.ars).."]"
- form = form.."button[0.5,6;7,1;save;"..attrans("Save").."]"
-
- minetest.show_formspec(pname, "at_lines_stop_"..pe, form)
+ local item_name = (minetest.registered_items["advtrains_line_automation:dtrack_stop_placer"] or {}).description or ""
+ local pname_unless_admin
+ if not minetest.check_player_privs(pname, "train_admin") then
+ pname_unless_admin = pname
+ end
+ local formspec = "formspec_version[6]"..
+ "size[12,12.3]"..
+ "label[0.5,0.5;"..minetest.formspec_escape(string.format("%s %d,%d,%d", item_name, pos.x, pos.y, pos.z)).."]"..
+ "style[ars,selector_ars,arr_action,dep_action;font=mono]"..
+ "label[0.5,1.1;"..S("Station Code").." | "..S("Station Name").."]"..
+ 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[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).").."]"..
+ "tooltip[ars;"..S("Non-timetabled trains matching these ARS rules will stop at this position.\nNote: Train must also match the 'Selector' filter above!").."]"
+ else
+ formspec = formspec .. "button[7.5,1.3;4,0.8;selector_ars_enable;"..S("Selector for stop position...").."]"..
+ "tooltip[selector_ars_enable;"..S("Use when multiple stop rails are located in the same track of a station. Allows to select a suitable stop position depending on the class of train.").."]"..
+ "tooltip[ars;"..S("Non-timetabled trains matching these ARS rules will stop at this position.\nTrains under timetable will use the timetable's settings.").."]"
+ end
+ -- separator line
+ formspec = formspec ..
+ "box[0.5,3.6;11,0.1;#dddddd]"..
+ --arrival
+ "textarea[0.5,4.3;4,1.3;ars;"..S("Stopping trains (ARS)")..";"..advtrains.interlocking.ars_to_text(stdata.ars).."]"..
+ "field[0.5,6.1;1.5,0.8;wait;"..S("Stop Time")..";"..stdata.wait.."]"..
+ "tooltip[wait;"..S("Train will remain stopped with open doors for at least this time before departure is attempted.").."]"..
+ "label[2.4,5.9;"..S("Door Side").."]"..
+ "dropdown[2.4,6.1;1.9,0.8;doors;"..S("left")..","..S("right")..","..S("closed")..";"..door_dropdown[stdata.doors]..";true]"..
+ "tooltip[doors;"..S("Select if and on which side the train will open its doors once stopped").."]"..
+ "checkbox[0.5,7.3;reverse;"..S("Reverse train")..";"..(stdata.reverse and "true" or "false").."]"..
+ "tooltip[reverse;"..S("Train will depart in the direction from where it arrived").."]"..
+ "checkbox[0.5,7.9;kick;"..S("Kick out passengers")..";"..(stdata.kick and "true" or "false").."]"..
+ "checkbox[0.5,8.5;arskeepen;"..S("Keep ARS enabled")..";"..(stdata.arskeepen and "true" or "false").."]"..
+ "tooltip[arskeepen;"..S("Do not disable ARS on approaching. Signals behind the stop rail already set ARS routes when the train arrives, not just before departure. (currently not implemented)").."]"..
+ "textarea[0.5,9.3;5.3,1.5;arr_action;"..S("Arrival Actions")..";<not yet implemented>]"..
+ "tooltip[arr_action;"..S("List of actions to perform on arrival (currently not implemented, later will allow actions such as setting line, RC and displays)").."]"..
+ -- departure
+ "field[10.2,4.3;1.1,0.8;speed;"..S("Speed")..";"..minetest.formspec_escape(stdata.speed).."]"..
+ "tooltip[speed;"..S("Speed that the train sets when departing. Set 'M' for maximum speed.").."]"..
+ "label[6.2,4.1;"..S("Departure Mode").."]"..
+ "dropdown[6.2,4.3;3.5,0.8;depmode;Normal,Interval,Begin Timetable;"..(depmode_to_dropdown[stdata.dep_mode] or 1)..";true]"..
+ "tooltip[depmode;"..S("Select the time for departure:\nNormal: depart immediately after the stop time elapsed\nInterval: depart at the next time position set by interval and offset\nBegin Timetable: The train gets the given timetable assigned and departs according to its settings (currently not implemented)").."]"
+ if stdata.dep_mode == "interval" then
+ formspec = formspec .. "field[6.2,5.6;1.8,0.8;interval;"..S("Interval:")..";"..minetest.formspec_escape(stdata.interval or "").."]"..
+ "tooltip[interval;"..S("The interval / time distance between departures in seconds. E.g. every two minutes -> set interval = 120").."]"..
+ "field[8.2,5.6;1.8,0.8;ioffset;"..S("Offset:")..";"..minetest.formspec_escape(stdata.ioffset or "0").."]"..
+ "tooltip[ioffset;"..S("The offset of departures from time 0:00 in seconds. E.g. interval 120 offset 60 -> departure at every odd minute").."]"
+ elseif stdata.dep_mode == "ttbegin" then
+ formspec = formspec .. "field[6.2,5.6;1.8,0.8;interval;"..S("Interval:")..";"..minetest.formspec_escape(stdata.interval or "").."]"..
+ "tooltip[interval;"..S("The interval / time distance between departures in seconds. E.g. every two minutes -> set interval = 120").."]"..
+ "field[8.2,5.6;1.8,0.8;ioffset;"..S("Offset:")..";"..minetest.formspec_escape(stdata.ioffset or "0").."]"..
+ "tooltip[ioffset;"..S("The offset of departures from time 0:00 in seconds. E.g. interval 120 offset 60 -> departure at every odd minute").."]"
+ -- 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 = 0
+ if stn and stn.linevars then
+ for k,_ in pairs(stn.linevars) do
+ table.insert(avail_linevars, k)
+ if stdata.tt_begin_linevar==k then sel_linevar = #avail_linevars end
+ end
+ 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 0)..",false]" -- this dropdown NOT using indexing!
+ else
+ formspec = formspec .. "label[6.2,6.6;"..S("No linevars\navailable!").."]"
+ end
+ end
+ formspec = formspec .. "checkbox[6.2,8.5;keepopen;"..S("Keep doors open")..";"..(stdata.keepopen and "true" or "false").."]"..
+ "tooltip[keepopen;"..S("Do not close the doors when departing, if they are open").."]"..
+ "checkbox[6.2,7.9;waitsig;"..S("Wait for signal to clear")..";"..(stdata.waitsig and "true" or "false").."]"..
+ "tooltip[waitsig;"..S("Do not depart immediately, instead first enable ARS and wait until the next signal ahead clears (ATC G command) before closing the doors and departing.").."]"..
+ "textarea[6.2,9.3;5.3,1.5;dep_action;"..S("Departure Actions")..";<not yet implemented>]"..
+ "tooltip[dep_action;"..S("List of actions to perform on departure (currently not implemented, later will allow actions such as setting line, RC and displays)").."]"..
+ -- end
+ "button_exit[0.5,11.2;11,0.8;save;"..S("Save").."]"
+ --atdebug(formspec)
+ minetest.show_formspec(pname, "at_lines_stop_"..pe, formspec)
end
local tmp_checkboxes = {}
minetest.register_on_player_receive_fields(function(player, formname, fields)
@@ -73,7 +226,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
local pos = advtrains.decode_pos(pe)
if pos then
if minetest.is_protected(pos, pname) then
- minetest.chat_send_player(pname, "Position is protected!")
+ minetest.chat_send_player(pname, S("You are not allowed to configure this track."))
return
end
@@ -87,34 +240,50 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if fields.reverse then
tmp_checkboxes[pe].reverse = (fields.reverse == "true")
end
- if fields.save then
- if fields.stn and stdata.stn ~= fields.stn and fields.stn ~= "" then
- local stn = advtrains.lines.stations[fields.stn]
- if stn then
- if (stn.owner == pname or minetest.check_player_privs(pname, "train_admin")) then
- stdata.stn = fields.stn
- else
- minetest.chat_send_player(pname, "Station code '"..fields.stn.."' does already exist and is owned by "..stn.owner)
- show_stoprailform(pos,player)
- return
- end
- else
- advtrains.lines.stations[fields.stn] = {name = fields.stnname, owner = pname}
- stdata.stn = fields.stn
- end
+ if fields.waitsig then
+ tmp_checkboxes[pe].waitsig = (fields.waitsig == "true")
+ end
+ if fields.keepopen then
+ tmp_checkboxes[pe].keepopen = (fields.keepopen == "true")
+ end
+ if fields.arskeepen then
+ tmp_checkboxes[pe].arskeepen = (fields.arskeepen == "true")
+ end
+
+ if fields.stn then
+ local new_index = tonumber(fields.stn)
+ if new_index ~= nil then
+ player_to_stn_override[pname] = new_index
end
- local stn = advtrains.lines.stations[stdata.stn]
- if stn and fields.stnname and fields.stnname ~= stn.name then
- if (stn.owner == pname or minetest.check_player_privs(pname, "train_admin")) then
- stn.name = fields.stnname
+ end
+
+ 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
+ -- no name station
+ stdata.stn = ""
+ minetest.log("action", pname.." set track at "..minetest.pos_to_string(pos).." to no station.")
else
- minetest.chat_send_player(pname, "Not allowed to edit station name, owned by "..stn.owner)
+ local stations = advtrains.lines.load_stations_for_formspec()
+ local station = stations[new_index - 1]
+ if station ~= nil then
+ if station.owner == pname or minetest.check_player_privs(pname, "train_admin") then
+ stdata.stn = station.stn
+ minetest.log("action", pname.." set track at "..minetest.pos_to_string(pos).." to station '"..tostring(station.stn).."'.")
+ else
+ minetest.chat_send_player(pname, S("Station code '@1' does already exist and is owned by @2", station.stn, station.owner))
+ show_stoprailform(pos,player)
+ return
+ end
+ end
end
+ player_to_stn_override[pname] = nil
end
-
+
-- dropdowns
if fields.doors then
- stdata.doors = door_dropdown_rev[fields.doors] or "C"
+ stdata.doors = door_dropdown_code[tonumber(fields.doors)] or "C" -- switch to numerical index of selection; attention : fields.doors is string typed, needed to be converted to an integer typed index in door_dropdown_code table
end
if fields.track then
@@ -127,13 +296,42 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if fields.ars then
stdata.ars = advtrains.interlocking.text_to_ars(fields.ars)
end
-
- if fields.ddelay then
- stdata.ddelay = to_int(fields.ddelay) or 1
+
+ if fields.selector_ars then
+ stdata.selector_ars = advtrains.interlocking.text_to_ars(fields.selector_ars)
+ elseif fields.selector_ars_enable then
+ -- define selector_ars field
+ stdata.selector_ars = {default=true}
end
+
+ stdata.ddelay = nil -- delete legacy field
+
if fields.speed then
stdata.speed = to_int(fields.speed) or "M"
end
+
+ if fields.depmode then
+ stdata.dep_mode = dropdown_to_depmode[tonumber(fields.depmode)]
+ end
+ if fields.interval then
+ local n = to_int(fields.interval)
+ if n and 0 < n and n <= 3600 then
+ stdata.interval = n
+ else
+ stdata.interval = 60
+ end
+ end
+ if fields.ioffset then
+ local n = to_int(fields.ioffset)
+ if n and n > 0 then
+ stdata.ioffset = n % stdata.interval
+ else
+ stdata.ioffset = 0
+ end
+ end
+ if fields.tt_begin_linevar then
+ stdata.tt_begin_linevar = fields.tt_begin_linevar
+ end
for k,v in pairs(tmp_checkboxes[pe]) do --handle checkboxes
stdata[k] = v or nil
@@ -141,19 +339,27 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
tmp_checkboxes[pe] = nil
--TODO: signal
updatemeta(pos)
+ minetest.log("action", pname.." saved stoprail at "..minetest.pos_to_string(pos))
show_stoprailform(pos, player)
- end
- end
-
+ elseif fields.editstn and advtrains.lines.open_station_editor ~= nil then
+ 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)
-
local adefunc = function(def, preset, suffix, rotation)
return {
after_place_node=function(pos)
local pe = advtrains.encode_pos(pos)
advtrains.lines.stops[pe] = {
- stn="", track="", doors="R", wait=10
+ stn="", track="", doors="R", wait=10, waitsig = true,
+ ars = { default = true },
}
updatemeta(pos)
end,
@@ -161,56 +367,42 @@ local adefunc = function(def, preset, suffix, rotation)
local pe = advtrains.encode_pos(pos)
advtrains.lines.stops[pe] = nil
end,
+ on_punch = function(pos, node, puncher, pointed_thing)
+ updatemeta(pos)
+ end,
on_rightclick = function(pos, node, player)
+ if minetest.is_player(player) then
+ player_to_stn_override[player:get_player_name()] = nil
+ end
show_stoprailform(pos, player)
end,
advtrains = {
- on_train_approach = function(pos,train_id, train, index, has_entered)
- if has_entered then return end -- do not stop again!
- if train.path_cn[index] == 1 then
- local pe = advtrains.encode_pos(pos)
- local stdata = advtrains.lines.stops[pe]
- if stdata and stdata.stn then
-
- --TODO REMOVE AFTER SOME TIME (only migration)
- if not stdata.ars then
- stdata.ars = {default=true}
- end
- if stdata.ars and (stdata.ars.default or advtrains.interlocking.ars_check_rule_match(stdata.ars, train) ) then
- advtrains.lzb_add_checkpoint(train, index, 2, nil)
- local stn = advtrains.lines.stations[stdata.stn]
- local stnname = stn and stn.name or "Unknown Station"
- train.text_inside = "Next Stop:\n"..stnname
- advtrains.interlocking.ars_set_disable(train, true)
- end
- end
- end
- end,
- on_train_enter = function(pos, train_id, train, index)
- if train.path_cn[index] == 1 then
- local pe = advtrains.encode_pos(pos)
- local stdata = advtrains.lines.stops[pe]
- if not stdata then
- return
- end
-
- if stdata.ars and (stdata.ars.default or advtrains.interlocking.ars_check_rule_match(stdata.ars, train) ) then
- local stn = advtrains.lines.stations[stdata.stn]
- local stnname = stn and stn.name or "Unknown Station"
-
- -- Send ATC command and set text
- advtrains.atc.train_set_command(train, "B0 W O"..stdata.doors..(stdata.kick and "K" or "").." D"..stdata.wait.." OC "..(stdata.reverse and "R" or "").."D"..(stdata.ddelay or 1) .. " A1 S" ..(stdata.speed or "M"), true)
- train.text_inside = stnname
- if tonumber(stdata.wait) then
- minetest.after(tonumber(stdata.wait), function() train.text_inside = "" end)
- end
- end
- end
- end
+ on_train_approach = advtrains.lines.on_train_approach,
+ on_train_enter = advtrains.lines.on_train_enter,
+ on_train_leave = advtrains.lines.on_train_leave,
},
}
end
+advtrains.station_stop_rail_additional_definition = adefunc -- HACK for tieless_tracks
+
+minetest.register_lbm({
+ label = "Update line track metadata",
+ name = "advtrains_line_automation:update_metadata",
+ nodenames = {
+ "advtrains_line_automation:dtrack_stop_st",
+ "advtrains_line_automation:dtrack_stop_st_30",
+ "advtrains_line_automation:dtrack_stop_st_45",
+ "advtrains_line_automation:dtrack_stop_st_60",
+ "advtrains_line_automation:dtrack_stop_tieless_st",
+ "advtrains_line_automation:dtrack_stop_tieless_st_30",
+ "advtrains_line_automation:dtrack_stop_tieless_st_40",
+ "advtrains_line_automation:dtrack_stop_tieless_st_60",
+ },
+ run_at_every_load = true,
+ action = updatemeta,
+})
+
if minetest.get_modpath("advtrains_train_track") ~= nil then
advtrains.register_tracks("default", {
nodename_prefix="advtrains_line_automation:dtrack_stop",
@@ -218,8 +410,16 @@ if minetest.get_modpath("advtrains_train_track") ~= nil then
models_prefix="advtrains_dtrack",
models_suffix=".b3d",
shared_texture="advtrains_dtrack_shared_stop.png",
- description="Station/Stop Rail",
+ description=S("Station/Stop Track"),
formats={},
get_additional_definiton = adefunc,
}, advtrains.trackpresets.t_30deg_straightonly)
+
+ minetest.register_craft({
+ output = "advtrains_line_automation:dtrack_stop_placer 2",
+ recipe = {
+ {"default:coal_lump", ""},
+ {"advtrains:dtrack_placer", "advtrains:dtrack_placer"},
+ },
+ })
end
diff --git a/advtrains_line_automation/structs.md b/advtrains_line_automation/structs.md
new file mode 100644
index 0000000..5b2c6c0
--- /dev/null
+++ b/advtrains_line_automation/structs.md
@@ -0,0 +1,190 @@
+Datové struktury:
+
+train = {
+ line_status = {
+ -- záznam o posledním zastavení/průjezdu vlaku neanonymní zastávkovou kolejí
+ -- (používá se jako údaj o poloze vlaku)
+ last_enter = {
+ stn = string, -- kód dopravny
+ encpos = string, -- zakódovaná pozice koleje, kde došlo ke kontaktu
+ rwtime = int, -- železniční čas
+ } or nil,
+
+ -- záznam o posledním odjezdu/průjezdu vlaku neanonymní zastávkovou kolejí
+ -- (používá se jako údaj o poloze vlaku)
+ last_leave = {
+ stn = string, -- kód dopravny
+ encpos = string, -- zakódovaná pozice koleje, kde došlo ke kontaktu
+ rwtime = int, -- železniční čas
+ } or nil,
+
+ -- pokud vlak právě stojí na zastávkové koleji, obsahuje její zakódovanou pozici;
+ -- při odjezdu se vynuluje
+ standing_at = string or nil,
+
+ -- nastaví se na 1 v případě, že "bylo dáno znamení", aby vlak zastavil
+ stop_request = 1 or nil,
+
+ -- údaje o poslední skončené jízdě na lince, dokud se nezmění číslo linky a dokud neuplyne 24 žel. hodin (cyklů)
+ -- nevyplní se, pokud vlak skončí jízdu jinak než zastavením na koncové zastávce
+ linevar_past = {
+ -- označení linky (LINE z linevar)
+ line = string,
+ -- linevar poslední jízdy na lince
+ linevar = string,
+ -- kód koncové zastávky, kde vlak skončil jízdu na lince
+ station = string,
+ -- žel. čas příjezdu na koncovou zastávku
+ arrival = int,
+ } or nil,
+
+ -- Následující pole jsou vyplněna jen u linkových vlaků:
+ -- ===========================
+ -- varianta linky LINE/STCODE/RC
+ linevar = string,
+
+ -- prostřední díl z 'linevar' (kód stanice, kde jsou uložena data varianty linky)
+ linevar_station = string,
+
+ -- skutečný železniční čas odjezdu z *výchozí* zastávky spoje
+ linevar_dep = int,
+
+ -- index zastávky spoje (do pole 'stops'), kde vlak naposledy zastavil
+ linevar_index = int,
+
+ -- skutečný železniční čas odjezdu z poslední zastávky spoje, kde vlak zastavil
+ linevar_last_dep = int,
+
+ -- kód zastávky spoje, kde vlak naposledy zastavil
+ linevar_last_stn = string,
+ }
+}
+
+station = {
+ linevars = {
+ [linevar] = {
+ -- linevar (LINE/STCODE/RC)
+ name = string,
+
+ -- přihlašovací jméno postavy, která linku spravuje
+ owner = string,
+
+ -- jméno vlaku pro zobrazení (volitelné)
+ train_name = string or nil,
+
+ -- je-li true, nové vlaky nemohou dostat tuto variantu přidělenu
+ disabled = bool or nil,
+
+ -- je-li neprázdný řetězec, udává označení linky, na kterou bude vlak pravděpodobně pokračovat
+ -- ze zastávky v režimu MODE_FINAL_CONTINUE
+ continue_line = string or nil,
+
+ -- je-li continue_line neprázdný řetězec, udává směrový kód pro pokračování
+ continue_rc = string or nil,
+
+ -- index zobrazované výchozí zastávky v poli 'stops'; nil značí, že taková zastávka nebyla nalezena
+ index_vychozi = int or nil,
+
+ -- index zobrazované cílové zastávky v poli 'stops'; nil značí, že taková zastávka nebyla nalezena
+ index_cil = int or nil,
+
+ -- seznam zastávek na lince, seřazený podle 'dep':
+ stops = {
+ {
+ -- kód dopravny, kde má vlak zastavit
+ stn = string,
+
+ -- plánovaný čas odjezdu, relativně vůči odjezdu z výchozí zastávky (v sekundách)
+ dep = int,
+
+ -- předpokládaný čas stání před časem odjezdu (používá se k zjištění času příjezdu)
+ -- je-li nil, počítá se 10 sekund
+ -- výjimka: pro koncové zastávky udává předpokládanou dobu stání po čase 'dep'
+ wait = int or nil,
+
+ -- režim zastávky (podle konstant ve zdrojovém kódu)
+ -- nil odpovídá 0 (normální zastavení)
+ mode = int or nil,
+
+ -- je-li vyplněna, vlak zastaví jen na koleji na uvedené pozici
+ pos = "X,Y,Z" or nil,
+
+ -- orientační údaj pro cestující, na které koleji má vlak zastavit
+ track = string or nil,
+ }...
+ }
+ }
+ },
+ anns = { -- staniční rozhlasy
+ [encoded_pos] = {
+ cedule = {
+ -- formát prázdné řádky pro danou ceduli
+ empty = string,
+ -- pozice připojené cedule ve tvaru pro použití ve formspecu, nebo "", pokud daná cedule není připojená
+ fs = string,
+ -- pozice připojené cedule ve formě vektoru
+ pos = vector,
+ -- formát řádky s odjezdem pro danou ceduli
+ row = string,
+ -- formát pro sestavení textu cedule z řádků; může používat značky {1} až {9} a může mít víc řádek
+ text = "{1}{2}",
+ -- seznam řádků, které jsou odkazovány v poli 'text', nebo prázdný řetězec, pokud nejsou odkazovány žádné
+ text_rtf = {int, ...} or "",
+ },
+ -- dosah zpráv v četu (>= 0, nil znamená 50):
+ chat_dosah = int or nil,
+
+ -- formát pro kladné zpoždění
+ fmt_delay = string,
+
+ -- formát pro záporné zpoždění
+ fmt_negdelay = string,
+
+ -- formát pro „bez zpoždění“
+ fmt_nodelay = string,
+
+ -- udává, zda na cedulích bude první znak každého řádku s odjezdem (textu dosazeného za značku {1} až {9})
+ -- převeden na velké písmeno:
+ fn_firstupper = bool,
+
+ -- obsah pole "koleje" zformátovaný pro použití ve formspecu; prázdný řetězec "" znamená, že st. rozhlas platí pro všechny koleje
+ -- a na .koleje pak nezáleží
+ fs_koleje = string,
+
+ -- pokud st. rozhlas není omezený na určité koleje, nil nebo ""
+ -- je-li omezen na jednu konkrétní kolej, pak jde o název této koleje
+ -- je-li omezen na více kolejí, pak jde o množinu indexovanou označeními kolejí
+ koleje = {[string] = true, ...} or string or nil,
+
+ -- vlastník/ice staničního rozhlasu
+ owner = string,
+
+ -- režim rozhlasu (RMODE_*)
+ rmode = int,
+
+ -- číslo verze systému staničního rozhlasu (pro detekci zastaralých rozhlasů)
+ version = int,
+
+ -- řetězce pro formátování hlášení v četu; nemusí být uvedeny všechny, nil znamená použít výchozí text
+ tx_* = string or nil,
+ }
+ }
+}
+
+stop = {
+ -- žel. čas posledního odjezdu jakéhokoliv zastavivšího vlaku z této zastávkové koleje;
+ -- používá se v kombinaci s intervalem
+ last_dep = int or nil,
+ -- původně naplánovaná doba stání vlaku vztahující se k last_dep
+ last_wait = int or nil,
+}
+
+local current_passages = {--[[
+ [train_id] = {[1] = rwtime, ..., [n] = rwtime (časy *odjezdu*, kromě koncových zastávek, kde jde o čas příjezdu)}
+]]}
+
+local last_passages = {--[[
+ [linevar] = {
+ [1..10] = {[1] = rwtime, ...} -- jízdy seřazeny od nejstarší (1) po nejnovější (až 10) podle odjezdu z výchozí zastávky
+ }
+]]}
diff --git a/advtrains_line_automation/textures/advtrains_dtrack_shared_stop.png b/advtrains_line_automation/textures/advtrains_dtrack_shared_stop.png
index b6629cf..956b6b4 100644
--- a/advtrains_line_automation/textures/advtrains_dtrack_shared_stop.png
+++ b/advtrains_line_automation/textures/advtrains_dtrack_shared_stop.png
Binary files differ
diff --git a/advtrains_line_automation/textures/advtrains_line_automation_jrad.png b/advtrains_line_automation/textures/advtrains_line_automation_jrad.png
new file mode 100644
index 0000000..627ddf8
--- /dev/null
+++ b/advtrains_line_automation/textures/advtrains_line_automation_jrad.png
Binary files differ
diff --git a/advtrains_line_automation/textures/advtrains_line_automation_white_pixel.png b/advtrains_line_automation/textures/advtrains_line_automation_white_pixel.png
new file mode 100644
index 0000000..d057ee3
--- /dev/null
+++ b/advtrains_line_automation/textures/advtrains_line_automation_white_pixel.png
Binary files differ
diff --git a/advtrains_line_automation/time_table.lua b/advtrains_line_automation/time_table.lua
new file mode 100644
index 0000000..90d30e3
--- /dev/null
+++ b/advtrains_line_automation/time_table.lua
@@ -0,0 +1,95 @@
+
+-- Get current translator
+local S = advtrains.lines.translate
+
+local visual_scale = 15/16
+local node_box = {type = "fixed", fixed = {
+ -16/32, -16/32, 15/32 / visual_scale,
+ 16/32, 16/32, 16/32 / visual_scale,
+}}
+local sbox = {type = "fixed", fixed = {
+ -16/32 * visual_scale, -16/32 * visual_scale, 15/32,
+ 16/32 * visual_scale, 16/32 * visual_scale, 16/32,
+}}
+
+local def = {
+ description = S("Timetable"),
+ drawtype = "nodebox",
+ node_box = node_box,
+ selection_box = sbox,
+ collision_box = sbox,
+ tiles = {
+ {name = "advtrains_line_automation_white_pixel.png^[multiply:#aaaaaa"},
+ {name = "advtrains_line_automation_white_pixel.png^[multiply:#aaaaaa"},
+ {name = "advtrains_line_automation_white_pixel.png^[multiply:#aaaaaa"},
+ {name = "advtrains_line_automation_white_pixel.png^[multiply:#aaaaaa"},
+ {name = "advtrains_line_automation_jrad.png"},
+ {name = "advtrains_line_automation_jrad.png"},
+ },
+ paramtype = "light",
+ paramtype2 = "4dir",
+ sunlight_propagates = true,
+ groups = {cracky = 3, ch_jrad = 1},
+ sounds = default and default.node_sound_metal_defaults and default.node_sound_metal_defaults() or nil,
+ visual_scale = visual_scale,
+ after_place_node = function(pos, placer, itemstack, pointed_thing)
+ local player_name = placer and placer:get_player_name()
+ if player_name ~= nil then
+ local meta = core.get_meta(pos)
+ meta:set_string("infotext", S("Timetable (owner: @1)", player_name))
+ meta:set_string("owner", player_name)
+ end
+ end,
+ can_dig = function(pos, player)
+ if player == nil then
+ return false
+ end
+ local player_name = player:get_player_name()
+ if core.check_player_privs(player_name, {protection_bypass=true}) then
+ return true
+ end
+ if core.is_protected(pos, player_name) then
+ core.record_protection_violation(pos, player_name)
+ return false
+ end
+ local meta = core.get_meta(pos)
+ local owner = meta:get_string("owner")
+ return owner == "" or owner == player_name
+ end,
+ on_use = function(itemstack, user, pointed_thing)
+ if core.is_player(user) then
+ advtrains.lines.show_jr_formspec(user)
+ end
+ end,
+ on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
+ if clicker ~= nil and core.is_player(clicker) then
+ local meta = core.get_meta(pos)
+ -- show_jr_formspec(player, pos, stn, track, linevar, stop_stn, force_unprivileged)
+ local force_unprivileged = false
+ if clicker:get_player_control().aux1 then
+ force_unprivileged = true
+ end
+ advtrains.lines.show_jr_formspec(clicker, pos, meta:get_string("stn"), meta:get_string("track"), nil, nil, force_unprivileged)
+ end
+ end,
+}
+
+core.register_node("advtrains_line_automation:jrad", table.copy(def))
+
+def.description = S("Timetable (on pole)")
+def.tiles = table.copy(def.tiles)
+def.tiles[5] = def.tiles[1]
+def.node_box = {
+ type = "fixed",
+ fixed = {
+ -16/32, -16/32, 27/32 / visual_scale,
+ 16/32, 16/32, 28/32 / visual_scale,
+ }}
+def.selection_box = {
+ type = "fixed",
+ fixed = {
+ -16/32 * visual_scale, -16/32 * visual_scale, 27/32,
+ 16/32 * visual_scale, 16/32 * visual_scale, 28/32,
+}}
+def.collision_box = def.selection_box
+core.register_node("advtrains_line_automation:jrad_on_pole", def)