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)
0.16.51 creating a ghost with mod causes an appcrash
-
- Burner Inserter
- Posts: 14
- Joined: Sun Oct 15, 2017 6:15 pm
- Contact:
0.16.51 creating a ghost with mod causes an appcrash
- Attachments
-
- factorio-dump-previous.dmp
- dump file
- (633.26 KiB) Downloaded 202 times
-
- factorio-current.log
- log
- (3.71 KiB) Downloaded 223 times
- eradicator
- 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
Why are you trying to create a ghost inside a ghost? Ghostception?TheThunderBirds wrote:Shift clicking (creating a ghost) with this piece of code causes an appcrash.
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.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
-
- 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
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!
- eradicator
- 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
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.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: 0.16.51 creating a ghost with mod causes an appcrash
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.