on_player_used_wire

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
PFQNiet
Filter Inserter
Filter Inserter
Posts: 289
Joined: Sat Sep 05, 2020 7:48 pm
Contact:

on_player_used_wire

Post by PFQNiet »

Okay that might not be the best name, but I would like to have an event for when the player connects (or disconnects) two entities with wire.

Event properties:
- wire: "copper", "red", "green"
- from, to: the entity/connection points that were joined or disconnected
- disconnect: true if the action disconnected the entities, false if connecting them

This would open possibilities such as managing power grids, refunding wires to the player on disconnecting, detecting the player messing with modded entities that require certain wires to function and more.

If a player shift-clicks to remove all connections from an entity, fire one disconnect event for each removes wire.

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

Re: on_player_used_wire

Post by DaveMcW »

PFQNiet wrote:
Wed Jun 23, 2021 9:36 am
detecting the player messing with modded entities that require certain wires to function
Note that you can also mess with wires using blueprints, so on_player_used_wire would not solve everything.

PFQNiet
Filter Inserter
Filter Inserter
Posts: 289
Joined: Sat Sep 05, 2020 7:48 pm
Contact:

Re: on_player_used_wire

Post by PFQNiet »

DaveMcW wrote:
Wed Jun 23, 2021 9:46 am
PFQNiet wrote:
Wed Jun 23, 2021 9:36 am
detecting the player messing with modded entities that require certain wires to function
Note that you can also mess with wires using blueprints, so on_player_used_wire would not solve everything.
Fair point. Just putting a power pole too close can also "mess with" stuff, but those two cases are already catchable with existing events.

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

Re: on_player_used_wire

Post by eradicator »

+1
But I'd prefer a full a "on_wire_changed" (or added+removed pair). Same as for entities.
PFQNiet wrote:
Wed Jun 23, 2021 12:04 pm
those two cases are already catchable with existing events.
That's not helpful though. Everything can be cought "in some kind of event" when you're prepared to go all the way to the bottom and use linked custom inputs. But it's error prone, expensive and ultimately causes lots of reinventing-the-wheel. It would be much nicer if there was a straight-forward event to use.
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.

quyxkh
Smart Inserter
Smart Inserter
Posts: 1028
Joined: Sun May 08, 2016 9:01 am
Contact:

Re: on_player_used_wire

Post by quyxkh »

The one I keep wanting is a change counter on the circuit, it's cheap to implement and gets you basically all the way there. If you don't have any other reason to check the connections, why check the connections? If you're using a signal value you're already running, so check the circuit's change count to see if you have to rebuild any cached connections graph or whatever.

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

Re: on_player_used_wire

Post by eradicator »

quyxkh wrote:
Wed Jun 23, 2021 9:12 pm
If you don't have any other reason to check the connections, why check the connections?
Mostly for "weird" entities. Script managed, compound, invisible, etc...
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 interface requests”