I am making a mod where I do something with ghost. I noticed that it is possible to stack ghosts on top of eachother using LuaSurface::create_entity in on_built_item(possibly in the other events too). This is a bug in my mod ofcourse but I also think it is a bug in the placing of a ghost. Two(or as in the picture 5 or 6 or more) equal ghosts on top of each other does not seem like a viable thing to me.
What I did
Removing the created entity using event.created_entity.destroy()
Recreating a previous ghost using game.players[event.player_index].sursurface.create_entity(entityToCreate)
What I expect
The old ghost being destroyed by the created_entity (this is where I have a bug in my mod)
A new copy of the old ghost being placed.
What did I get
A new copy on top of the old ghost
A brighter ghost.
[0.16.7 Stacking ghosts with LuaSurface::create_entity
[0.16.7 Stacking ghosts with LuaSurface::create_entity
- Attachments
-
- 20171221223343_1.jpg (841.95 KiB) Viewed 1013 times
Re: [0.16.7 Stacking ghosts with LuaSurface::create_entity
Thanks for the report. If you don't want the ghosts to stack you need to use LuaSurface::can_place_entity to check if the entity is valid to be placed at that location normally.
Scripts are allowed to stack entities on top of each other provided it won't corrupt the game which is what you're seeing.
Scripts are allowed to stack entities on top of each other provided it won't corrupt the game which is what you're seeing.
If you want to get ahold of me I'm almost always on Discord.