Train Network for Players

by leeh

QoL and advanced functionality for players using trains for transport, including improved destination selection dialog and automated train calling.

Content
2 years ago
0.17 - 1.1
7.44K
Transportation

b Train Network for Players caused a non-recoverable error.

5 years ago

The mod Train Network for Players caused a non-recoverable error.
Please report this error to the mod author.

Error while running event TrainNetworkForPlayers::on_lua_shortcut (ID 34)
real number expected got nil.
stack traceback:
TrainNetworkForPlayers/tnp/train.lua:47: in function 'tnp_train_enact'
TrainNetworkForPlayers/tnp/action.lua:12: in function 'tnp_action_player_board'
TrainNetworkForPlayers/tnp/action.lua:63: in function 'tnp_action_player_request_boarded'
TrainNetworkForPlayers/tnp/event.lua:99: in function 'tnp_handle_request'
TrainNetworkForPlayers/tnp/event.lua:124: in function <TrainNetworkForPlayers/tnp/event.lua:122>
stack traceback:
[C]: in function 'newindex'
__TrainNetworkForPlayers
/tnp/train.lua:47: in function 'tnp_train_enact'
TrainNetworkForPlayers/tnp/action.lua:12: in function 'tnp_action_player_board'
TrainNetworkForPlayers/tnp/action.lua:63: in function 'tnp_action_player_request_boarded'
TrainNetworkForPlayers/tnp/event.lua:99: in function 'tnp_handle_request'
TrainNetworkForPlayers/tnp/event.lua:124: in function <TrainNetworkForPlayers/tnp/event.lua:122>

5 years ago

Looking at the code the error occurred when we tried to set a trains schedule -- though unfortunately it doesn't explain which field of the schedule its unhappy with. I can't seem to reproduce it with either of the two obvious numeric schedule fields set to nil (current station index, or wait condition timers) which makes this a little trickier.

Could you provide some further detail for me please? Ideally:
- Version of factorio
- Version of stdlib mod (Factorio Standard Library)
- Single player or multiplayer/headless

Also if you have any other context that'd be great, particularly if there's anything you know about what the train was doing before boarding and what its schedule would have looked like.

Cheers,

5 years ago

OK, Describing it will be a little difficult (where station is, what I'm doing, mods, moon phases ;) ). I'll try like this:

Steps to reproduce:
1. Download 0.17.60 from https://factorio.com/download/experimental (i've used linux one)
2. Downloads save+mods from: https://mega.nz/#!sJsiAQzA!wVYYHQKcksUlbm2Zg7Xrhq5lXybbXPwPXYOSZLAHh00
3. Copy folders to factorio
4. Run, load save (only 1 available), confirm some recepies changes.
5. Go to nearest train.
6. Hit "ALT + P"
CRASH
(disable auto in trains and move forward stil same)

Got another save (few more hours in game) - and eveything is fine.
On my latest one I'm not able to reproduce it. :/

BTW. If mega is not comfortable for you just ping me, will try to figure it something different.

5 years ago

Thanks, much appreciated for that, it helped to track everything down and I've just released v0.4.3 which should (hopefully) stop this error happening again.

In short, the error occurs when trying to set a trains schedule to one thats effectively empty -- this can happen for example when placing a train down from the players inventory, immediately boarding it and then pressing ALT+P, for various reasons that actually triggers tnfp to save and restore the trains schedule, which happens to be blank.

Now in versions 0.17.58 and earlier, it was valid to set a trains schedule to an empty object/hash (i.e. train.schedule = {}), but in 0.17.59 and above that now triggers this error and the schedule needs to be explicitly set to "nil" instead (or at least, not set to an empty hash ;-) ). It's unclear exactly why this changed, but I guess its just part of the fun of experimental releases...

Cheers, Lee H.

5 years ago

Excellent, thank You!

New response