Wiring Pencil

This is the place to request new mods or give ideas about what could be done.
Post Reply
tehfreek
Filter Inserter
Filter Inserter
Posts: 391
Joined: Thu Mar 17, 2016 7:34 am
Contact:

Wiring Pencil

Post by tehfreek »

Since power wires are essentially free with power poles and blueprints make circuit network wires almost completely free, it makes sense to me to have a reusable, all-in-one tool that can apply wires of any type. Enter the wiring pencil. It is a tool with a one-time-cost that can apply or break power, red, or green wire in exactly the same way that those actions are currently performed. A hotkey switches between the wire used.

I can give a stab at writing this myself if I get some hints on how to implement it, but I can't help but feel that someone that already has modding experience would get it done much faster.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7351
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Wiring Pencil

Post by bobingabout »

I am unsure if it is possible with 0.16, because I think it's pretty hard wired to cost an item to make a wire.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

tehfreek
Filter Inserter
Filter Inserter
Posts: 391
Joined: Thu Mar 17, 2016 7:34 am
Contact:

Re: Wiring Pencil

Post by tehfreek »

I don't know, after a quick flip through at the Lua API it looks like you could use LuaEntity::{,dis}connect_neighbour() to implement this.

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

Re: Wiring Pencil

Post by eradicator »

bobingabout wrote:I am unsure if it is possible with 0.16, because I think it's pretty hard wired to cost an item to make a wire.
Wire cost can be changed in 0.17 (thread).

But you can't make a wiring "pencil" because the half-connected wire-to-cursor preview is hardcoded to the actual wire types. But there's nothing preventing you from making a hotkey that changes the "color" of a wire-stack on your cursor and replenishing the stack when some of it is used up (on_cursor_stack_changed).

Hm..looking at the base lua files. Are the wire names hardcoded? I can't find any reference on the "green-wire" item that defines it as an item to make green wires (Bob, can you confirm?). In that case you'd have to live with the fact that players can convert copper-wire to green-wire for free with the hotkey if they want to build combinators with them.
tehfreek wrote:I can give a stab at writing this myself if I get some hints on how to implement it, but I can't help but feel that someone that already has modding experience would get it done much faster.
If you learn modding you contribute to the communities overall coding speed :p.
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.

tehfreek
Filter Inserter
Filter Inserter
Posts: 391
Joined: Thu Mar 17, 2016 7:34 am
Contact:

Re: Wiring Pencil

Post by tehfreek »

Looking deeper it does seem that there is in fact no way to perform the appropriate interactions in Lua, e.g. see which end of a combinator was clicked, or to tell if the wire is too far to connect.

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

Re: Wiring Pencil

Post by eradicator »

tehfreek wrote:[...] see which end of a combinator was clicked, or to tell if the wire is too far to connect.
If you use the wire as is you don't need that info. If you wanted to implement your own logic you have to intercept the click anyway and thus know what was clicked, and the distance is LuaEntityPrototype.max_circuit_wire_distance.
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.

tehfreek
Filter Inserter
Filter Inserter
Posts: 391
Joined: Thu Mar 17, 2016 7:34 am
Contact:

Re: Wiring Pencil

Post by tehfreek »

Okay, the items (along with custom eye-bleeding sprites), recipe, technology, and wire rotation parts are done. But that was the easy part. Now I just need to figure out how to emulate or delegate the actual wiring operations.

I can try a bit of wire switcheroo and invoking the appropriate event(s), but 1) I'm worried about what will happen if I switch back to the pencil in the middle of a wiring operation (for visual purposes), and 2) I have absolutely no idea what events are invoked.

tehfreek
Filter Inserter
Filter Inserter
Posts: 391
Joined: Thu Mar 17, 2016 7:34 am
Contact:

Re: Wiring Pencil

Post by tehfreek »

And of course wiring operations generate no events. Probably just as you were trying to get though my skull. Time for more thought, and possibly a dev request or two.

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

Re: Wiring Pencil

Post by eradicator »

tehfreek wrote:
Thu Sep 13, 2018 10:48 am
And of course wiring operations generate no events. Probably just as you were trying to get though my skull. Time for more thought, and possibly a dev request or two.
on_wire_changed is implemented in 0.17 as far as i remember (and i don't even know why you would need that, as described above), but it's not going to solve your problem. You still have no way to get the entity-to-cursor wire effect.
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 “Ideas and Requests For Mods”