Page 1 of 1

0.16.51 creating a ghost with mod causes an appcrash

Posted: Tue Jul 17, 2018 2:21 pm
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)

Re: 0.16.51 creating a ghost with mod causes an appcrash

Posted: Tue Jul 17, 2018 2:39 pm
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?

Re: 0.16.51 creating a ghost with mod causes an appcrash

Posted: Tue Jul 17, 2018 2:43 pm
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!

Re: 0.16.51 creating a ghost with mod causes an appcrash

Posted: Tue Jul 17, 2018 4:40 pm
by eradicator
Simply skip processing things that are already ghosts:

Code: Select all

if event.created_entity.type == 'entity-ghost' then return end

Re: 0.16.51 creating a ghost with mod causes an appcrash

Posted: Tue Jul 31, 2018 3:49 am
by Rseding91
Thanks for the report. It's now fixed for 0.17.