Private
Public Access
1
0

Update version to 0.2.2, improve network cache handling, and enhance train state tracking

This commit is contained in:
Jan Grießhaber
2026-01-04 10:37:10 +01:00
parent f40e219a2e
commit a44d27c386
6 changed files with 14 additions and 12 deletions

View File

@@ -64,6 +64,7 @@ function GetTrainStates()
elseif train.state == defines.train_state.on_the_path
or train.state == defines.train_state.arrive_signal
or train.state == defines.train_state.arrive_station
or train.state == defines.train_state.wait_signal
then trainsDriving = trainsDriving + 1
@@ -167,6 +168,7 @@ function onTrainStateChange(event)
if event.train.state == defines.train_state.wait_station then
if train.station.unit_number == stat.lastStationUnitNumber then return end
stat.lastStationUnitNumber = stat.currentStationUnitNumber
stat.lastInventory = stat.currentInventory
stat.lastArrivalTime = stat.currentArrivalTime
@@ -176,7 +178,8 @@ function onTrainStateChange(event)
stat.currentArrivalTime = game.tick
if stat.lastStationUnitNumber
and stat.currentStationUnitNumber then
and stat.currentStationUnitNumber
and (stat.lastStationUnitNumber ~= stat.currentStationUnitNumber) then
local tripIdentifier = tostring(stat.lastStationUnitNumber) .. tostring(stat.currentStationUnitNumber)
stat.trips[tripIdentifier] = {
startStation = game.get_entity_by_unit_number(stat.lastStationUnitNumber),