[Lua][feature] event for circuit network modification

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Asynchron
Inserter
Inserter
Posts: 24
Joined: Fri Dec 02, 2022 9:10 pm
Contact:

[Lua][feature] event for circuit network modification

Post by Asynchron »

Hi team, and everyone,

So I've been working on a pet mod for myself, which tries to employ circuit networks to do discovery of entities that should interact between themselves. The problem here is: there is no event that can notify my mod if a circuit network has changed, where by change I mean addition/removal/swap of an entity in the network.

At current moment I'm forced to do polls over all circuits I'm using for discovering if it was modified or not. This involves quite a lot of checkups, O(n^2) of operations since I need to check if new set of entities is same as old set that is kept in mod memory.

I think this would be a beneficial addition since this will eliminate any heavy comparisons being done in mod itself, as well as removing any delay between circuit modification and actual detection of said change.

There could be a new event similar to (pseudo syntax: name(params)):

Code: Select all

on_network_circuit_changed(circuit_network_id: number, added: entity[], removed: entity[])
P.S. This also can benefit other existing mods like LTN, or crafting combinator, improving their speed.

Best regards,
Alexandru.
User avatar
Gergely
Filter Inserter
Filter Inserter
Posts: 659
Joined: Sun Apr 10, 2016 8:31 pm
Contact:

Re: [Lua][feature] event for circuit network modification

Post by Gergely »

+1

I think we need wire connected and wire disconnected events. My use case could benefit from being able to detect when the connections of an entity change in order to update things.
User avatar
protocol_1903
Filter Inserter
Filter Inserter
Posts: 520
Joined: Fri Sep 09, 2022 4:33 pm
Contact:

Re: [Lua][feature] event for circuit network modification

Post by protocol_1903 »

I currently supply these custom events using PEREL. It is not currently updated for 2.1, but should suit your needs perfectly.
pY and pYblock developer, wielder of fluid networks and subtick events in arbitrary ways. I make mods. Check them out, maybe.
https://mods.factorio.com/user/protocol_1903

Buy me a coffee
Post Reply

Return to “Modding interface requests”