0.16.51 creating a ghost with mod causes an appcrash

This subforum contains all the issues which we already resolved.
TheThunderBirds
Burner Inserter
Burner Inserter
Posts: 14
Joined: Sun Oct 15, 2017 6:15 pm
Contact:

0.16.51 creating a ghost with mod causes an appcrash

Post by TheThunderBirds »

Shift clicking (creating a ghost) with this piece of code causes an appcrash. It has probably something to do with creating a ghost where there is already one or trying to destroy a ghost because the normal click works without any problems.

This piece of code causes the crash:

script.on_event(defines.events.on_built_entity, function(event)
local ghost = {
name = "entity-ghost",
inner_name = event.created_entity .name,
position = event.created_entity .position,
force = event.created_entity .force
}

event.created_entity.destroy()
game.surfaces['nauvis'].create_entity(ghost)
end)
Attachments
factorio-dump-previous.dmp
dump file
(633.26 KiB) Downloaded 204 times
factorio-current.log
log
(3.71 KiB) Downloaded 223 times
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5207
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: 0.16.51 creating a ghost with mod causes an appcrash

Post by eradicator »

TheThunderBirds wrote:Shift clicking (creating a ghost) with this piece of code causes an appcrash.
Why are you trying to create a ghost inside a ghost? Ghostception?
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
TheThunderBirds
Burner Inserter
Burner Inserter
Posts: 14
Joined: Sun Oct 15, 2017 6:15 pm
Contact:

Re: 0.16.51 creating a ghost with mod causes an appcrash

Post by TheThunderBirds »

I tried to make the normal building work like shift clicking but then found out the shift clicking now crashed the game xD. If there is a cleaner way to do this please tell me!
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5207
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: 0.16.51 creating a ghost with mod causes an appcrash

Post by eradicator »

Simply skip processing things that are already ghosts:

Code: Select all

if event.created_entity.type == 'entity-ghost' then return end
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14318
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: 0.16.51 creating a ghost with mod causes an appcrash

Post by Rseding91 »

Thanks for the report. It's now fixed for 0.17.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Resolved Problems and Bugs”