Page 1 of 1

Making remnants permanent

Posted: Sat Nov 25, 2017 10:23 am
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.

Re: Making remnants permanent

Posted: Sat Nov 25, 2017 11:25 am
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

Re: Making remnants permanent

Posted: Mon Nov 27, 2017 8:01 am
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?

Re: Making remnants permanent

Posted: Wed Jan 17, 2018 7:35 pm
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.

Re: Making remnants permanent

Posted: Wed Jan 17, 2018 7:42 pm
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.

Re: Making remnants permanent

Posted: Wed Jan 17, 2018 7:55 pm
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

Re: Making remnants permanent

Posted: Wed Jan 17, 2018 8:01 pm
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.

Re: Making remnants permanent

Posted: Wed Jan 17, 2018 8:15 pm
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...)

Re: Making remnants permanent

Posted: Wed Jan 17, 2018 8:26 pm
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).

Re: Making remnants permanent

Posted: Wed Jan 17, 2018 8:36 pm
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.

Re: Making remnants permanent

Posted: Wed Jan 17, 2018 9:26 pm
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.

Re: Making remnants permanent

Posted: Wed Jan 17, 2018 10:00 pm
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 :(