Jump to content

Keys customisation shortcut ?


YouGroove
 Share

Recommended Posts

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

Stop toying and make games

Link to comment
Share on other sites

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

 

 

It doesn´t work... why? mhmmm It works... why?

Link to comment
Share on other sites

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

  • Upvote 1
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...