Player placed ghost vs blueprint ghost.

Place to get help with not working mods / modding interface.
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Player placed ghost vs blueprint ghost.

Post by bobingabout »

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)
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Player placed ghost vs blueprint ghost.

Post by Nexela »

You could check the players cursor stack and see if they are holding a blueprint.
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Player placed ghost vs blueprint ghost.

Post by bobingabout »

Good idea. This line seems to work as a check.

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")))
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"
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
Post Reply

Return to “Modding help”