entity.destroy() makes new item-on-the-ground

Place to get help with not working mods / modding interface.
Post Reply
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

entity.destroy() makes new item-on-the-ground

Post by darkfrei »

Hi all!

I have a problem with my mod https://mods.factorio.com/mod/SmogSolarPanels

How it works:
If the player places solar panel, then this panel will be added to the global table.
Every tick will be checked one entity from the table. If in this position is another pollution as expected, then new entity with lower/higher power will be placed on this position.
Here is not fast_replaceable_group by solar panels and I need to destroy old solar panel. On the destroying I get new item-on-the-ground under this entity.

The bug cannot be reproduced due

Code: Select all

/c game.player.selected.destroy()

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

Re: entity.destroy() makes new item-on-the-ground

Post by Nexela »

entity.destroy() is not making a new item, fast_replace = true is

It simulates fast_replacing an entity, if there is no player associated to the create_entity event then the item from mining is spilled to the ground. so you need to add spill=false

I think this next bit applies to later versions of .16 also
Also the original entity is already destroyed when fast_replacing but you can destroy() invalid stuff without an error thanks to rseding :)

Also when items are not in the same fast_replace_group they are not fast_replacable and they won't spill an item.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: entity.destroy() makes new item-on-the-ground

Post by darkfrei »

Nexela wrote:
Sat Oct 20, 2018 1:06 am
entity.destroy() is not making a new item, fast_replace = true is

It simulates fast_replacing an entity, if there is no player associated to the create_entity event then the item from mining is spilled to the ground. so you need to add spill=false
By solar panels is no fast replacing, but with "spill=false" it works, thanks!

Post Reply

Return to “Modding help”