diff options
Diffstat (limited to 'ers')
-rw-r--r-- | ers/init_code.lua | 91 | ||||
-rw-r--r-- | ers/nodes/(1655,1,1261).lua | 30 | ||||
-rw-r--r-- | ers/nodes/(1655,1,1264).lua | 6 | ||||
-rw-r--r-- | ers/nodes/(3159,74,2331).lua | 0 |
4 files changed, 127 insertions, 0 deletions
diff --git a/ers/init_code.lua b/ers/init_code.lua new file mode 100644 index 0000000..f0a5c4d --- /dev/null +++ b/ers/init_code.lua @@ -0,0 +1,91 @@ +-- environment_ers.lua +F.debug = true + +F.isempty = function (s) + return s == nil or s == '' +end + +F.print = function (str) + if F.debug then + print("PrntMsg: ".. (str or "nil") ) + end +end + +S.train_duration = {} +F.train_duration = function(type) + if not atc_id then return end + local now = os.date("%H:%M:%S") + if F.isempty(type) then + type = "start" + end + if not S.train_duration[atc_id] then + S.train_duration[atc_id] = { ["start"] = "", ["end"] = "" } + end + if type == "start" then + S.train_duration[atc_id]["end"] = "Nil" + end + S.train_duration[atc_id][type] = now +end + +F.train_info = function (passive_name, show_print) + local timestart = "" + local timeend = "" + local time_message = "" + if F.isempty(passive_name) or passive_name == "RESETALL" then + msg_atc_id = "No Train" + if passive_name == "RESETALL" then + S.train_duration = {} + end + else + timestart = S.train_duration[atc_id]["start"] + timeend = S.train_duration[atc_id]["end"] + msg_atc_id = atc_id + end + local lcd_message = "" .. + msg_atc_id .. + "" + + if not F.isempty(timestart) and not F.isempty(timeend) then + time_message = "Time: | " .. timestart .. " to " .. timeend + elseif not F.isempty(timestart) and F.isempty(timeend) then + time_message = "Start Time: | " .. timestart + else + time_message = "RegTime: | " .. os.date("%H:%M:%S") + end + + digiline_send("lcd", lcd_message) + digiline_send("time", time_message) + local message = lcd_message .. " | " .. time_message + + if show_print == true then + F.print(message) + end +end + +F.does_train_have_rc = function(wanted_rc) + local rc = get_rc() or "" + if rc:match(wanted_rc) then + return true + else + return false + end +end + +F.send_route = function(passive_name, route, show_print) + if can_set_route(passive_name, route) then + set_route(passive_name, route) + if show_print == true then + F.print(passive_name .. " has been set to " .. route) + end + return true + else + if show_print == true then + F.print(route .. " cannot be set for " .. passive_name .. ". Try another") + end + return false + end +end + +if event.type == "init" then + F.print("Initialized") +end
\ No newline at end of file diff --git a/ers/nodes/(1655,1,1261).lua b/ers/nodes/(1655,1,1261).lua new file mode 100644 index 0000000..2d9ef7a --- /dev/null +++ b/ers/nodes/(1655,1,1261).lua @@ -0,0 +1,30 @@ +-- luaatctrack_main_depot_01.lua +local show_print = false +if event.train then + if atc_arrow then + local passive_name = "ErsDepotTurnaround" + local track_route = "" + local can_do_route = false + F.train_duration("start") + F.train_info(passive_name, show_print) + + if F.does_train_have_rc("ERSTAZIDEPOTUNLOAD") then + track_route = "01 UNLOADING TRACK" + F.send_route(passive_name, track_route, show_print) + elseif F.does_train_have_rc("ERSTAZITST") then + track_route = "02 LOADING TRACK" + F.send_route(passive_name, track_route, show_print) + else + track_route = "03 EXTRA" + can_do_route = F.send_route(passive_name, track_route, show_print) + if can_do_route == false then + track_route = "04 EXTRA" + F.send_route(passive_name, track_route, show_print) + end + end + else + local passive_name = "ErsDepotTurnaround" + F.train_duration("end") + F.train_info(passive_name, show_print) + end +end
\ No newline at end of file diff --git a/ers/nodes/(1655,1,1264).lua b/ers/nodes/(1655,1,1264).lua new file mode 100644 index 0000000..0cb6ef7 --- /dev/null +++ b/ers/nodes/(1655,1,1264).lua @@ -0,0 +1,6 @@ +-- luaoperatingpanel_depot_01.lua +local show_print = false +if event.type == "punch" then + F.train_info("RESETALL", show_print) + return +end
\ No newline at end of file diff --git a/ers/nodes/(3159,74,2331).lua b/ers/nodes/(3159,74,2331).lua new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/ers/nodes/(3159,74,2331).lua |