Page 1 of 1
Changing key bindings
Posted: Sat Apr 16, 2016 4:16 pm
by Teshi
What would be the best way to go about allowing the player to change their keybindings?
I had the idea of using a text file and reading the bindings from that but im wondering if there are smarter ways to go about this (there probably are).
Could anyone help?
Re: Changing key bindings
Posted: Sat Apr 16, 2016 5:00 pm
by Skeletonxf
I think have all your project code detect if certain 'keys' are pressed to do things ins response but these keys are to be variables or entries in a table of keybindings where the user can change their string value to change key either via a GUI that writes/reads their preferences to a file or by manually editing the file. A GUI would certainly be much more user friendly and helpful on mobile devices. I think last time I was trying to do something similar to this I used tserial to encode/decode the file contents into a lua table so I could then read out of it to get the key-value pairs for thing that is meant to have a key binding and the key binding - except I was saving volume data instead of strings, but it's the same concept.
Re: Changing key bindings
Posted: Sun Apr 17, 2016 5:45 am
by Guard13007
In addition to what Skeletonxf said, take a look at existing keybinding libraries, such as
this one and
this. The second one is more up to date, but not as featured as the other. Note that I haven't checked if these still work in current versions of Love, which is why I'm suggesting you
reference them to design your own library...or test them and use them if they do work. Your choice.