on_train_created and train.id useless?
on_train_created and train.id useless?
on_train_created and especially train.id seem less useful than I imagined they would be.
Triggering twice makes sense in all but one case
coupling two trains: fine
one trigger holding the coupled two trains as one train
decoupling trains: fine
first trigger holding the player controlled train
second trigger holding the decoupled train
removing/destroying a carriage: fine
one trigger for every part
placing a carriage by hand: wtf?
first trigger seems to create a new train with the placed carriage. Why?
second trigger is the original train with the carriage attached
If you place the same entities together in the same way it has to be the same train right?
Wrong, train id constantly increases even if the train itself consists of the same entities as before adding and removing some carriages. What would have been useful is a checksum consisting of all carriages unit_number.
This makes train.id pointless for keeping track of trains, especially sice on_train_created does not always give access to the old id so you could update your references.
Triggering twice makes sense in all but one case
coupling two trains: fine
one trigger holding the coupled two trains as one train
decoupling trains: fine
first trigger holding the player controlled train
second trigger holding the decoupled train
removing/destroying a carriage: fine
one trigger for every part
placing a carriage by hand: wtf?
first trigger seems to create a new train with the placed carriage. Why?
second trigger is the original train with the carriage attached
If you place the same entities together in the same way it has to be the same train right?
Wrong, train id constantly increases even if the train itself consists of the same entities as before adding and removing some carriages. What would have been useful is a checksum consisting of all carriages unit_number.
This makes train.id pointless for keeping track of trains, especially sice on_train_created does not always give access to the old id so you could update your references.
My Mods: mods.factorio.com
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: on_train_created and train.id useless?
So you're saying that every time you add or remove a carriage, the train ID changes? that does sound kind of pointless and makes train IDs useless.
Re: on_train_created and train.id useless?
Yes, that's exactly what happens.bobingabout wrote:So you're saying that every time you add or remove a carriage, the train ID changes? that does sound kind of pointless and makes train IDs useless.
Changing the id over and over would be bad in itself, but having no access to the old id through any event makes it utterly useless.
My Mods: mods.factorio.com
Re: on_train_created and train.id useless?
Can you try to move train with this mod? viewtopic.php?f=135&t=44345
Re: on_train_created and train.id useless?
The train ID changes when the LuaTrain would no longer be valid (every time a train is created).
if you're listening to the train created event then yes the ID is of no meaning to you - it's like unit number - it uniquely identifies the train.
if you're listening to the train created event then yes the ID is of no meaning to you - it's like unit number - it uniquely identifies the train.
If you want to get ahold of me I'm almost always on Discord.
Re: on_train_created and train.id useless?
What field will let us keep track of the "same train", and by "same train" I mean whatever the schedule follows?Rseding91 wrote:The train ID changes when the LuaTrain would no longer be valid (every time a train is created).
if you're listening to the train created event then yes the ID is of no meaning to you - it's like unit number - it uniquely identifies the train.
Re: on_train_created and train.id useless?
The schedule follows both trains. In the event that a train is split perfectly then you have 2 identical sized trains with the same schedule and same last train ID.sparr wrote:What field will let us keep track of the "same train", and by "same train" I mean whatever the schedule follows?Rseding91 wrote:The train ID changes when the LuaTrain would no longer be valid (every time a train is created).
if you're listening to the train created event then yes the ID is of no meaning to you - it's like unit number - it uniquely identifies the train.
If you want to get ahold of me I'm almost always on Discord.
Re: on_train_created and train.id useless?
Let me rephrase my question:Rseding91 wrote:The schedule follows both trains. In the event that a train is split perfectly then you have 2 identical sized trains with the same schedule and same last train ID.sparr wrote:What field will let us keep track of the "same train", and by "same train" I mean whatever the schedule follows?Rseding91 wrote:The train ID changes when the LuaTrain would no longer be valid (every time a train is created).
if you're listening to the train created event then yes the ID is of no meaning to you - it's like unit number - it uniquely identifies the train.
What value can we follow/track in a mod that will let us identify that one previously existing train and one new train are the same train, where "same train" is defined as continuity of schedule?
Re: on_train_created and train.id useless?
I'll add "last train IDs" to the created event when it's created as a result of splitting/merging trains.
If you want to get ahold of me I'm almost always on Discord.
Re: on_train_created and train.id useless?
What about adding one wagon?Rseding91 wrote:I'll add "last train IDs" to the created event when it's created as a result of splitting/merging trains.
Will it generate a new train id or simply update the existing to include the new wagon?
In case it generates new id's for both the wagon and the train it has to fire with old_id as the trains id so we can properly update internal tracking.
What when the previously added wagon is removed again?
Basically it's now the same train we started with. It consists of the same entities with the same unit_numbers.
My Mods: mods.factorio.com
Re: on_train_created and train.id useless?
My interpretation:Rseding91 wrote:I'll add "last train IDs" to the created event when it's created as a result of splitting/merging trains.
Trains are still going to get new IDs every time you modify them. What will change is that the event will also include the previous id(s) of any train(s) that the new id(s) describe.
If you have train tracking information in your mod then you will need to update that tracking information each time the event fires.
Re: on_train_created and train.id useless?
Correct. It already works that way for LuaTrain - the Id just makes it possible to know what some train was before it was destroyed.sparr wrote:My interpretation:Rseding91 wrote:I'll add "last train IDs" to the created event when it's created as a result of splitting/merging trains.
Trains are still going to get new IDs every time you modify them. What will change is that the event will also include the previous id(s) of any train(s) that the new id(s) describe.
If you have train tracking information in your mod then you will need to update that tracking information each time the event fires.
If you want to get ahold of me I'm almost always on Discord.
Re: on_train_created and train.id useless?
Back to the add one wagon to an existing train example. Currently it fires twice and i assume that won't change.Rseding91 wrote:Correct. It already works that way for LuaTrain - the Id just makes it possible to know what some train was before it was destroyed.sparr wrote:My interpretation:Rseding91 wrote:I'll add "last train IDs" to the created event when it's created as a result of splitting/merging trains.
Trains are still going to get new IDs every time you modify them. What will change is that the event will also include the previous id(s) of any train(s) that the new id(s) describe.
If you have train tracking information in your mod then you will need to update that tracking information each time the event fires.
1) on_train_created fires with the wagon
2) on_train_created fires with the train the wagon was attached to
What old_id will the 2nd time it fires hold? the wagon the train or both?
My Mods: mods.factorio.com
Re: on_train_created and train.id useless?
Both.
If you want to get ahold of me I'm almost always on Discord.