summaryrefslogtreecommitdiff
path: root/far/init_code.lua
diff options
context:
space:
mode:
Diffstat (limited to 'far/init_code.lua')
-rw-r--r--far/init_code.lua45
1 files changed, 29 insertions, 16 deletions
diff --git a/far/init_code.lua b/far/init_code.lua
index 55f685c..e6fbcb5 100644
--- a/far/init_code.lua
+++ b/far/init_code.lua
@@ -56,21 +56,28 @@ F.send_route = function(passive_name, route, show_print)
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
- if F.has_rc("FAREAST", F.get_rc_safe()) then
- 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"])
- -- remote_track = POS(30919,13,1812)
- -- interrupt_pos(remote_track, "display")
+F.save_train = function(pos, direction)
+ if event.train then
+ 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
+ if F.has_rc("FAREAST", F.get_rc_safe()) then
+ if direction == nil or direction == "" then
+ 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 , ["direction"] = nil }
+ else
+ 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 , ["direction"] = direction }
+ end
+ -- F.print("Train ID: " .. S.trains[atc_id]["id"] .. " at " .. S.trains[atc_id]["pos"])
+ -- remote_track = POS(30919,13,1812)
+ -- interrupt_pos(remote_track, "display")
+ end
end
end
+ return
end
F.get_real_split_count = function(train_length_count, split_count)
@@ -114,6 +121,7 @@ F.list_trains = function(print_info)
F.clear_main_depot_displays()
number_of_displays = number_of_displays + 1
count_keys = 0
+ direction_display = ""
trains_table = {}
for k in pairs(S.trains) do
table.insert(trains_table, k)
@@ -167,13 +175,18 @@ F.list_trains = function(print_info)
rc_display = rc_display .. "| RC:" .. rc_list_unknown
end
end
+ if v["direction"] == nil or v["direction"] == "" then
+ direction_display = " D: ??"
+ else
+ direction_display = " D: " .. v["direction"]
+ end
if v["cars_count"] == nil or v["cars_count"] == "" then
- cars_count_display = " Len: 0"
+ cars_count_display = " L: 0"
else
cars_count = tonumber(v["cars_count"])
- cars_count_display = " Len: " .. cars_count
+ cars_count_display = " L: " .. cars_count
end
- message = " ID: " .. v["id"] .. cars_count_display .. rc_display .. line_number .. pos_string
+ message = " ID: " .. v["id"] .. cars_count_display .. direction_display .. rc_display .. line_number .. pos_string
if x > 0 then digiline_send("train_display" .. x, message) end
if print_info then
F.print(x .. ": " .. message)