Jump to content

Lua and key input?


Andy Gilbert
 Share

Recommended Posts

Trying to check for key inputs in lua but struggling.

 

I tried :

if KeyDown(KEY_SPACE)==1 then                        
	model1body:AddForce(Vec3(0,0,100))	
end

 

Which didnt work, so i then tried :

if KeyDown(KEY_SPACE)==1 then                        
	AppTerminate=1	
end

 

Which also does nothing....

 

thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

Trying to check for key inputs in lua but struggling.

 

I tried :

if KeyDown(KEY_SPACE)==1 then                        
	model1body:AddForce(Vec3(0,0,100))	
end

 

Which didnt work, so i then tried :

if KeyDown(KEY_SPACE)==1 then                        
	AppTerminate=1	
end

 

Which also does nothing....

 

thanks

Andy

 

 

Are you including dofile('\Scripts\base.lua') to your script at the top? I think it's required for the key constants.

 

Try KeyHit() also. Just to make sure. Also put an AppLog() inside your if statement and check your engine log to make sure it's getting inside there.

Link to comment
Share on other sites

It should work, you should use AppLog("KEY SPACE DOWN") to see if it has any effect.

Keypressed work only if you click on the Editor scene first, I click on the terrain so I don't select any objects.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

AppTerminate is a variable you are initializing in the loop. It would not have any effect. Try Notify("Hit!").

 

Make sure you are including the keycodes script that defines all the key constants.

My job is to make tools you love, with the features you want, and performance you can't live without.

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