How to find item_request_proxy targeting an entity?
Posted: Thu Mar 28, 2019 2:53 am
I have question about item_request_proxy entities, specifically the following scenario:
1. Player creates a blueprint with locomotive containing fuel item stacks.
2. Player places the blueprint, creating locomotive ghost with item_request property.
3. Construction bot places locomotive, creating locomotive entity and item_request_proxy entity with fuel targeting that locomotive.
4. Mod detects locomotive was created and replaces it with a nearly-identical locomotive entity, copying all parameters so the player doesn't notice the difference.
5. Old item_request_proxy target is invalid, new locomotive does not get fuel. Player notices the difference.
How does Mod know if there was an item_request_proxy targeting the locomotive it replaced? How can it create a new item_request_proxy with the same contents targeting the new locomotive entity?
The revive() function returns the associated item_request_proxy, but only if the script is the one reviving it. For non-script reviving, the on_built and on_robot_built_entity events do not appear to return a reference to any item_request_proxy entities created.
Do I have to search the entire list of entities, or at least item_request_proxy entities, to find out of any of them target the locomotive I am replacing? How would I do that?
Thanks in advance for your help.
1. Player creates a blueprint with locomotive containing fuel item stacks.
2. Player places the blueprint, creating locomotive ghost with item_request property.
3. Construction bot places locomotive, creating locomotive entity and item_request_proxy entity with fuel targeting that locomotive.
4. Mod detects locomotive was created and replaces it with a nearly-identical locomotive entity, copying all parameters so the player doesn't notice the difference.
5. Old item_request_proxy target is invalid, new locomotive does not get fuel. Player notices the difference.
How does Mod know if there was an item_request_proxy targeting the locomotive it replaced? How can it create a new item_request_proxy with the same contents targeting the new locomotive entity?
The revive() function returns the associated item_request_proxy, but only if the script is the one reviving it. For non-script reviving, the on_built and on_robot_built_entity events do not appear to return a reference to any item_request_proxy entities created.
Do I have to search the entire list of entities, or at least item_request_proxy entities, to find out of any of them target the locomotive I am replacing? How would I do that?
Thanks in advance for your help.