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.
Wiring Pencil
- bobingabout
- Smart Inserter
- Posts: 7351
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: Wiring Pencil
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.
Re: Wiring Pencil
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.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Wiring Pencil
Wire cost can be changed in 0.17 (thread).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.
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.
If you learn modding you contribute to the communities overall coding speed :p.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.
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: Wiring Pencil
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.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Wiring Pencil
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.tehfreek wrote:[...] see which end of a combinator was clicked, or to tell if the wire is too far to connect.
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: Wiring Pencil
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.
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.
Re: Wiring Pencil
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.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Wiring Pencil
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.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Wiring Pencil
In case you haven't found it yet: https://mods.factorio.com/mod/WireShortcuts