Unable to deconstruct entity that lacks a paired item

Place to get help with not working mods / modding interface.
Post Reply
User avatar
Afforess
Filter Inserter
Filter Inserter
Posts: 422
Joined: Tue May 05, 2015 6:07 pm
Contact:

Unable to deconstruct entity that lacks a paired item

Post by Afforess »

I am confused about how the deconstruction planner works. I have an entity that is a slightly modified deepcopy of the radar entity. No essential fields are modified. It has no associated item, which is intentional, because the entity is only spawned by control.lua scripting. As a result of this, it seems the entity also can not be marked as an entity to deconstruct by the deconstruction planner. Additionally, the entity does have a minable result, which does drop a regular item. The entity can be mined by hand by players just fine.

The solution here seems obvious, right? Add an item for the entity? Except this doesn't make sense -Trees and rocks are deconstructable by the planner and have no associated entity - only a minable result. So what exactly is going on here? Are trees and rocks some special case in the game engine? Am I missing something else entirely?

Jeroen D Stout
Inserter
Inserter
Posts: 33
Joined: Fri May 05, 2017 2:09 pm
Contact:

Re: Unable to deconstruct entity that lacks a paired item

Post by Jeroen D Stout »

I have the same problem in my mod. I swap entities with almost identical ones to change behaviour; bots will not pick the ones up that have no unique item.

This might be bug report worthy; IMHO bots should just pick up entities that mine into a different item.

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Unable to deconstruct entity that lacks a paired item

Post by Nexela »

This is how I handle blueprinting and deconstructing and deconstructing a combined entity in nanobots. Might help a little bit in figuring out ways to make it work.

https://github.com/Nexela/Nanobots/blob ... e.lua#L215
https://github.com/Nexela/Nanobots/blob ... erface.lua

The radar I don't care about so when the roboport is build/delete the radar is built/deleted
but this allows blueprint the roboport or the combinator and it will keep settings.
This is accomplished by using on_built entity to teleport everything into their correct places.

User avatar
Afforess
Filter Inserter
Filter Inserter
Posts: 422
Joined: Tue May 05, 2015 6:07 pm
Contact:

Re: Unable to deconstruct entity that lacks a paired item

Post by Afforess »

Nexela wrote:This is how I handle blueprinting and deconstructing and deconstructing a combined entity in nanobots. Might help a little bit in figuring out ways to make it work.
Good to know, but my main question is about understanding how the deconstruction planner actually works. I'd at least at like to understand why trees and rocks and other materials which are minable can be deconstructed using the planner, but other entities can not unless they have an item.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Unable to deconstruct entity that lacks a paired item

Post by bobingabout »

Trees and rocks have an item assigned. there was a time when rocks didn't, and you couldn't mine them, they were a pain in the ass.

basically though, for something to be minable (deconstructable) it needs this tag

Code: Select all

    minable = {hardness = 0.2, mining_time = 0.5, result = "underground-belt"},
in this case, a mined entity will give you an underground belt item. You can list any item you want. it SHOULD be unique with a tag as follows

Code: Select all

    place_result = "underground-belt",
listing the name of the entity that gives you the same item, however, you could have multiple entities that give the same item, or multiple items that construct the same entity, and it SHOULD work just fine.

what happens if you don't want an item? include an item, but give it

Code: Select all

          probability = 0
and that will cause it to give you an item 0% of the time, but allow it to be mined.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

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

Re: Unable to deconstruct entity that lacks a paired item

Post by Rseding91 »

You can define an entity as mineable but have no result.

The reason entities can't be deconstructed is they share a check with blueprintable in that it must have an item that builds the entity to be deconstructed.

I don't think that is strictly required so I'll look into changing it to allow deconstructing entities that have no item-to-place.
If you want to get ahold of me I'm almost always on Discord.

Jeroen D Stout
Inserter
Inserter
Posts: 33
Joined: Fri May 05, 2017 2:09 pm
Contact:

Re: Unable to deconstruct entity that lacks a paired item

Post by Jeroen D Stout »

Rseding91 wrote:I don't think that is strictly required so I'll look into changing it to allow deconstructing entities that have no item-to-place.
Thank you for looking into this!

Might it also be possible for entities to get a "blueprint as" tag for mod purposes? I.e., a modified entity being blueprinted as its original? (So a "radar-modified" would turn into a "radar" in a blueprint.) That might solve a lot of the slightly hacky "replace entity to change behaviour" things mods do at the moment.

User avatar
Afforess
Filter Inserter
Filter Inserter
Posts: 422
Joined: Tue May 05, 2015 6:07 pm
Contact:

Re: Unable to deconstruct entity that lacks a paired item

Post by Afforess »

Rseding91 wrote:You can define an entity as mineable but have no result.

The reason entities can't be deconstructed is they share a check with blueprintable in that it must have an item that builds the entity to be deconstructed.

I don't think that is strictly required so I'll look into changing it to allow deconstructing entities that have no item-to-place.
I've been on hiatus for a while, but the 0.16 update brought me back... Any idea if any changes surrounding this occured?

User avatar
Therax
Filter Inserter
Filter Inserter
Posts: 470
Joined: Sun May 21, 2017 6:28 pm
Contact:

Re: Unable to deconstruct entity that lacks a paired item

Post by Therax »

There still seem to be some odd inconsistencies between how player mining works and robot-managed deconstruction works.

As I'm working on adding circuit and filter support to Miniloaders, I have made the formerly invisible inserter entities interactable. So each miniloader consists of an underground-belt (empty selection_box) and an inserter (with selection_box). The item has the underground-belt as its place_result, and both the underground-belt and the inserter have minable.result yielding the item.

When the player mines a miniloader, the actual entity that is mined is the inserter, since it has a selection_box, and by script I clean up the underground-belt.

When a robot mines a miniloader, the actual entity that is mined is the underground-belt, it appears from this thread because the underground-belt has an item with the underground-belt as its place_result, but the inserter does not, and I must clean up with inserter via script.

It certainly makes for some odd scripting.
Miniloader — UPS-friendly 1x1 loaders
Bulk Rail Loaders — Rapid train loading and unloading
Beltlayer & Pipelayer — Route items and fluids freely underground

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

Re: Unable to deconstruct entity that lacks a paired item

Post by Rseding91 »

I've changed it for the next version of 0.16 so an entity that's mineable but doesn't have an item-to-place can still be deconstructed.
If you want to get ahold of me I'm almost always on Discord.

User avatar
Therax
Filter Inserter
Filter Inserter
Posts: 470
Joined: Sun May 21, 2017 6:28 pm
Contact:

Re: Unable to deconstruct entity that lacks a paired item

Post by Therax »

Rseding91 wrote:I've changed it for the next version of 0.16 so an entity that's mineable but doesn't have an item-to-place can still be deconstructed.
I must still be missing something. I have an entity that has no item-to-place, but is minable

Code: Select all

entity.minable = { mining_time = 1, count = 1, result = "raw-wood" }
but at runtime calling

Code: Select all

entity.order_deconstruction(entity.force)
returns false. What other conditions need to be satisfied to be able to mark an entity for deconstruction?
Miniloader — UPS-friendly 1x1 loaders
Bulk Rail Loaders — Rapid train loading and unloading
Beltlayer & Pipelayer — Route items and fluids freely underground

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

Re: Unable to deconstruct entity that lacks a paired item

Post by Rseding91 »

The entity just has to be mineable. What entity type are you using?
If you want to get ahold of me I'm almost always on Discord.

User avatar
Therax
Filter Inserter
Filter Inserter
Posts: 470
Joined: Sun May 21, 2017 6:28 pm
Contact:

Re: Unable to deconstruct entity that lacks a paired item

Post by Therax »

Rseding91 wrote:The entity just has to be mineable. What entity type are you using?
Entity type is "loader". I was able to get it to work by adding "player-creation" to the entity's flags.

Is there documentation somewhere on what all the different flags mean? Some of them are relatively clear from their names, but what's the link between "player-creation" and deconstruction?
Miniloader — UPS-friendly 1x1 loaders
Bulk Rail Loaders — Rapid train loading and unloading
Beltlayer & Pipelayer — Route items and fluids freely underground

User avatar
Afforess
Filter Inserter
Filter Inserter
Posts: 422
Joined: Tue May 05, 2015 6:07 pm
Contact:

Re: Unable to deconstruct entity that lacks a paired item

Post by Afforess »

Rseding91 wrote:
Sun Dec 31, 2017 10:48 pm
I've changed it for the next version of 0.16 so an entity that's mineable but doesn't have an item-to-place can still be deconstructed.
This no longer seems to be fixed in 1.0. I remember that 0.16 worked as expected and entities that were minable without a paired item could be deconstructed by the deconstruction planner, but in 0.17 and 1.0 it appears the change was lost or broken in some way. What is the expected behavior for these type of entities @Rseding91?

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

Re: Unable to deconstruct entity that lacks a paired item

Post by Rseding91 »

Afforess wrote:
Sun Oct 04, 2020 7:14 pm
Rseding91 wrote:
Sun Dec 31, 2017 10:48 pm
I've changed it for the next version of 0.16 so an entity that's mineable but doesn't have an item-to-place can still be deconstructed.
This no longer seems to be fixed in 1.0. I remember that 0.16 worked as expected and entities that were minable without a paired item could be deconstructed by the deconstruction planner, but in 0.17 and 1.0 it appears the change was lost or broken in some way. What is the expected behavior for these type of entities @Rseding91?
It looks like actually in version 0.15.0 it was changed that it wouldn't allow deconstructing stuff without an item-to-place it. Have you actually tested if 0.15 or 0.16 allowed that?
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Modding help”