summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorautocommitter <autocommitter@linux-forks.de>2024-04-22 15:00:32 +0200
committerautocommitter <autocommitter@linux-forks.de>2024-04-22 15:00:32 +0200
commite03d888a00e52d12b992456a646e79bef2873418 (patch)
tree0edae6eced91e39dc5f8da40239b412a6c1bfe74
parent1ab6086a3d25cca6f2029a45e4bdcd117d1985bd (diff)
downloadluaatc_envs-e03d888a00e52d12b992456a646e79bef2873418.tar.gz
luaatc_envs-e03d888a00e52d12b992456a646e79bef2873418.tar.bz2
luaatc_envs-e03d888a00e52d12b992456a646e79bef2873418.zip
State at 2023-07-20
-rw-r--r--far/init_code.lua170
-rw-r--r--far/nodes/(10731,46,1251).lua8
-rw-r--r--far/nodes/(13481,13,713).lua8
-rw-r--r--far/nodes/(15454,14,1055).lua8
-rw-r--r--far/nodes/(15472,14,1131).lua8
-rw-r--r--far/nodes/(18288,36,607).lua8
-rw-r--r--far/nodes/(19710,8,689).lua8
-rw-r--r--far/nodes/(19741,8,684).lua8
-rw-r--r--far/nodes/(2049,9,1480).lua8
-rw-r--r--far/nodes/(21333,13,880).lua8
-rw-r--r--far/nodes/(23195,15,1512).lua8
-rw-r--r--far/nodes/(23199,15,1512).lua8
-rw-r--r--far/nodes/(25670,10,1575).lua8
-rw-r--r--far/nodes/(25720,10,1519).lua8
-rw-r--r--far/nodes/(28834,24,1382).lua8
-rw-r--r--far/nodes/(28866,24,1378).lua8
-rw-r--r--far/nodes/(30856,15,1814).lua8
-rw-r--r--far/nodes/(30870,15,1800).lua8
-rw-r--r--far/nodes/(30919,13,1814).lua9
-rw-r--r--far/nodes/(30919,13,1815).lua8
-rw-r--r--far/nodes/(3978,8,1756).lua8
-rw-r--r--far/nodes/(3983,8,1774).lua8
-rw-r--r--far/nodes/(6874,23,2199).lua8
-rw-r--r--far/nodes/(6890,23,2175).lua8
-rw-r--r--far/nodes/(8534,11,1789).lua8
-rw-r--r--far/nodes/(8558,11,1758).lua8
26 files changed, 371 insertions, 0 deletions
diff --git a/far/init_code.lua b/far/init_code.lua
new file mode 100644
index 0000000..582b42e
--- /dev/null
+++ b/far/init_code.lua
@@ -0,0 +1,170 @@
+-- environment_far.lua
+if S.trains == nil then S.trains = {} end
+
+F.print = function (str) if F.debug then print("".. (str or "nil") ) end end
+F.isempty = function (s) return s == nil or s == "" end
+F.get_rc_safe = function() return get_rc() or "" end
+F.get_line_safe = function() return get_line() or "" end
+F.get_train_length_safe = function() return train_length() or 0 end
+F.avg = function(t)
+ local sum = 0
+ local count = 0
+ for k,v in pairs(t) do
+ if type(v) == "number" then
+ sum = sum + v
+ count = count + 1
+ end
+ end
+ return (sum / count)
+end
+
+if event.init then
+ F.debug = true
+ F.max_displays = 52
+ F.print("Initialized")
+end
+
+F.clear_main_depot_displays = function() for i = 1, F.max_displays, 1 do digiline_send("train_display" .. i, " ") end end
+
+--[[
+ EXAMPLE: F.has_rc("LILSHUNTER", F.get_rc_safe() )
+ Merged F.has_rc and F.does_train_have_rc
+ F.does_train_have_rc is deprecated
+]]
+F.has_rc = function(query,rc_list) -- query = string, single entry
+ for word in rc_list:gmatch("[^%s]+") do
+ if word == query then return true end
+ end
+ return false
+end
+
+F.send_route = function(passive_name, route, show_print)
+ local message = ""
+ local return_value = false
+ if can_set_route(passive_name, route) then
+ set_route(passive_name, route)
+ message = passive_name .. " has been set to " .. route
+ return_value = true
+ else
+ message = route .. " cannot be set for " .. passive_name .. ". Try another."
+ return_value = false
+ end
+ if show_print == true then F.print(message) end
+ return return_value
+end
+
+F.save_train = function(pos)
+ if not atc_id then return end
+ if S.trains then
+ if F.isempty(pos) then
+ pos_string = ""
+ else
+ pos_string = pos["x"] .. "," .. pos["y"] .. "," .. pos["z"]
+ end
+ S.trains[atc_id] = { ["id"] = atc_id, ["rc"] = F.get_rc_safe(), ["ln"] = F.get_line_safe(), ["cars_count"] = F.get_train_length_safe(), ["pos"] = pos_string }
+ F.print("Train ID: " .. S.trains[atc_id]["id"] .. " at " .. S.trains[atc_id]["pos"])
+ end
+end
+
+F.get_real_split_count = function(train_length_count, split_count)
+ if split_count then
+ if split_count == "all" then
+ return 2
+ else
+ F.print("train_length_count (" .. train_length_count .. ") - split_count (" .. split_count .. ")")
+ train_length_count = train_length_count + 1
+ split_count = train_length_count - split_count
+ return split_count
+ end
+ else
+ return nil
+ end
+end
+
+F.delete_train_info = function(train_id)
+ if S.trains[train_id] then
+ S.trains[train_id] = nil
+ F.print("Deleted train id: " .. train_id)
+ end
+end
+
+F.list_trains = function(number_of_displays)
+ if S.trains then
+ if number_of_displays == nil then number_of_displays = F.max_displays end
+ F.clear_main_depot_displays()
+ number_of_displays = number_of_displays + 1
+ count_keys = 0
+ trains_table = {}
+ for k in pairs(S.trains) do
+ table.insert(trains_table, k)
+ count_keys = count_keys + 1
+ end
+ table.sort(trains_table)
+ x = number_of_displays - count_keys
+ for _, k in ipairs(trains_table) do
+ if S.trains[k] then
+ v = S.trains[k]
+ if F.has_rc("LILSHUNTER", v["rc"]) or F.has_rc("LIL", v["rc"]) then
+ F.delete_train_info(v["id"])
+ else
+ if v["ln"] == nil or v["ln"] == "" then
+ line_number = ""
+ else
+ line_number = "| LN: [" .. v["ln"] .. "]"
+ end
+ if v["pos"] == nil or v["pos"] == "" then
+ pos_string = ""
+ else
+ pos_string = "| POS: [" .. v["pos"] .. "]"
+ end
+ if v["rc"] == nil or v["rc"] == "" then
+ rc_display = ""
+ else
+ rc_list = v["rc"]
+ rc_list_cleansed = ""
+ rc_list_unknown = ""
+ rc_list_table = {}
+ if F.has_rc("ERSTAZI", rc_list) and F.has_rc("FREIGHT", rc_list) then
+ rc_list_cleansed = "ERSTAZI FREIGHT |"
+ else
+ rc_list_cleansed = "NO E,F |"
+ end
+ for rc in rc_list:gmatch("[^%s]+") do
+ if rc == "ERSTAZI" or rc == "FREIGHT" then
+ -- leaving for future use
+ do_nothing = true
+ else
+ rc_list_unknown = rc_list_unknown .. " " .. rc
+ end
+ end
+ rc_display = ""
+ if not F.isempty(rc_list_unknown) then
+ rc_display = rc_display .. "| RC:" .. rc_list_unknown
+ end
+ end
+ if v["cars_count"] == nil or v["cars_count"] == "" then
+ cars_count_display = " Len: 0"
+ else
+ cars_count = tonumber(v["cars_count"])
+ cars_count_display = " Len: " .. cars_count
+ end
+ message = " ID: " .. v["id"] .. cars_count_display .. rc_display .. line_number .. pos_string
+ if x > 0 then digiline_send("train_display" .. x, message) end
+ F.print(x .. ": " .. message)
+ x = x + 1
+ end
+ end
+ end
+ else
+ F.print("no trains saved in S.trains")
+ end
+end
+
+F.slow_train_down = function(id)
+ result = atc_send_to_train(id, "B1")
+ if result == false then
+ F.print("Train ID " .. id .. " does not exist")
+ else
+ F.print("Train ID " .. id .. " is slowed down to B1")
+ end
+end
diff --git a/far/nodes/(10731,46,1251).lua b/far/nodes/(10731,46,1251).lua
new file mode 100644
index 0000000..a5de8b7
--- /dev/null
+++ b/far/nodes/(10731,46,1251).lua
@@ -0,0 +1,8 @@
+-- far_luaatctrack_spot_check_01.lua
+
+local show_print = false
+if event.train then
+ local posTable = POS(10731,46,1251)
+ F.save_train(posTable)
+ return
+end \ No newline at end of file
diff --git a/far/nodes/(13481,13,713).lua b/far/nodes/(13481,13,713).lua
new file mode 100644
index 0000000..4d8275c
--- /dev/null
+++ b/far/nodes/(13481,13,713).lua
@@ -0,0 +1,8 @@
+-- far_luaatctrack_spot_check_01.lua
+
+local show_print = false
+if event.train then
+ local posTable = POS(13481,13,713)
+ F.save_train(posTable)
+ return
+end \ No newline at end of file
diff --git a/far/nodes/(15454,14,1055).lua b/far/nodes/(15454,14,1055).lua
new file mode 100644
index 0000000..989dfc1
--- /dev/null
+++ b/far/nodes/(15454,14,1055).lua
@@ -0,0 +1,8 @@
+-- far_luaatctrack_spot_check_01.lua
+
+local show_print = false
+if event.train then
+ local posTable = POS(15454,14,1055)
+ F.save_train(posTable)
+ return
+end \ No newline at end of file
diff --git a/far/nodes/(15472,14,1131).lua b/far/nodes/(15472,14,1131).lua
new file mode 100644
index 0000000..f45c7b6
--- /dev/null
+++ b/far/nodes/(15472,14,1131).lua
@@ -0,0 +1,8 @@
+-- far_luaatctrack_spot_check_01.lua
+
+local show_print = false
+if event.train then
+ local posTable = POS(15472,14,1131)
+ F.save_train(posTable)
+ return
+end \ No newline at end of file
diff --git a/far/nodes/(18288,36,607).lua b/far/nodes/(18288,36,607).lua
new file mode 100644
index 0000000..de4f9c8
--- /dev/null
+++ b/far/nodes/(18288,36,607).lua
@@ -0,0 +1,8 @@
+-- far_luaatctrack_spot_check_01.lua
+
+local show_print = false
+if event.train then
+ local posTable = POS(18288,36,607)
+ F.save_train(posTable)
+ return
+end \ No newline at end of file
diff --git a/far/nodes/(19710,8,689).lua b/far/nodes/(19710,8,689).lua
new file mode 100644
index 0000000..0b4c30a
--- /dev/null
+++ b/far/nodes/(19710,8,689).lua
@@ -0,0 +1,8 @@
+-- far_luaatctrack_spot_check_01.lua
+
+local show_print = false
+if event.train then
+ local posTable = POS(19710,8,689)
+ F.save_train(posTable)
+ return
+end \ No newline at end of file
diff --git a/far/nodes/(19741,8,684).lua b/far/nodes/(19741,8,684).lua
new file mode 100644
index 0000000..0eb5cfc
--- /dev/null
+++ b/far/nodes/(19741,8,684).lua
@@ -0,0 +1,8 @@
+-- far_luaatctrack_spot_check_01.lua
+
+local show_print = false
+if event.train then
+ local posTable = POS(19741,8,684)
+ F.save_train(posTable)
+ return
+end \ No newline at end of file
diff --git a/far/nodes/(2049,9,1480).lua b/far/nodes/(2049,9,1480).lua
new file mode 100644
index 0000000..3c361d0
--- /dev/null
+++ b/far/nodes/(2049,9,1480).lua
@@ -0,0 +1,8 @@
+-- far_luaatctrack_spot_check_01.lua
+
+local show_print = false
+if event.train then
+ local posTable = POS(2049,9,1480)
+ F.save_train(posTable)
+ return
+endv \ No newline at end of file
diff --git a/far/nodes/(21333,13,880).lua b/far/nodes/(21333,13,880).lua
new file mode 100644
index 0000000..863fc83
--- /dev/null
+++ b/far/nodes/(21333,13,880).lua
@@ -0,0 +1,8 @@
+-- far_luaatctrack_spot_check_01.lua
+
+local show_print = false
+if event.train then
+ local posTable = POS(21333,13,880)
+ F.save_train(posTable)
+ return
+end \ No newline at end of file
diff --git a/far/nodes/(23195,15,1512).lua b/far/nodes/(23195,15,1512).lua
new file mode 100644
index 0000000..e9af33e
--- /dev/null
+++ b/far/nodes/(23195,15,1512).lua
@@ -0,0 +1,8 @@
+-- far_luaatctrack_spot_check_01.lua
+
+local show_print = false
+if event.train then
+ local posTable = POS(23195,15,1512)
+ F.save_train(posTable)
+ return
+end \ No newline at end of file
diff --git a/far/nodes/(23199,15,1512).lua b/far/nodes/(23199,15,1512).lua
new file mode 100644
index 0000000..569eb68
--- /dev/null
+++ b/far/nodes/(23199,15,1512).lua
@@ -0,0 +1,8 @@
+-- far_luaatctrack_spot_check_01.lua
+
+local show_print = false
+if event.train then
+ local posTable = POS(23199,15,1512)
+ F.save_train(posTable)
+ return
+end \ No newline at end of file
diff --git a/far/nodes/(25670,10,1575).lua b/far/nodes/(25670,10,1575).lua
new file mode 100644
index 0000000..30f0da6
--- /dev/null
+++ b/far/nodes/(25670,10,1575).lua
@@ -0,0 +1,8 @@
+-- far_luaatctrack_spot_check_01.lua
+
+local show_print = false
+if event.train then
+ local posTable = POS(25670,10,1575)
+ F.save_train(posTable)
+ return
+end \ No newline at end of file
diff --git a/far/nodes/(25720,10,1519).lua b/far/nodes/(25720,10,1519).lua
new file mode 100644
index 0000000..f5ddc3c
--- /dev/null
+++ b/far/nodes/(25720,10,1519).lua
@@ -0,0 +1,8 @@
+-- far_luaatctrack_spot_check_01.lua
+
+local show_print = false
+if event.train then
+ local posTable = POS(25720,10,1519)
+ F.save_train(posTable)
+ return
+end \ No newline at end of file
diff --git a/far/nodes/(28834,24,1382).lua b/far/nodes/(28834,24,1382).lua
new file mode 100644
index 0000000..b23e5ec
--- /dev/null
+++ b/far/nodes/(28834,24,1382).lua
@@ -0,0 +1,8 @@
+-- far_luaatctrack_spot_check_01.lua
+
+local show_print = false
+if event.train then
+ local posTable = POS(28834,24,1382)
+ F.save_train(posTable)
+ return
+end \ No newline at end of file
diff --git a/far/nodes/(28866,24,1378).lua b/far/nodes/(28866,24,1378).lua
new file mode 100644
index 0000000..6c5427b
--- /dev/null
+++ b/far/nodes/(28866,24,1378).lua
@@ -0,0 +1,8 @@
+-- far_luaatctrack_spot_check_01.lua
+
+local show_print = false
+if event.train then
+ local posTable = POS(28866,24,1378)
+ F.save_train(posTable)
+ return
+end \ No newline at end of file
diff --git a/far/nodes/(30856,15,1814).lua b/far/nodes/(30856,15,1814).lua
new file mode 100644
index 0000000..04c43dc
--- /dev/null
+++ b/far/nodes/(30856,15,1814).lua
@@ -0,0 +1,8 @@
+-- far_luaatctrack_spot_check_01.lua
+
+local show_print = false
+if event.train then
+ local posTable = POS(30856,15,1814)
+ F.save_train(posTable)
+ return
+end \ No newline at end of file
diff --git a/far/nodes/(30870,15,1800).lua b/far/nodes/(30870,15,1800).lua
new file mode 100644
index 0000000..b50e6aa
--- /dev/null
+++ b/far/nodes/(30870,15,1800).lua
@@ -0,0 +1,8 @@
+-- far_luaatctrack_spot_check_01.lua
+
+local show_print = false
+if event.train then
+ local posTable = POS(30870,15,1800)
+ F.save_train(posTable)
+ return
+end \ No newline at end of file
diff --git a/far/nodes/(30919,13,1814).lua b/far/nodes/(30919,13,1814).lua
new file mode 100644
index 0000000..0aa072d
--- /dev/null
+++ b/far/nodes/(30919,13,1814).lua
@@ -0,0 +1,9 @@
+
+local show_print = false
+if event.type == "punch" then
+
+-- F.delete_train_info("450511")
+
+ F.list_trains(6)
+ return
+end \ No newline at end of file
diff --git a/far/nodes/(30919,13,1815).lua b/far/nodes/(30919,13,1815).lua
new file mode 100644
index 0000000..c8cd423
--- /dev/null
+++ b/far/nodes/(30919,13,1815).lua
@@ -0,0 +1,8 @@
+
+local show_print = false
+if event.type == "punch" then
+-- trainID = 999999999
+-- F.slow_train_down(trainID)
+ F.clear_main_depot_displays()
+ return
+end \ No newline at end of file
diff --git a/far/nodes/(3978,8,1756).lua b/far/nodes/(3978,8,1756).lua
new file mode 100644
index 0000000..e9059d7
--- /dev/null
+++ b/far/nodes/(3978,8,1756).lua
@@ -0,0 +1,8 @@
+-- far_luaatctrack_spot_check_01.lua
+
+local show_print = false
+if event.train then
+ local posTable = POS(3978,8,1756)
+ F.save_train(posTable)
+ return
+end \ No newline at end of file
diff --git a/far/nodes/(3983,8,1774).lua b/far/nodes/(3983,8,1774).lua
new file mode 100644
index 0000000..41ef5de
--- /dev/null
+++ b/far/nodes/(3983,8,1774).lua
@@ -0,0 +1,8 @@
+-- far_luaatctrack_spot_check_01.lua
+
+local show_print = false
+if event.train then
+ local posTable = POS(3983,8,1774)
+ F.save_train(posTable)
+ return
+end \ No newline at end of file
diff --git a/far/nodes/(6874,23,2199).lua b/far/nodes/(6874,23,2199).lua
new file mode 100644
index 0000000..a108f44
--- /dev/null
+++ b/far/nodes/(6874,23,2199).lua
@@ -0,0 +1,8 @@
+-- far_luaatctrack_spot_check_01.lua
+
+local show_print = false
+if event.train then
+ local posTable = POS(6874,23,2199)
+ F.save_train(posTable)
+ return
+end \ No newline at end of file
diff --git a/far/nodes/(6890,23,2175).lua b/far/nodes/(6890,23,2175).lua
new file mode 100644
index 0000000..dbdaa99
--- /dev/null
+++ b/far/nodes/(6890,23,2175).lua
@@ -0,0 +1,8 @@
+-- far_luaatctrack_spot_check_01.lua
+
+local show_print = false
+if event.train then
+ local posTable = POS(6890,23,2175)
+ F.save_train(posTable)
+ return
+end \ No newline at end of file
diff --git a/far/nodes/(8534,11,1789).lua b/far/nodes/(8534,11,1789).lua
new file mode 100644
index 0000000..17d7aa0
--- /dev/null
+++ b/far/nodes/(8534,11,1789).lua
@@ -0,0 +1,8 @@
+-- far_luaatctrack_spot_check_01.lua
+
+local show_print = false
+if event.train then
+ local posTable = POS(8534,11,1789)
+ F.save_train(posTable)
+ return
+end \ No newline at end of file
diff --git a/far/nodes/(8558,11,1758).lua b/far/nodes/(8558,11,1758).lua
new file mode 100644
index 0000000..ba5264c
--- /dev/null
+++ b/far/nodes/(8558,11,1758).lua
@@ -0,0 +1,8 @@
+-- far_luaatctrack_spot_check_01.lua
+
+local show_print = false
+if event.train then
+ local posTable = POS(8558,11,1758)
+ F.save_train(posTable)
+ return
+end \ No newline at end of file