Jump to content
  • Advertisement
Sign in to follow this  
satsujin

XNA Keyboard input in Lua

This topic is 2154 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi folks, I have been trying to move my xna input checks into Lua. It has worked for the most part but strangely while the speed is fine in C# when I move the script to Lua, the keyboard input seems to have a bug in it where it lags before responding. If I just press and release the Space key nothing comes in my output windows but it works if i hold it down for about 2-3 seconds and release it. This bug does not occur with mouse input. I don't know why.

 

Here is is my script which is run from a DoFile in my XNA Update loop. 

if (gameController.inputController:Pressed(Keys.Space))
then
Console.WriteLine("pressed");
    if (mainMenu.cursorState == "look")
    then
        mainMenu.cursorState = "talk";
        Console.WriteLine(mainMenu.cursorState);
    else
        mainMenu.cursorState = "look";
        Console.WriteLine(mainMenu.cursorState);
    end
end 

the Pressed function is used to just check the previous KeyboardState and the current Keyboard state so that we know the key has been pressed and released instead of just being pressed.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!