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.
on_player_used_wire
Re: on_player_used_wire
Note that you can also mess with wires using blueprints, so on_player_used_wire would not solve everything.PFQNiet wrote: Wed Jun 23, 2021 9:36 amdetecting the player messing with modded entities that require certain wires to function
Re: on_player_used_wire
Fair point. Just putting a power pole too close can also "mess with" stuff, but those two cases are already catchable with existing events.
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: on_player_used_wire
+1
But I'd prefer a full a "on_wire_changed" (or added+removed pair). Same as for entities.
But I'd prefer a full a "on_wire_changed" (or added+removed pair). Same as for entities.
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.PFQNiet wrote: Wed Jun 23, 2021 12:04 pm those two cases are already catchable with existing events.
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.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: on_player_used_wire
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.
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: on_player_used_wire
Mostly for "weird" entities. Script managed, compound, invisible, etc...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?
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.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.