Detect placement of blueprint

Place to get help with not working mods / modding interface.
Post Reply
PFQNiet
Filter Inserter
Filter Inserter
Posts: 289
Joined: Sat Sep 05, 2020 7:48 pm
Contact:

Detect placement of blueprint

Post by PFQNiet »

What is the proper way to respond to a blueprint being placed? I would like to have a table of ghosts to do stuff with.

Would this be done as just a large number of entity creation events where the entity is a ghost? If so, how would I tell the difference between an item holding a single entity, or shift-clicking to place a ghost?

What about copy-paste? Is this just a temporary blueprint that can be handled in the same way?

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Detect placement of blueprint

Post by DaveMcW »

PFQNiet wrote:
Thu Mar 25, 2021 1:37 am
Would this be done as just a large number of entity creation events where the entity is a ghost?
Yes. If you need all ghosts in one table, you can collect them in on_built_entity, store them in a table, and process/delete the table in on_tick.
PFQNiet wrote:
Thu Mar 25, 2021 1:37 am
If so, how would I tell the difference between an item holding a single entity, or shift-clicking to place a ghost?
Check player.cursor_stack to see what they used.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Detect placement of blueprint

Post by eradicator »

DaveMcW wrote:
Thu Mar 25, 2021 4:53 am
PFQNiet wrote:
Thu Mar 25, 2021 1:37 am
Would this be done as just a large number of entity creation events where the entity is a ghost?
Yes. If you need all ghosts in one table, you can collect them in on_built_entity, store them in a table, and process/delete the table in on_tick.
You should keep seperate tables for each player in case several players build simultaneously.
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.

Post Reply

Return to “Modding help”