YouGroove Posted March 10, 2014 Share Posted March 10, 2014 It is possible in LE3 to program key assignation by user ? I mean how to have user be able to choose key letter , as it will be a string object in script slot input, and use it in code. In example below how to use a,b,c,d key letters in Keydown function ? Make ourselves some correspondance table or function ? It is not some shortcut programming tips ? Script.left = "A" Script.right ="B" Script.up ="C" Script.down ="D" function Script:UpdatePhysics() local window = Window:GetCurrent() local moveX = 0 if window:KeyDown(Key.Q) then moveX = -1 end if window:KeyDown(Key.D) then moveX = 1 end if window:KeyDown(Key.Q) then moveX = -1 end if window:KeyDown(Key.D) then moveX = 1 end Quote Stop toying and make games Link to comment Share on other sites More sharing options...
DudeAwesome Posted March 10, 2014 Share Posted March 10, 2014 You Need a function that returns which Key was pressed. There is no function for this in the API for now so you have to Check every Key in One Loop by yourself (KeyHit()) I would do it this way: i have a file (i like xml) with the default Key configuration. You need a file here because this should be persistent. A Script reads the file and sets the command for each Key. If you want to change the configuration You Need to overwrite the configfile and read it again Quote It doesn´t work... why? mhmmm It works... why? Link to comment Share on other sites More sharing options...
Rick Posted March 13, 2014 Share Posted March 13, 2014 I'm not 100% sure about this, but if Key is a table then you should be able to access it's variables (the constants) with the string version as well since you can do that with Lua tables. I can't test yet but just an idea to test. If that works then you can replace the "D" with a variable that is the string key. if(window.KeyDown(Key["D"]) then 1 Quote Link to comment Share on other sites More sharing options...
YouGroove Posted March 13, 2014 Author Share Posted March 13, 2014 I'll try, this would allow to easy read and bind input keys with what user could had choosen in some menu options. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Rick Posted March 13, 2014 Share Posted March 13, 2014 Well, there are other ways to do this, they are just more work on your end Quote Link to comment Share on other sites More sharing options...
Einlander Posted March 14, 2014 Share Posted March 14, 2014 I just wrote a blog post about this topic: http://www.leadwerks.com/werkspace/blog/120/entry-1184-key-configs-and-tedium/ Example: http://www.leadwerks.com/werkspace/files/file/515-key-config-host/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.