Item Request Proxy Events


Utility mod for item-request-proxy events.

Internal
19 hours ago
2.0
555
Owner:
thremtopod
Source:
https://gitlab.com/jfletcher94/factorio-mods
Homepage:
N/A
License:
GNU LGPLv3
Created:
5 days ago
Latest Version:
0.1.2 (19 hours ago)
Factorio version:
2.0
Downloaded by:
555 users

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: int The game tick when the item-request-proxy entity was created/removed/updated.
  • name: string The name of the event.
  • unit_number: int The LuaEntity.unit_number of the item-request-proxy entity; mostly useful for deduplication and calling register_item_request_proxy_updated.
  • proxy_target: LuaEntity The entity that the item-request-proxy is targeting; after being removed, when the item-request-proxy entity itself is no longer valid, the proxy_target will still be valid. If the proxy_target entity was also removed, this wil be nil.

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.