Page 1 of 1

Unable to deconstruct entity that lacks a paired item

Posted: Fri May 19, 2017 12:23 am
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?

Re: Unable to deconstruct entity that lacks a paired item

Posted: Sat May 20, 2017 1:46 pm
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.

Re: Unable to deconstruct entity that lacks a paired item

Posted: Sat May 20, 2017 2:11 pm
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.

Re: Unable to deconstruct entity that lacks a paired item

Posted: Sat May 20, 2017 6:44 pm
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.

Re: Unable to deconstruct entity that lacks a paired item

Posted: Sat May 20, 2017 11:16 pm
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.

Re: Unable to deconstruct entity that lacks a paired item

Posted: Sun May 21, 2017 5:15 am
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.

Re: Unable to deconstruct entity that lacks a paired item

Posted: Sun May 21, 2017 12:54 pm
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.

Re: Unable to deconstruct entity that lacks a paired item

Posted: Sun Dec 31, 2017 7:27 pm
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?

Re: Unable to deconstruct entity that lacks a paired item

Posted: Sun Dec 31, 2017 10:21 pm
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.

Re: Unable to deconstruct entity that lacks a paired item

Posted: Sun Dec 31, 2017 10:48 pm
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.

Re: Unable to deconstruct entity that lacks a paired item

Posted: Thu Jan 18, 2018 8:56 am
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?

Re: Unable to deconstruct entity that lacks a paired item

Posted: Thu Jan 18, 2018 9:02 am
by Rseding91
The entity just has to be mineable. What entity type are you using?

Re: Unable to deconstruct entity that lacks a paired item

Posted: Thu Jan 18, 2018 7:47 pm
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?

Re: Unable to deconstruct entity that lacks a paired item

Posted: Sun Oct 04, 2020 7:14 pm
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?

Re: Unable to deconstruct entity that lacks a paired item

Posted: Sun Oct 04, 2020 8:20 pm
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?