I wrote a script to do something when a player places a ghost entity.
The problem is that it's also catching when a player places a blueprint.
Is there any way to tell the difference between a ghost entity placed by the player, and by a player placed blueprint?
(Both seem to trigger the script.on_event(defines.events.on_built_entity) event)
Player placed ghost vs blueprint ghost.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: Player placed ghost vs blueprint ghost.
You could check the players cursor stack and see if they are holding a blueprint.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: Player placed ghost vs blueprint ghost.
Good idea. This line seems to work as a check.
Loosely translated, it says "If the player places a ghost of an inserter, and doesn't have a blueprint, or blueprint book in his hand"
Code: Select all
or (entity.type == "entity-ghost" and entity.ghost_type == "inserter" and not (player.cursor_stack and (player.cursor_stack.type == "blueprint" or player.cursor_stack.type == "blueprint-book")))