Electric Trains


Adds electric trains.

Content
a month ago
0.16 - 1.1
37.0K
Trains

g Crash on Server

5 years ago
(updated 5 years ago)

Sadly I have no idea what caused it, as I wasn't close to any trains when it crashed.

Running 0.16.43

Log:
4292.510 Error MainLoop.cpp:1030: Exception at tick 23921357: Error while running event ElectricTrains::on_nth_tick(23)
LuaEntity API call when LuaEntity was invalid.
stack traceback:
ElectricTrains/control.lua:170: in function <ElectricTrains/control.lua:148>
4292.510 Error ServerMultiplayerManager.cpp:96: MultiplayerManager failed: "Error while running event ElectricTrains::on_nth_tick(23)
LuaEntity API call when LuaEntity was invalid.
stack traceback:
ElectricTrains/control.lua:170: in function <ElectricTrains/control.lua:148>"
4292.510 Info ServerMultiplayerManager.cpp:699: mapTick(23921357) changing state from(InGame) to(Failed)

5 years ago

It looks as if the function that handles recharging trains tried to look up a value on a train that got removed. Without knowing more details (was the train blown up? Was it deconstructed? Etc.) I can't really diagnose the issue. Of course, this is two months old now so it's moot, but I'll look out for any other reports of the issue in the future.

5 years ago

Hey,

we are constantly getting the same message on our server, we only have one train running that goes to three stations, two of them are only activated via circuit network.

It's the same message:
2649.056 Error MainLoop.cpp:1035: Exception at tick 31001654: Error while running event ElectricTrains::on_nth_tick(23)
LuaEntity API call when LuaEntity was invalid.
stack traceback:
ElectricTrains/control.lua:170: in function <ElectricTrains/control.lua:148>
2649.056 Error ServerMultiplayerManager.cpp:96: MultiplayerManager failed: "Error while running event ElectricTrains::on_nth_tick(23)
LuaEntity API call when LuaEntity was invalid.
stack traceback:
ElectricTrains/control.lua:170: in function <ElectricTrains/control.lua:148>"

5 years ago

I think I may have narrowed down the issue. Can you upload a copy of the map somewhere for me to experiment with, please?

5 years ago

Yeah, you can add me on discord (NaliLord#8414), I can send it to you, currently it is 36MB.

5 years ago

Do we have a fix for this yet?

5 years ago

I still can't diagnose what's going wrong, so, no. If you can give me any further information, feel free to.

5 years ago

in Control.lua line 170 change:

    chargeTransferValue = math.min(maxFuelValue - currentFuelValue, v[2].energy, maxChargingRate)
    v[2].energy = v[2].energy - chargeTransferValue
    v[4].burner.remaining_burning_fuel = currentFuelValue + chargeTransferValue

to:

    if v[2] ~= nil and v[2].valid then
        chargeTransferValue = math.min(maxFuelValue - currentFuelValue, v[2].energy, maxChargingRate)
        v[2].energy = v[2].energy - chargeTransferValue
        v[4].burner.remaining_burning_fuel = currentFuelValue + chargeTransferValue
    end
5 years ago

Recently I fixed many mod errors myself by adding additional entity nil/valid checks.
I don't know how this checks impact the UPS but at least the crashing stops.

New response