Jump to content

Keyboard binding, save options, listen for inputs.


Ttiki
 Share

Go to solution Solved by Yue,

Recommended Posts

Hello.

I'm working on a demo for my upcoming game, and while I was working on it, I wanted to add the ability to bind keys in the options menu. I've already made the GUI code (in Lua) to make a second tab, add buttons for every movement, etc... The problem is I can't figure how to listen for keyboard/mouse input. As you can see, I've chosen buttons and not TextInput. When you click a button, a panel opens with a text. This panel will only close when the user will press a button or hit escape.  

Keyboard binding tab Bind key exemple pannel

And this is where I'm stuck. How can I listen for any keyboard or mouse input? 

 

Also, I had another question:

How can I save options?

How can I save options (keyboard input, graphical options, ...) to load them when the game starts? Or does Leadwerk already do that every time the user hit apply in the options panel?

 

Thank you very much, I hope I've explained myself enough.

Just making games for fun. Currently working on T3-L4

Linka logo

Link to comment
Share on other sites

  • Solution

When you create a project a game settings file with the same name is created in the path. 
C:\Users\USERNAME>AppData\local

You can retrieve and store configurations, using the commands.
https://www.leadwerks.com/learn?page=API-Reference_Object_System

That is, if for some reason there is no SetProperty command where the key and value are set, for example.

System:SetProperty("FullScreen",true)

 

  • Thanks 1

 

 

Link to comment
Share on other sites

 

System:SetProperty("KeyMoveF", label:GetText())
System:SetProperty("KeyMoveB", label:GetText())

keyMoveF = System:GetProperty("KeyMoveF")

I don't know if the above has anything to do with your other concern, I'm sorry I don't speak English, I use the translator.

 

 

Link to comment
Share on other sites

17 minutes ago, ?Yue? said:

 

System:SetProperty("KeyMoveF", label:GetText())
System:SetProperty("KeyMoveB", label:GetText())

keyMoveF = System:GetProperty("KeyMoveF")

I don't know if the above has anything to do with your other concern, I'm sorry I don't speak English, I use the translator.

Thanks, I didn't quite understand how to use GetProperty and SetProperty. 

You idea sounds good the problem is how to detect if the player is pressing mouse1, shift, etc... I had a first idea with a simple InputText accepting 1 char. This OLD method helped with alphanumeric but not with special key like shift, ctrl or with mouse input.  And that's my main problem right now (alongside listening for mouse / keyboard input.)

 

Anyway, I will keep looking on forums and doing some experiment on my code.

For the time being, I will go to bed.

Good night and thank you again.

 

Also, don't worry about your English, I understood ?

Just making games for fun. Currently working on T3-L4

Linka logo

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...