Page 1 of 1

on_player_used_wire

Posted: Wed Jun 23, 2021 9:36 am
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.

Re: on_player_used_wire

Posted: Wed Jun 23, 2021 9:46 am
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.

Re: on_player_used_wire

Posted: Wed Jun 23, 2021 12:04 pm
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.

Re: on_player_used_wire

Posted: Wed Jun 23, 2021 1:43 pm
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.

Re: on_player_used_wire

Posted: Wed Jun 23, 2021 9:12 pm
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.

Re: on_player_used_wire

Posted: Thu Jun 24, 2021 2:27 pm
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...