diff --git a/cybersyn/locale/en/base.cfg b/cybersyn/locale/en/base.cfg index de9e67f..bb4e17a 100644 --- a/cybersyn/locale/en/base.cfg +++ b/cybersyn/locale/en/base.cfg @@ -37,9 +37,9 @@ cybersyn-locked-slots=Locked slots per cargo wagon [cybersyn-messages] missing-trains=No trains available to make a delivery from __2__ to __1__ -lost-train=A train has become lost -nonempty-train=A train has parked in a depot while still containing items; it cannot be dispatched until it is empty -unexpected-train=A train has returned to the depot before completing it's delivery +lost-train=A train from depot __1__ has become lost +nonempty-train=A train is being held in the depot because it still has cargo +unexpected-train=A train has returned to the depot before completing its delivery [cybersyn-gui] combinator-title=Cybernetic combinator diff --git a/cybersyn/scripts/factorio-api.lua b/cybersyn/scripts/factorio-api.lua index 71bf86b..1134e81 100644 --- a/cybersyn/scripts/factorio-api.lua +++ b/cybersyn/scripts/factorio-api.lua @@ -219,14 +219,15 @@ end local send_lost_train_alert_icon = {name = LOST_TRAIN_NAME, type = "fluid"} ---@param train LuaTrain -function send_lost_train_alert(train) +---@param depot_name string +function send_lost_train_alert(train, depot_name) local loco = train.front_stock or train.back_stock if loco then for _, player in pairs(loco.force.players) do player.add_custom_alert( loco, send_lost_train_alert_icon, - {"cybersyn-messages.lost-train"}, + {"cybersyn-messages.lost-train", depot_name}, true) player.play_sound({path = ALERT_SOUND}) end diff --git a/cybersyn/scripts/layout.lua b/cybersyn/scripts/layout.lua index 2c7423c..7e86c1a 100644 --- a/cybersyn/scripts/layout.lua +++ b/cybersyn/scripts/layout.lua @@ -22,10 +22,8 @@ end ---@param train Train ---@param train_id uint function remove_train(map_data, train, train_id) - map_data.trains[train_id] = nil - local depot = train.depot - if depot then - remove_available_train(map_data, depot) + if train.depot then + remove_available_train(map_data, train.depot) end local layout_id = train.layout_id local count = map_data.layout_train_count[layout_id] @@ -38,6 +36,7 @@ function remove_train(map_data, train, train_id) else map_data.layout_train_count[layout_id] = count - 1 end + map_data.trains[train_id] = nil end ---@param map_data MapData diff --git a/cybersyn/scripts/main.lua b/cybersyn/scripts/main.lua index 7e5d410..125d464 100644 --- a/cybersyn/scripts/main.lua +++ b/cybersyn/scripts/main.lua @@ -162,7 +162,7 @@ local function on_station_broken(map_data, station_id, station) on_failed_delivery(map_data, train) train.entity.schedule = nil remove_train(map_data, train, train_id) - send_lost_train_alert(train.entity) + send_lost_train_alert(train.entity, train.depot_name) end end end @@ -609,7 +609,7 @@ local function on_train_arrives_buffer(map_data, stop, train) on_failed_delivery(map_data, train) remove_train(map_data, train, train.entity.id) train.entity.schedule = nil - send_lost_train_alert(train.entity) + send_lost_train_alert(train.entity, train.depot_name) end else --train is lost somehow, probably from player intervention