Private
Public Access
1
0

Update version to 0.1.22 and improve train name retrieval in GetTrainName function

This commit is contained in:
Jan Grießhaber
2026-01-03 19:49:00 +01:00
parent f25adfcaa3
commit 7dc542e448
2 changed files with 5 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "factorio-metrics-exporter",
"version": "0.1.21",
"version": "0.1.22",
"title": "Prometheus Metrics Exporter",
"author": "Jan Grießhaber",
"contact": "jan@griesshaber.systems",

View File

@@ -9,10 +9,9 @@ end
---@param train LuaTrain
function GetTrainName(train)
if train.locomotives.front_movers[1] then
return train.locomotives.front_movers[1].backer_name
return train.locomotives.front_movers[1].backer_name or ""
elseif train.locomotives.back_movers[1] then
return train.locomotives.back_movers[1].backer_name
end
return train.locomotives.back_movers[1].backer_name or ""
end
return ""
end
@@ -167,7 +166,7 @@ function GetTrainStatistics()
local trainParts = {}
trainParts[#trainParts+1] = "---train-total-statistics---\n"
for trainID, stat in pairs(storage.trainStats) do
trainParts[#trainParts+1] = ("%s:%s:%d"):format(trainID,GetTrainName(storage.trains[trainID]),stat.totalCargoCount)
trainParts[#trainParts+1] = ("%d:%s:%d"):format(trainID,GetTrainName(storage.trains[trainID]),stat.totalCargoCount or 0)
end
return table.concat(trainParts,"\n")
end