Read if controls have keys bound to them in locale or in general

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
User avatar
Osmo
Filter Inserter
Filter Inserter
Posts: 330
Joined: Wed Oct 23, 2024 12:08 pm
Contact:

Read if controls have keys bound to them in locale or in general

Post by Osmo »

Some UI elements in base game have tooltips like this:
изображение.png
изображение.png (39.92 KiB) Viewed 542 times
If i unbind the control from the settings, it is displayed like this:
изображение.png
изображение.png (36.55 KiB) Viewed 542 times
I have a similar UI, but as far as i know, there is no way to read the state of keybinds, so the only option is to always show them via rich text, which looks like this:
изображение.png
изображение.png (14.68 KiB) Viewed 542 times
This adds unnecessary clutter on every button. In a tooltip, its kind of not too ugly, but that's already a compromise, ideally it'd be displayed alongside the button text, but that'd look bad if most of them are not set.

While there are some usecases to just being able to read currently bound keys, if this worked similar to locale pluralization (which only works on numbers currently) that'd also be enough for my usecase
User avatar
protocol_1903
Filter Inserter
Filter Inserter
Posts: 531
Joined: Fri Sep 09, 2022 4:33 pm
Contact:

Re: Read if controls have keys bound to them in locale or in general

Post by protocol_1903 »

+1
pY and pYblock developer, wielder of fluid networks and subtick events in arbitrary ways. I make mods. Check them out, maybe.
https://mods.factorio.com/user/protocol_1903

Buy me a coffee
User avatar
Osmo
Filter Inserter
Filter Inserter
Posts: 330
Joined: Wed Oct 23, 2024 12:08 pm
Contact:

Re: Read if controls have keys bound to them in locale or in general

Post by Osmo »

This looks even worse in 2.1
изображение.png
изображение.png (53.48 KiB) Viewed 167 times
User avatar
Shemp
Long Handed Inserter
Long Handed Inserter
Posts: 65
Joined: Mon Jan 19, 2026 6:51 pm
Contact:

Re: Read if controls have keys bound to them in locale or in general

Post by Shemp »

+1, although I imagine being able to read controls directly in Lua would lead to de-syncs, so if you wanted to go down that path it would be a request_translation type of situation.

I wonder how you would implement this. It is useful to show "Not set" in some contexts.

Perhaps a __CONTROL_SET__name__ LocalisedString parameter, which acts similarly to CONTROL, but fails to resolve if the named CustomInput isn't assigned. So you could write:

in locale.cfg

Code: Select all

toggle-tooltip-with-control=Toggle entity (__CONTROL_SET__toggle-entity__)
toggle-tooltip=Toggle entity
in control.lua

Code: Select all

tooltip = {"?", {"toggle-tooltip-with-control"}, {"toggle-tooltip"}}
(There is also the issue of controls in mod tooltips not changing when the player changes the binding, but I assume that's a deliberate compromise.)
Post Reply

Return to “Modding interface requests”