Making remnants permanent

Place to get help with not working mods / modding interface.
Post Reply
dgw
Fast Inserter
Fast Inserter
Posts: 197
Joined: Tue Apr 12, 2016 7:06 pm
Contact:

Making remnants permanent

Post by dgw »

I discovered that the Naked Rails mod claims to make rail remnants permanent, but they are not. Suspecting that the wrong property was being used to set data.raw["rail-remnants"]["straight-rail-remnants"].time_to_live, I tried editing my local mod copy to set time_before_removed instead, but got an error that 0 is not an acceptable value. Setting it negative results in rail remnants that disappear instantly. The original behavior was that rail remnants faded out over time. (I haven't completely ruled out another mod interfering, but it seems more likely that the game simply doesn't use time_to_live for rail remnants.)

My question is this: How can a mod alter rail remnants so they never disappear and can be used for decorative purposes? Or any remnants, really; I'm just looking at rail remnants right now, to fix a bug in futileohm's existing mod.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5151
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Making remnants permanent

Post by Klonan »

dgw wrote:I discovered that the Naked Rails mod claims to make rail remnants permanent, but they are not. Suspecting that the wrong property was being used to set data.raw["rail-remnants"]["straight-rail-remnants"].time_to_live, I tried editing my local mod copy to set time_before_removed instead, but got an error that 0 is not an acceptable value. Setting it negative results in rail remnants that disappear instantly. The original behavior was that rail remnants faded out over time. (I haven't completely ruled out another mod interfering, but it seems more likely that the game simply doesn't use time_to_live for rail remnants.)

My question is this: How can a mod alter rail remnants so they never disappear and can be used for decorative purposes? Or any remnants, really; I'm just looking at rail remnants right now, to fix a bug in futileohm's existing mod.
Well, If you don't want them to expire, I suppose you can set `time_before_removed` to max int_32, like 2^30 or something

dgw
Fast Inserter
Fast Inserter
Posts: 197
Joined: Tue Apr 12, 2016 7:06 pm
Contact:

Re: Making remnants permanent

Post by dgw »

I guess 400-odd days (assuming I did my math right) ought to be quite long enough for any reasonable save file, haha.

Would it also be possible to do by, say, cloning the right properties of the built-in remnants (like sprites, dimensions, etc.) but making them instead a special kind of rail that trains can't use for pathfinding? I know entities can be disabled (and are when e.g. marked for deconstruction), so maybe that would be another approach?

User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2634
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: Making remnants permanent

Post by steinio »

Hi,

i updated Naked Rails to 016 and changed the remnant behaviour.

The api recommend .time_to_live = 4294967295 and itseems fine so far(15 minutes tested).
http://lua-api.factorio.com/0.16.16/Lua ... me_to_live

Whats the difference between time to live and time before removed?

Greetings, steinio.
Image

Transport Belt Repair Man

View unread Posts

Bilka
Factorio Staff
Factorio Staff
Posts: 3159
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Making remnants permanent

Post by Bilka »

steinio wrote:Whats the difference between time to live and time before removed?
time_before_removed is the name of the property in the data phase for corpses/rail remants, time_to_live is the name of the property in the data phase for combat robots and flying-text and is how you access it in the the control phase for combat robot and entity ghosts. The rail-remnants/corpse prototype doesnt have the time_to_live property.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2634
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: Making remnants permanent

Post by steinio »

Bilka wrote:
steinio wrote:Whats the difference between time to live and time before removed?
time_before_removed is the name of the property in the data phase for corpses/rail remants, time_to_live is the name of the property in the data phase for combat robots and flying-text and is how you access it in the the control phase for combat robot and entity ghosts. The rail-remnants/corpse prototype doesnt have the time_to_live property.
Thank you.

I get no error on missing attribute so far and t-b-r is not documented for LuaEntitiy: http://lua-api.factorio.com/0.16.16/LuaEntity.html

I'll try it out.

Edit:
time_to_live lasted nearly 1,5 hours
time_before_removed had no effect and the remnants got removed instantly with a value of 4294967295
Last edited by steinio on Wed Jan 17, 2018 8:03 pm, edited 1 time in total.
Image

Transport Belt Repair Man

View unread Posts

Bilka
Factorio Staff
Factorio Staff
Posts: 3159
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Making remnants permanent

Post by Bilka »

steinio wrote: I get no error on missing attribute so far and t-b-r is not documented for LuaEntitiy: http://lua-api.factorio.com/0.16.16/LuaEntity.html

I'll try it out.
It's not erroring because it defaults to 60 * 120. That doc is for the control phase and not the data phase, so it doesnt really matter for you. https://wiki.factorio.com/Prototype/Corpse matters for you, which is why I just created it.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Bilka
Factorio Staff
Factorio Staff
Posts: 3159
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Making remnants permanent

Post by Bilka »

steinio wrote:time_to_live lasted nearly 1,5 hours
time_before_removed had no effect and the remnants got removed instantly with a value of 4294967295
That doesnt make any sense. Rail remnants use time_before_removed as seen in line 176 in base\prototypes\entity\demo-remnants.lua, and when I look at the source code, I can also see that time_to_live is not a valid property in the data phase. Are you perhaps talking about the control phase, unlike the originial post? (And ignoring that I specifed what was for the data and what for the control phase...)
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2634
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: Making remnants permanent

Post by steinio »

Bilka wrote:
steinio wrote:time_to_live lasted nearly 1,5 hours
time_before_removed had no effect and the remnants got removed instantly with a value of 4294967295
That doesnt make any sense. Rail remnants use time_before_removed as seen in line 176 in base\prototypes\entity\demo-remnants.lua, and when I look at the source code, I can also see that time_to_live is not a valid property in the data phase. Are you perhaps talking about the control phase, unlike the originial post? (And ignoring that I specifed what was for the data and what for the control phase...)
Well, just a little happy coincidence...

data phase is correct
.time_to_live got ignored and the vanilla time get used (45 minutes)
.time_before_removed is an uint and i assigned the max value for an uint32 what probably did a bufferoverflow into a negative value what means instantly...

Now i asisgnend 2^30 instead and it seems fine for 3hours (time tools 64x).
Image

Transport Belt Repair Man

View unread Posts

Bilka
Factorio Staff
Factorio Staff
Posts: 3159
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Making remnants permanent

Post by Bilka »

steinio wrote: .time_before_removed is an uint and i assigned the max value for an uint32 what probably did a bufferoverflow into a negative value what means instantly...
It's imported as a float and cast to an int32, but otherwise you seem to be correct.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

dgw
Fast Inserter
Fast Inserter
Posts: 197
Joined: Tue Apr 12, 2016 7:06 pm
Contact:

Re: Making remnants permanent

Post by dgw »

Bilka wrote:and when I look at the source code, I can also see that time_to_live is not a valid property in the data phase.
Source code would have probably made it unnecessary for me to open this topic in the first place, haha. The docs are pretty good, but not perfect.

Bilka
Factorio Staff
Factorio Staff
Posts: 3159
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Making remnants permanent

Post by Bilka »

dgw wrote:
Bilka wrote:and when I look at the source code, I can also see that time_to_live is not a valid property in the data phase.
Source code would have probably made it unnecessary for me to open this topic in the first place, haha. The docs are pretty good, but not perfect.
Yeah, the docs are still lacking so much :/ I'm trying to work on them, but the main wiki is simply more important :(
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Post Reply

Return to “Modding help”