ul_708 Posted May 19, 2024 Share Posted May 19, 2024 (edited) See the mod's github at https://github.com/rtk0c/dont-starve-mods/tree/master/KeybindLib for documentation. There is also an example mod in the same repo, https://github.com/rtk0c/dont-starve-mods/tree/master/ClientTweaks -- specifically see its modmain.lua. I won't copy contents of the README.md here just so that I don't have to maintain the same information in two places. ———————————————————————————————— Hello! I made a new library mod for keybinds. When you register a keybind, this automatically happens: An entry in the Options > Mod Keybinds screenis added for easy remapping for the player. Remap just like vanilla's Controls screen: click on the entry, press a key sequence, click Apply. And it's immediately usable in game. The callback you supply when registering is called when the player presses the configured key sequence. In any context--even in the main menu, for example, if your mod is loaded (again see README.md, caveats section). Also published on Steam Workshop: https://steamcommunity.com/sharedfiles/filedetails/?id=3250212696 If you have any questions feel free to ask here or in Github Issues, and I'll try to amend my documentation so others won't be confused. If you have any suggestions, that is welcomed too. Why I did this: I got extremely fed with the status quo of keybind/hotkey/control/whatever-you-call-it handling in mods today. You put a configuration option in your mod, which is only changeable on the main menu and requires a reset (so takes a long time to do in middle of a game). Not only that, you need to choose the less of two evils: either list very few options (like Geometric Placement or Action Queue, only letter keys) which severely limits players' options; or list a lot of options (like Auto Cook which has nearly 100 choices for every key in constants.lua) and it takes forever to get to the key you want, especially if you clicked the spinner in the wrong direction. P.S. If anybody has a suggestion for a mod icon and/or the preview image on steam, please let me know. I'm not good at selecting these kind of things (not to mention drawing them myself). Edited May 19, 2024 by ul_708 add image 1 1 1 1 Link to comment https://forums.kleientertainment.com/forums/topic/156221-api-keybindlib-configure-keybinds-just-like-vanillas-options-controls-menu/ Share on other sites More sharing options...
liolok Posted July 7, 2024 Share Posted July 7, 2024 (edited) Awesome Lib! Changing keybinds in game, no restart! How could I sync mod configuration with this? Or must I choose between two methods? Edited July 7, 2024 by liolok Link to comment https://forums.kleientertainment.com/forums/topic/156221-api-keybindlib-configure-keybinds-just-like-vanillas-options-controls-menu/#findComment-1733407 Share on other sites More sharing options...
ul_708 Posted July 10, 2024 Author Share Posted July 10, 2024 On 7/7/2024 at 2:07 PM, liolok said: Awesome Lib! Changing keybinds in game, no restart! How could I sync mod configuration with this? Or must I choose between two methods? If I understand you correctly, you want to store the keybind in mod_configuration rather than KeybindLib's storage system. Currently this isn't possible, but I can add a way to do it. It would probably be a getter and a setter you pass into KeybindLib:Register(), which, if detected, would make the configuration screen read/write from that instead of using the internal storage. If that sounds fine I can make such a change. Note that this has the implication that you'll have to use your own triggering mechanism (perhaps a call to AddKeyDownHandler just like how mods do it usually). KyebindLib's triggering mechanism uses an internal lookup table, and if the storage is external, it's hard to keep that LUT in sync. (One solution would be to add a notification channel from mods into KeybindLib; I feel like this would have implications, such as, being able to reliably detect changes to mod_configuration, but I haven't thought it through yet). Anyways, thank you for using this library! 1 Link to comment https://forums.kleientertainment.com/forums/topic/156221-api-keybindlib-configure-keybinds-just-like-vanillas-options-controls-menu/#findComment-1734198 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now