Update version to 0.2.2, improve network cache handling, and enhance train state tracking
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user