I would like to request an event:
on_player_placed_wire
contains:
player :: the player that placed the wire
wire :: the type of wire placed
end_point_1 :: one of the entities connected by the wire
end_point_2 :: the other entity connected by the wire
circuit_network :: the circuit network this wire connects to (not sure if this is even a thing that is recorded, just putting it here for completeness sake)
I intend to use this to make it so that whenever a wire is placed, I get a new wire of the same type for free put into my hand, effectively making wires free beyond the initial crafting cost, I also intend to increase the crafting cost as some self-imposed balance. I'm just fixing the fact that I am annnoyed by the fact that simply experimenting with circuit networks deletes resources from the world and that I can run out of wire while experimenting, forcing me to go get more. tiny amounts, sure, but enough to trigger mini-OCD.
I would only really need the event itself, the player that placed it and to know what type of wire it is, the endpoint/circuit network data just seems like highly related information that others might be interested in using.
I cannot do this with the currently available tools as literally the only event that triggers when placing wires is on_player_cursor_stack_changed, however, it is as far as I can tell impossible to distinguish between:
1. losing an item from your cursor stack because you used it to connect 2 entities with a wire.
2. losing an item from your cursor stack because you put 1 wire into a chest.
both of these actions will only trigger exactly 1 event (on_player_cursor_stack_changed) and your cursor changes the same way for both actions (stack amount -1), therefore rendering these actions indistinguishable.
arguably, it might also be sensible to have the event:
on_player_put_item_in_chest
contains:
player :: the player that put the item in the chest
item :: the item put in the chest
chest :: the chest the item was put into
I don't need it, but someone else might.
on_player_placed_wire / on_player_put_item_in_chest
Re: on_player_placed_wire / on_player_put_item_in_chest
on_player_put_item_in_chest isn't going to happen. Not even the game knows where the item went after it did entity.insert(...).
An event for a player connecting wires isn't out of the question but for your specific use case I think a different solution would be better. Something like a property that defines how many wires are needed to connect 2 entities and if wanted a mod could set it to 0 so it doesn't consume anything.
An event for a player connecting wires isn't out of the question but for your specific use case I think a different solution would be better. Something like a property that defines how many wires are needed to connect 2 entities and if wanted a mod could set it to 0 so it doesn't consume anything.
If you want to get ahold of me I'm almost always on Discord.
Re: on_player_placed_wire / on_player_put_item_in_chest
Fair enough, that does seem a lot easier to manipulate for my purposes, what are the odds that something like wires_to_connect will be implemented?
Re: on_player_placed_wire / on_player_put_item_in_chest
I already implemented it for 0.17.Roblin wrote:Fair enough, that does seem a lot easier to manipulate for my purposes, what are the odds that something like wires_to_connect will be implemented?
If you want to get ahold of me I'm almost always on Discord.
Re: on_player_placed_wire / on_player_put_item_in_chest
Miniloader implements a mechanism through existing events to fire on_wire_added and on_wire_removed events. As Rseding has noted, it's not perfect, but it should handle the usual scenario you're talking about of a player placing and removing wires by hand.
https://github.com/mspielberg/factorio- ... placed.lua
As a suggestion, would it make more sense to restore a wire to the player's inventory when a wire is removed? That would make wires reusable, but not completely free.
https://github.com/mspielberg/factorio- ... placed.lua
As a suggestion, would it make more sense to restore a wire to the player's inventory when a wire is removed? That would make wires reusable, but not completely free.
Miniloader — UPS-friendly 1x1 loaders
Bulk Rail Loaders — Rapid train loading and unloading
Beltlayer & Pipelayer — Route items and fluids freely underground
Bulk Rail Loaders — Rapid train loading and unloading
Beltlayer & Pipelayer — Route items and fluids freely underground