Get key name from system scancode in a mod?

Post Reply
User avatar
Linuxdirk
Member
Posts: 3416
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Get key name from system scancode in a mod?

by Linuxdirk » Post

In a mod I’m developing I want to add a little help text for the everyday player that contains some information about what keys to be pressed for certain actions.

While I can easily get the system scancodes by just requesting the corresponding setting like so …

Code: Select all

local dig_scancode = core.settings:get('keymap_dig')
local fast_scancode = core.settings:get('keymap_fastmove')
local fly_scancode = core.settings:get('keymap_freemove')

-- Do something, link print-dumping them
print(dump(dig_scancode)) -- result: "KEY_LBUTTON"
print(dump(fast_scancode)) -- result: "SYSTEM_SCANCODE_224"
print(dump(fly_scancode)) -- result: "SYSTEM_SCANCODE_14"
… there seems to be no function in the API (searched the markdown file for scancode) for getting the actual key name.

But Luanti already has a function for getting the key name (even localized) fromt he scancode, it does so in the key configuration.

s.png
s.png (17.9 KiB) Viewed 112 times
here, in German

So, the information is already known to the client, I just need a way to display that information somewhere (GUI, formspec, tooltip, chat, etc.)

I wonder if I somehow can use this function in a mod, or if there are other methods achieving the same result (localized key name from scancode like in the settings).

Any Idea or help would be appreciated!

User avatar
rubenwardy
Moderator
Posts: 7104
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: London, United Kingdom
Contact:

Re: Get key name from system scancode in a mod?

by rubenwardy » Post

This is not currently supported by Luanti. The issue is https://github.com/luanti-org/luanti/issues/14788
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
Linuxdirk
Member
Posts: 3416
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: Get key name from system scancode in a mod?

by Linuxdirk » Post

Thanks for linking me that issue, that’s sad :(

Maybe not back in 2024 – but now that users can remap anything to anything such an API call would really be helpful.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests