Item Request Proxy Events
This mod adds events whenever an item-request-proxy entity is created or removed (either fulfilled or cancelled). It is also possible to register item-request-proxy entities to fire events whenever they are updated (e.g. partially fulfilled or cancelled).
Subscribe to Creation Events
Covers creation of all item-request-proxy entities:
script.on_event("item-request-proxy-created", function(event)
-- Logic to run upon item-request-proxy creation
end)
Subscribe to Destruction Events
Covers both fulfillment and cancellation of all item-request-proxy entities,
script.on_event("item-request-proxy-removed", function(event)
-- Logic to run upon item-request-proxy removal
end)
Subscribe to Update Events
Note: This does have a small UPS cost.
First, register specific item-request-proxy entities to fire events when updated:
script.on_event("item-request-proxy-created", function(event)
if matches_some_criteria(event) then
remote.call("item-request-proxy-events", "register_item_request_proxy_updated", event.unit_number)
end
end)
Then, subscribe to the update events:
script.on_event("item-request-proxy-updated", function(event)
-- Logic to run upon item-request-proxy update
end)
More Information
EventData
The event data for all three event types is the same:
tick:intThe game tick when theitem-request-proxyentity was created/removed/updated.name:stringThe name of the event.unit_number:intTheLuaEntity.unit_numberof theitem-request-proxyentity; mostly useful for deduplication and callingregister_item_request_proxy_updated.proxy_target:LuaEntityThe entity that theitem-request-proxyis targeting; after being removed, when theitem-request-proxyentity itself is no longer valid, theproxy_targetwill still be valid. If theproxy_targetentity was also removed, this wil benil.
Adding to an Existing Save
When a save is loaded after this mod has been added to it, the mod will fire "catch-up" events for all existing item-request-proxy entities.
Issues
This is a new mod, and should still be considered experimental. So far it has only been tested with Rigor Module. Use at your own risk.