Wire Shortcuts X


Adds a shortcut (Alt-W) for giving free wires, repeat presses cycle between wire types. Adds nicer looking wire shortcuts than vanilla.

Utilities
12 days ago
1.1 - 2.0
6.09K
Circuit network

i [Completed] Adjust shortcut settings

1 year, 10 months ago
(updated 1 year, 10 months ago)

I saw in the changelog that you added support for extra shortcuts using ALT+F, ALT+G, but I didin't see the controls for it in the game. I inspected the game files and discovered that there is a config option for the number of available shortcuts, and only then will the shortcuts in config appear.

I think that you should make the following changes, because right now I got a bit confused:
- remove the "number of shortcuts" setting - because all shortcuts should be present out of the box. If someone doesn't want them, he can omit assigning keys. If you want the default to be one shortcut only you should leave the default ALT+C, ALT+F, ALT+G bindings empty instead, but shortcuts enabled nonetheless
- Move settings to "Per Player" tab (currently the "number of shortcuts" is in "Startup" tab which is confusing
- Add a settings entry called "Wire order" instead which accepts a string of up to 3 characters from the set [RGC] representing red, green, copper. Then use that setting to determine the cycle order. (You can instead directly add some kind of "list of item names" if it's possible by the API, but I don't know if settings support such a thing).

Btw I saw you have an array storing entries of a form current_wire -> next_wire. You can use a circular buffer instead (pseudocode below, reassembles javascript more than lua):

symbolsToNames = {R=red-wire-item-name, G=green-wire-item-name, C=copper-wire-item-name};
orderedItemNames = settings[wireCycleOrderString].mapChars(c -> symbolsToNames[c]);
currentWire = 0;

onAltWPressed() {
   if (not holding) giveItem(orderedItemNames[currentWire]);
   else currentWire = (currentWire + 1) % orderedItemNames.arrayLength();
}

You can change it to build an array of 3 wires and remembering current index like [red, green, copper] that would be parsed from the RGC string.

1 year, 10 months ago

It is possible that the way I've done it is completely over engineered and unnecessary. However, let me explain my thinking first... :)

Priority number 1: the mod should be instantly understandable, clear, and easy-to-use without any configuration required.
With the current default setting (number of shortcuts = 2) I think this is well achieved. There are only 2 things in the shortcut list that the player can choose to add to their shortcut bar (one button for red/green wires, with a half-red-half-green icon, and one button for copper cable). The tooltip for the combined shortcut button states "Give/cycle wires" which (hopefully) easily demonstrates how to get both colours of wires.

Now, if I remove the setting and instead add all shortcuts straight away then we have a problem: there would actually have to be 5 shortcuts (to maintain the current level of options): one each for red, green, copper, one for combined red+green, and one for combined red+green+copper. This is way too confusing to pick from, and just ends up cluttering the whole list.

If instead of removing the setting I move it to per-player: we could get away with only 3 shortcuts, but if you wanted the functionality of a combined button (red+green or red+green+copper), then you wouldn't get the nice combined icon, because the icons can only be set at game startup.

It isn't ideal that players can't set their own options (because it is startup rather than per-player), but I do think that the current defaults are fine for almost everyone anyway (especially now that the default has copper cable separated from the other two).

Better to think of the "Number of shortcuts" setting as three different 'modes of operation' rather than just a choice of 'how many' of something. And since these different modes require different prototypes and icons, it sadly has to be in the "Startup" tab.

"Wire order" setting: theoretically possible but when there's only 3 items (and 2 by default) in the cycle, I really don't see the point. Plus I'm really not a fan of string settings like that.

The main change that I would be willing to make if you think it would be useful is: currently the keybind for copper cable (Alt+C) is removed in "One" mode and the keybinds for red/green wires (Alt+F/Alt+G) are removed in "One" and "Two" modes. I could definitely make these all available in all modes (even though they wouldn't necessarily have a shortcut button associated with them). Cluttering the "Controls" setting page isn't such a worry.

Let me know your thoughts :)


PS Your circular buffer is similar to how I manage the module cycle in Module Inserter Simplified, which has a much larger cycle that changes dynamically based on mods added and configuration chosen. But I think it is way overkill for this :) (plus indexing/modulo like that is a bit more of a pain in 1-indexed Lua).

1 year, 10 months ago
(updated 1 year, 10 months ago)

Thank for a detailed answer :)
Firstly, here are some of my experiences so far:
- I only ever used shortcuts for this mod, never used the icons. I also have a lot of mods that already clutter the "shortcuts" tab, and I have already picked my set of most useful shortcuts, so neither have I noticed that shortcut icons are there nor that they are different.
- I have been searching for a way to enable separate keybinds for red,green,copper, but they were not present so it was confusing. I had to all settings tabs to see if this mod added something and there it was. Then I had to restart the game for a change to apply. This is in my opinion very questionable
- For the vast majority of time I use red/green wire. Copper wire is used super rarely.
- I have a muscle memory if I know what I want to do: for primary, ALT+F, secondary ALT+G, copper, ALT+C. I tried using ALT+W, but the situation when it equipped the wire I not intended were present maybe 1/3 of a time.

Based on what you wrote above, it seems that the only need for the "number of shortcuts" in the startup file is to assign a proper icon to the shortcut and assign a proper prototype. I think you can avoid it. I think you don't have to keep different prototypes if you write a single function that just picks wire depending on the cycle setting.

Instead of "number of shortcuts" I think it would be more useful to provide a smart wire behavior for ALT+W select, which has three modes of operation:
- don't cycle: only recalls last item.
- cycle red-green: would cycle only red-green wires
- cycle red-green-copper: would cycle all

Another thing is that the current "one shortcut" and "three shortcuts" has the same behavior for ALT+W. That essentially means, that this settings majority of the job is hiding keybind settings from settings tab.

I wonder how useful is the ALT+W shortcut anyway. For now I didn't yet have a situation, when I would want to cycle between all three red-green-copper. If I ever do any kind of wire action, I already know what kind of wire I want, and I'm always one known shortcut away from what I intend to do. IMO pressing ALT+W has only the benefit of being easier to press on keyboard than ALT+F, because it is closer.

I understand that you like it that you have a separate icon for every kind of shortcut mode, however in your place I would question their usefulness. For starters, consider replacing them with 4 fixed icons: one for red wire, one for green wire, one for copper and one for the "smart wire" that swaps the colors accordingly. Here is why:
- I've never used buttons to give me wires if I already have wire shortcuts.
- Almost all other icons and icons from other mods have a shortcut style that uses an icon of some kind.
- Incidentally Red/Green/Copper are unfortunately colors that people with red/green daltonism have hard time differentiating.
- The details are lost for the current icons.
- player already knows what kind of wires are cycled through. There is no need, in my opinion, to remind him every time about it.

If you want to keep the shortcuts, I would consider changing their icon to stylistically fit the rest of the icons - one color, only a symbol. This way you would have a red, green, copper symbol and a black symbol for swapping colors.

Another thing is — do you even need a shortcut on a shortcut bar for the swap wires? How often do you click that button? How often do you click any of the buttons? From personal experience I can tell, that I came here from the Wire Shortcuts mod, where I already had ALT+F, ALT+G, ALT+C shortcuts, so I've never yet used the buttons and swap wire yet. I tried, but it often equipped to cursor the wire type that was not the one I wanted. The current ALT+W behavior reassembles pressing a shortcut to focus and scroll a quickbar, instead of simply providing a shortcut for each item in the quickbar.

For now I see the following uses for the icon buttons:
- the shortcut bar is too cluttered and someone doesn't want keybinds (but why would he?) - only one shortcut to give a wire would be good
- someone is playing on a device that doesn't have keyboard or cannot bind keys to shortcuts

To be a bit clearer about the last point about not needing the shortcut button: I mean, there is an <kbd>R</kbd> shortcut to rotate an entity, but there is no shortcut button for it. I think ALT+W should be treated the same, because if it's meant to "swap wires quickly" then no one is gonna click this button with a mouse, but use a keyboard instead.


PS: I think (i-1) % #bufferLen + 1 is not that much of a pain in the ass ;P

1 year, 10 months ago
(updated 1 year, 10 months ago)

Ok, I think I am understanding your point of view better now - you are focussed on the keybinds whereas I'm primarily focused on the shortcut buttons, and for me the keybinds are secondary.

Reason being: most people (non-power users), including me, don't use these wires very often, and won't memorise the keybinds for the shortcuts. So they need to have the buttons there for when they need them. This means that having less buttons (taking up less space) is good, and also means that if/when they do come to use keybinds, there are less keybinds to memorise. And even when starting to use the keybinds, having the buttons right there that you can hover over and remind yourself of the keybind is very useful. This follows the same principle as the vanilla undo, decon planner, upgrade planner, etc. They aren't used commonly enough by many people, so not everyone will have memorised the keybinds, and the best way to learn the keybinds is from the button tooltips. And the discoverability bonus is useful too (particularly in multiplayer, when most players didn't consciously add the mod themselves).

Worth noting that Alt+W is less about 'swapping wires quickly' (although that is a use) and more about 'press it to get a wire, if it isn't the one you want, simply press it again'.

Now I don't want to completely discard the power users like yourself. And since you said that you don't use the buttons at all, it seems to me that the clear solution is just to have all 4 keybinds available for use at any time, no matter what mode you are in. And if you are using these 3 separate keybinds, then I doubt you'll be also using the Alt+W combined keybind so I still don't see the point of a setting to make it configurable.

Shortcut icons: yes I would like to experiment with using the icons from Wire Shortcuts (probably as an option), I just need to do a bit of graphics work to get the combined icons in the same style.

1 year, 10 months ago

v1.2.2 now has all 4 keybinds enabled at all times.

New response