Update version to 0.1.22 and improve train name retrieval in GetTrainName function
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "factorio-metrics-exporter",
|
"name": "factorio-metrics-exporter",
|
||||||
"version": "0.1.21",
|
"version": "0.1.22",
|
||||||
"title": "Prometheus Metrics Exporter",
|
"title": "Prometheus Metrics Exporter",
|
||||||
"author": "Jan Grießhaber",
|
"author": "Jan Grießhaber",
|
||||||
"contact": "jan@griesshaber.systems",
|
"contact": "jan@griesshaber.systems",
|
||||||
|
|||||||
@@ -9,10 +9,9 @@ end
|
|||||||
---@param train LuaTrain
|
---@param train LuaTrain
|
||||||
function GetTrainName(train)
|
function GetTrainName(train)
|
||||||
if train.locomotives.front_movers[1] then
|
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
|
elseif train.locomotives.back_movers[1] then
|
||||||
return train.locomotives.back_movers[1].backer_name
|
return train.locomotives.back_movers[1].backer_name or ""
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
@@ -167,7 +166,7 @@ function GetTrainStatistics()
|
|||||||
local trainParts = {}
|
local trainParts = {}
|
||||||
trainParts[#trainParts+1] = "---train-total-statistics---\n"
|
trainParts[#trainParts+1] = "---train-total-statistics---\n"
|
||||||
for trainID, stat in pairs(storage.trainStats) do
|
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
|
end
|
||||||
return table.concat(trainParts,"\n")
|
return table.concat(trainParts,"\n")
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user