Skip to content

Commit 50f39eb

Browse files
committed
Version: 1.16.10
Date: 2022-07-22 Features: - use RichText [train-stop=uid] for stations - use RichText [train=uid] for trains Changes: - GPS tags disabled by default, was too spammy
1 parent 02159af commit 50f39eb

File tree

8 files changed

+45
-22
lines changed

8 files changed

+45
-22
lines changed

changelog.txt

+8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
---------------------------------------------------------------------------------------------------
2+
Version: 1.16.10
3+
Date: 2022-07-22
4+
Features:
5+
- use RichText [train-stop=uid] for stations
6+
- use RichText [train=uid] for trains
7+
Changes:
8+
- GPS tags disabled by default, was too spammy
9+
---------------------------------------------------------------------------------------------------
210
Version: 1.16.9
311
Date: 2022-06-19
412
Bugfixes:

info.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "LogisticTrainNetwork",
3-
"version": "1.16.9",
3+
"version": "1.16.10",
44
"title": "LTN - Logistic Train Network",
55
"author": "Optera",
66
"contact": "https://forums.factorio.com/memberlist.php?mode=viewprofile&u=21729",

locale/de/base.cfg

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ delivery-removed-depot=[LTN] Lieferung von __1__ nach __2__ entfernt. Zug ist in
7474
delivery-removed-train-invalid=[LTN] Lieferung von __1__ nach __2__ entfernt. Zug existiert nicht mehr.
7575
delivery-removed-timeout=[LTN] Lieferung von __1__ nach __2__ wegen Time-Out nach __3__ Ticks entfernt.
7676

77-
train-arrived=[LTN] Zug __1__ ist in __2__ angekommen.
78-
train-left=[LTN] Zug __1__ hat __2__ verlassen.
77+
train-arrived=[LTN] __1__ ist in __2__ angekommen.
78+
train-left=[LTN] __1__ hat __2__ verlassen.
7979

8080
provider_missing_cargo=[LTN] Zug __1__ hat Anbieterhaltestelle __2__ mit fehlender Fracht verlassen.
8181
provider_unscheduled_cargo=[LTN] Zug __1__ hat Anbieterhaltestelle __2__ mit ungeplanter Fracht verlassen.

locale/en/base.cfg

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ delivery-removed-depot=[LTN] Delivery from __1__ to __2__ removed. Train returne
7474
delivery-removed-train-invalid=[LTN] Delivery from __1__ to __2__ removed. Train no longer valid.
7575
delivery-removed-timeout=[LTN] Delivery from __1__ to __2__ running for __3__ ticks removed after time out.
7676
77-
train-arrived=[LTN] Train __1__ arrived at __2__.
78-
train-left=[LTN] Train __1__ left __2__.
77+
train-arrived=[LTN] __1__ arrived at __2__.
78+
train-left=[LTN] __1__ departed from __2__.
7979
8080
provider_missing_cargo=[LTN] Train __1__ left provider __2__ with missing cargo.
8181
provider_unscheduled_cargo=[LTN] Train __1__ left provider __2__ with unscheduled cargo.

script/dispatcher.lua

+7-7
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ function OnTick(event)
6363
if message_level >= 1 then
6464
printmsg({
6565
"ltn-message.delivery-removed-train-invalid",
66-
MakeGpsString(from_entity, delivery.from),
67-
MakeGpsString(to_entity, delivery.to)
66+
Make_Stop_RichText(from_entity) or delivery.from,
67+
Make_Stop_RichText(to_entity) or delivery.to
6868
}, delivery.force, false)
6969
end
7070
if debug_log then log("(OnTick) Delivery from "..delivery.from.." to "..delivery.to.." removed. Train no longer valid.") end
@@ -77,8 +77,8 @@ function OnTick(event)
7777
if message_level >= 1 then
7878
printmsg({
7979
"ltn-message.delivery-removed-timeout",
80-
MakeGpsString(from_entity, delivery.from),
81-
MakeGpsString(to_entity, delivery.to),
80+
Make_Stop_RichText(from_entity) or delivery.from,
81+
Make_Stop_RichText(to_entity) or delivery.to,
8282
tick-delivery.started
8383
}, delivery.force, false)
8484
end
@@ -438,7 +438,7 @@ function ProcessRequest(reqIndex, request)
438438
local to = requestStation.entity.backer_name
439439
local to_rail = requestStation.entity.connected_rail
440440
local to_rail_direction = requestStation.entity.connected_rail_direction
441-
local to_gps = MakeGpsString(requestStation.entity, to)
441+
local to_gps = Make_Stop_RichText(requestStation.entity) or to
442442
local to_network_id_string = format("0x%x", band(requestStation.network_id))
443443
local item = request.item
444444
local count = request.count
@@ -507,7 +507,7 @@ function ProcessRequest(reqIndex, request)
507507
local from_rail = providerData.entity.connected_rail
508508
local from_rail_direction = providerData.entity.connected_rail_direction
509509
local from = providerData.entity.backer_name
510-
local from_gps = MakeGpsString(providerData.entity, from)
510+
local from_gps = Make_Stop_RichText(providerData.entity) or from
511511
local matched_network_id_string = format("0x%x", band(providerData.network_id))
512512

513513
if message_level >= 3 then printmsg({"ltn-message.provider-found", from_gps, tostring(providerData.priority), tostring(providerData.activeDeliveryCount), providerData.count, "[" .. itype .. "=" .. iname .. "]"}, requestForce, true) end
@@ -584,7 +584,7 @@ function ProcessRequest(reqIndex, request)
584584
local selectedTrain = free_trains[1].train
585585
local trainInventorySize = free_trains[1].inventory_size
586586

587-
if message_level >= 3 then printmsg({"ltn-message.train-found", from, to, matched_network_id_string, tostring(trainInventorySize), tostring(totalStacks) }, requestForce) end
587+
if message_level >= 3 then printmsg({"ltn-message.train-found", from_gps, to_gps, matched_network_id_string, tostring(trainInventorySize), tostring(totalStacks) }, requestForce) end
588588
if debug_log then log("Train to transport "..tostring(trainInventorySize).."/"..tostring(totalStacks).." stacks from "..from.." to "..to.." in network "..matched_network_id_string.." found in Depot.") end
589589

590590
-- recalculate delivery amount to fit in train

script/train-events.lua

+6-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ function TrainArrives(train)
4141
end
4242
local is_provider = false
4343

44-
if message_level >= 3 then printmsg({"ltn-message.train-arrived", tostring(trainName), stop_name}, trainForce, false) end
44+
-- if message_level >= 3 then printmsg({"ltn-message.train-arrived", tostring(trainName), stop_name}, trainForce, false) end
45+
if message_level >= 3 then printmsg({"ltn-message.train-arrived", Make_Train_RichText(train, trainName), format("[train-stop=%d]", stopID)}, trainForce, false) end
4546
if debug_log then log(format("(TrainArrives) Train [%d] \"%s\": arrived at LTN-stop [%d] \"%s\"; train_faces_stop: %s", train.id, trainName, stopID, stop_name, stop.parked_train_faces_stop )) end
4647

4748
if stop.error_code == 0 then
@@ -52,8 +53,8 @@ function TrainArrives(train)
5253
if message_level >= 1 then
5354
printmsg({
5455
"ltn-message.delivery-removed-depot",
55-
MakeGpsString(from_entity, delivery.from),
56-
MakeGpsString(to_entity, delivery.to)
56+
Make_Stop_RichText(from_entity) or delivery.from,
57+
Make_Stop_RichText(to_entity) or delivery.to
5758
}, delivery.force, false)
5859
end
5960
if debug_log then log(format("(TrainArrives) Train [%d] \"%s\": Entered Depot with active Delivery. Failing Delivery and reseting train.", train.id, trainName)) end
@@ -318,7 +319,8 @@ function TrainLeaves(trainID)
318319
-- remove train reference
319320
stop.parked_train = nil
320321
stop.parked_train_id = nil
321-
if message_level >= 3 then printmsg({"ltn-message.train-left", tostring(stoppedTrain.name), stop.entity.backer_name}, stoppedTrain.force) end
322+
-- if message_level >= 3 then printmsg({"ltn-message.train-left", tostring(stoppedTrain.name), stop.entity.backer_name}, stoppedTrain.force) end
323+
if message_level >= 3 then printmsg({"ltn-message.train-left", Make_Train_RichText(train, stoppedTrain.name), format("[train-stop=%d]", stopID)}, stoppedTrain.force, false) end
322324
UpdateStopOutput(stop)
323325

324326
global.StoppedTrains[trainID] = nil

script/utils.lua

+18-5
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,25 @@ function GetTrainCapacity(train)
4040
return inventorySize, fluidCapacity
4141
end
4242

43-
-- returns gps string from entity or just string if entity is invalid
44-
function MakeGpsString(entity, name)
45-
if message_include_gps and entity and entity.valid then
46-
return format("%s [gps=%s,%s,%s]", name, entity.position["x"], entity.position["y"], entity.surface.name)
43+
-- returns rich text string for train stops, or nil if entity is invalid
44+
function Make_Stop_RichText(entity)
45+
if entity and entity.valid then
46+
if message_include_gps then
47+
return format("[train-stop=%d] [gps=%s,%s,%s]", entity.unit_number, entity.position["x"], entity.position["y"], entity.surface.name)
48+
else
49+
return format("[train-stop=%d]", entity.unit_number)
50+
end
4751
else
48-
return name
52+
return nil
4953
end
5054
end
5155

56+
-- returns rich text string for trains, or nil if entity is invalid
57+
function Make_Train_RichText(train, train_name)
58+
local loco = Get_Main_Locomotive(train)
59+
if loco and loco.valid then
60+
return format("[train=%d] %s", loco.unit_number, train_name)
61+
else
62+
return format("[train=] %s", train_name)
63+
end
64+
end

settings.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ data:extend({
5252
name = "ltn-interface-message-gps",
5353
order = "af",
5454
setting_type = "runtime-global",
55-
default_value = true
55+
default_value = false
5656
},
5757
{
5858
type = "bool-setting",

0 commit comments

Comments
 (0)