No Deconstruction Timeout

This is the place to request new mods or give ideas about what could be done.
adam_bise
Filter Inserter
Filter Inserter
Posts: 274
Joined: Fri Jun 08, 2018 10:42 pm
Contact:

No Deconstruction Timeout

Post by adam_bise »

Would like a mod or a push in the right direction to make one. All it would do is remove the timeout period for deconstruction marks.

All I can find is this from the API docs under Class LuaForce

deconstruction_time_to_live :: uint [Read/Write]
The time, in ticks, before a deconstruction order is removed.

Unfortunately, my only experience in modding is changing things in the lua files. I have no idea what to do with or how to manipulate something under "LuaForce Class"

Any assistance appreciated!

Don't know if it is relevant, but it should (hopefully) also work in multiplayer.

User avatar
jodokus31
Smart Inserter
Smart Inserter
Posts: 1394
Joined: Sun Feb 26, 2017 4:13 pm
Contact:

Re: No Deconstruction Timeout

Post by jodokus31 »

Console:

Code: Select all

/c game.player.force.deconstruction_time_to_live = 4294967295
this should last more than 2 years of playtime

Alternatively, you can call it from control.lua:

Code: Select all

script.on_init(function()
    for _, player in pairs(game.connected_players) do
        player.force.deconstruction_time_to_live = 4294967295
    end
end)
Did not test though...and not sure, if on_init is the best place.

adam_bise
Filter Inserter
Filter Inserter
Posts: 274
Joined: Fri Jun 08, 2018 10:42 pm
Contact:

Re: No Deconstruction Timeout

Post by adam_bise »

Thank you but I tried that and I tried putting this in migrations, but neither worked.

Code: Select all

for _, player in pairs(game.connected_players) do
    player.force.deconstruction_time_to_live = 4294967295
    end
end
The only way I tested was going to map editor and cranking up the speed and wait for about 44 days. The decon flags disappeared along with the ghosts underneath them.

I think it has to be applied to forces? Not sure.

User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 387
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: No Deconstruction Timeout

Post by Silari »

Did you check it on new ones, or on ones you had already ordered deconstructed? It'd almost certainly only take effect on new orders - time to live is generally set when the order is created.

It's being applied to player.force - that's the force the player using the console is on, usually 'player'

User avatar
jodokus31
Smart Inserter
Smart Inserter
Posts: 1394
Joined: Sun Feb 26, 2017 4:13 pm
Contact:

Re: No Deconstruction Timeout

Post by jodokus31 »

adam_bise wrote:
Tue Feb 15, 2022 1:23 am
Thank you but I tried that and I tried putting this in migrations, but neither worked.
Maybe the mod was already up-to-date and the migration didn't run anymore?
https://lua-api.factorio.com/latest/Dat ... ve-startup

adam_bise
Filter Inserter
Filter Inserter
Posts: 274
Joined: Fri Jun 08, 2018 10:42 pm
Contact:

Re: No Deconstruction Timeout

Post by adam_bise »

Thanks. In both cases I loaded the mod, created a new scenario in map editor, placed blueprint over trees, turn time to x64 and wait about 44 day cycles and the trees were unmarked and ghosts under them poofed.

I also tried saving the scenario and reloading. It looked like migrations was maybe tied to saving.

I will try it again in a bit.

Also, the mod doesn't have data.lua, is that OK? I didnt know what to put in there. Just info.json and migrations/migrations.lua

Also, just pointing out this is multiplayer. Not the map editor, but I would use it on a headless server.

User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 387
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: No Deconstruction Timeout

Post by Silari »

If you're in the map editor, you can go to the Forces tab, and click 'Edit Other Properties' and see what the value for 'deconstruction_time_to_live' is - that'll let you know if the migration took effect.

Note in multiplayer with a headless server that migration is probably going to do nothing - when the game loads there are no connected players, so it doesn't find anything to load. Iterating over forces directly is probably better - setting them all to max is fine since biters aren't deconstructing things, and that way you also get any forces made by mods.


Also from testing, it seems there's a bug in the game. deconstruction_time_to_live near the max value of a uint seems to go away almost immediately. Lowering it a little doesn't seem to stop it. So, gonna report that. Until then you might want to change your value to 4294957295 instead.

User avatar
jodokus31
Smart Inserter
Smart Inserter
Posts: 1394
Joined: Sun Feb 26, 2017 4:13 pm
Contact:

Re: No Deconstruction Timeout

Post by jodokus31 »

Silari wrote:
Tue Feb 15, 2022 6:20 pm
Also from testing, it seems there's a bug in the game. deconstruction_time_to_live near the max value of a uint seems to go away almost immediately. Lowering it a little doesn't seem to stop it. So, gonna report that. Until then you might want to change your value to 4294957295 instead.
Maybe something is adding a tiny bit to the number and then the uint overflows back to 0 again.
adam_bise wrote:
Tue Feb 15, 2022 2:55 pm
Also, the mod doesn't have data.lua, is that OK? I didnt know what to put in there. Just info.json and migrations/migrations.lua
I think, thats fine.
However:
Migrations are run in their mod's Lua state and have full access to the game state. If a mod doesn't have a control.lua file and thus no runtime Lua state, the game creates a temporary Lua environment to run the migrations in, which is discarded afterwards.
Maybe the change to game state doesn't stick without a control.lua? I'm not sure.

adam_bise
Filter Inserter
Filter Inserter
Posts: 274
Joined: Fri Jun 08, 2018 10:42 pm
Contact:

Re: No Deconstruction Timeout

Post by adam_bise »

Thank you very much for all the help.

This is what I tried, in migrations

Code: Select all

for _, force in pairs(game.forces) do
    force.deconstruction_time_to_live = 4000000000
    end
end
Would that count as iterating through forces?

But when I check in map editor, forces > edit properties, deconstruction-time-to-live shows 1080000

User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 387
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: No Deconstruction Timeout

Post by Silari »

Code: Select all

for _, force in pairs(game.forces) do
    force.deconstruction_time_to_live = 4000000000
end
There's an extra end in your version, which the game should be complaining about. I can confirm this one works as expected when I put it in a mod.

Double check your log file to make sure the mod is being loaded and that the migration is being called. There should be a line in there that it's running a migration right after loading the scenario, map, and running checksums on scripts.

Code: Select all

34.450 Applying migration: Asteroid Mining: test.lua
In this case it says it's running the migration test.lua from the mod Asteroid Mining.

If there's no line saying it's applying a migration, something is wrong, most likely the mod isn't being loaded at all or the file isn't in the right spot/not named correctly (should be in a subfolder called migrations and the file must end with .lua).

If you're still having issues with it, upload the mod zip here and I'll take a look at it.

adam_bise
Filter Inserter
Filter Inserter
Posts: 274
Joined: Fri Jun 08, 2018 10:42 pm
Contact:

Re: No Deconstruction Timeout

Post by adam_bise »

Log doesn't say loading mod, but does load the others, then goes on to say "1.793 Checksum of no-decon-timeout: 0"

I must be missing something stupid simple.

Here is the mod.
no-decon-timeout_1.1.0.zip
(2.55 KiB) Downloaded 113 times

User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 387
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: No Deconstruction Timeout

Post by Silari »

Oh right migrations AREN'T run on new games - you need to have it in the on_init event in control.lua for that.

Code: Select all

script.on_init(function()
    for _, force in pairs(game.forces) do
        force.deconstruction_time_to_live = 4000000000
    end
end)
Put that in control.lua and that should let it work fine. At least one of the two should run any time the mod is in a game so the timeout should be set properly.

adam_bise
Filter Inserter
Filter Inserter
Posts: 274
Joined: Fri Jun 08, 2018 10:42 pm
Contact:

Re: No Deconstruction Timeout

Post by adam_bise »


Rseding91
Factorio Staff
Factorio Staff
Posts: 12211
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: No Deconstruction Timeout

Post by Rseding91 »

Mind if I ask: why? The default is 2 hours but if you've marked something for deconstruction and over 2 hours later you still haven't gotten around to letting a robot work on it why is it important? Obviously it wasn't important since 2 hours has passed and it still wasn't handled.
If you want to get ahold of me I'm almost always on Discord.

robot256
Filter Inserter
Filter Inserter
Posts: 428
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: No Deconstruction Timeout

Post by robot256 »

It's confusing when the tree/rock deconstruction times out, but the ghost placed on top of it does not. Then you have to re-apply a filtered deconstruction planner or the original blueprint. Worst case, you don't notice until all your bots are hovering waiting to place things, and none are available to deconstruct until you cancel your original blueprint.

Time delays like this can happen for example in Space Exploration planning a planetary outpost before you have the resources for enough rockets to get there and build it.

Rseding91
Factorio Staff
Factorio Staff
Posts: 12211
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: No Deconstruction Timeout

Post by Rseding91 »

robot256 wrote:
Wed Feb 23, 2022 9:46 pm
It's confusing when the tree/rock deconstruction times out, but the ghost placed on top of it does not. Then you have to re-apply a filtered deconstruction planner or the original blueprint. Worst case, you don't notice until all your bots are hovering waiting to place things, and none are available to deconstruct until you cancel your original blueprint.

Time delays like this can happen for example in Space Exploration planning a planetary outpost before you have the resources for enough rockets to get there and build it.
That's not how it works. The ghost is removed when the deconstruction order times out.
If you want to get ahold of me I'm almost always on Discord.

User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 387
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: No Deconstruction Timeout

Post by Silari »

Rseding91 wrote:
Wed Feb 23, 2022 9:38 pm
Mind if I ask: why? The default is 2 hours but if you've marked something for deconstruction and over 2 hours later you still haven't gotten around to letting a robot work on it why is it important? Obviously it wasn't important since 2 hours has passed and it still wasn't handled.
You can see the thread OP made asking if timing out was a bug - it says what happened to them that they wanted the timeout longer: viewtopic.php?f=18&t=101590

robot256
Filter Inserter
Filter Inserter
Posts: 428
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: No Deconstruction Timeout

Post by robot256 »

Sorry, I misread that other post. So you're left with a partial blueprint with trees and holes in it. Still seems like a confusing and seemingly arbitrary difference in behavior from normal ghosts.

User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 387
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: No Deconstruction Timeout

Post by Silari »

Deconstruction is fundamentally different from construction though. Construction relies on having a specific material available to the network (cliff deconstruction included). Deconstruction doesn't - all you need is a free bot in range and the job can be done, nothing else needed. It doesn't even need space for storage as it doesn't seem to check that until after it grabs the item(s).

That said I'm not sure what advantage there is to having them expire. Possibly there's some overhead involved with having a bunch of orders around even if they can't be done/aren't in range of anything.

User avatar
jodokus31
Smart Inserter
Smart Inserter
Posts: 1394
Joined: Sun Feb 26, 2017 4:13 pm
Contact:

Re: No Deconstruction Timeout

Post by jodokus31 »

I mark something for deconstruction, because I want it to be deconstructed. I think, it adds to confusion, if the game decides, that the order was not important after 2 hours and removes it (probably without notice). If you work on a big project like solar, 2 hours might be short. Importance is not necessarily the same as urgency.

I get, if there are technical limitations or performance issues or simply a game design decision, other that I see no big benefit for the expiration.

Post Reply

Return to “Ideas and Requests For Mods”