diff --git a/info.json b/info.json index 3c72cf6..5a4fdd9 100644 --- a/info.json +++ b/info.json @@ -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", diff --git a/train-stats.lua b/train-stats.lua index 2b85e1d..0622bbd 100644 --- a/train-stats.lua +++ b/train-stats.lua @@ -9,11 +9,10 @@ end ---@param train LuaTrain function GetTrainName(train) if train.locomotives.front_movers[1] then - return train.locomotives.front_movers[1].backer_name - else if train.locomotives.back_movers[1] then - return train.locomotives.back_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 or "" end - 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