Log In  

I've run into a problem where nested menus are reading the same btnp input and I was wondering: is there a simple way to clear or ignore all the input until the next frame?

There is probably a different way to do it, but my code is kafkaesque and has gotten progressively worse as I've tried to solve this problem, so I felt it in poor taste to subject you to that.

P#10956 2015-05-28 01:13 ( Edited 2015-05-30 18:48)

On a related note, it would be nice to have an option to btnp that doesn't do auto-repeat when you hold it down. I had to code my own wrapper around btn to make double-jump work reasonably in my game.

P#10957 2015-05-28 01:46 ( Edited 2015-05-28 05:46)

At the top of your code, do something like this:

function new_input()
  return {
   clear = function (self, which)
    self[which]= false

Then at the top of _update, do something like this:

local in = new_in()

Now you can replace tests of btnp(0) inside _update with in[0], and you can also do in:clear(0) if and when you decide to clear it.

Of course, if your _update calls another function, it will have to pass "in" to that function - can't call new_in twice in the same frame without introducing exactly the problem you're hitting.

P#10958 2015-05-28 06:58 ( Edited 2015-05-28 10:58)
:: Cow

Thanks! I'll give that a shot.

P#10980 2015-05-29 00:31 ( Edited 2015-05-29 04:31)
:: Cow

Worked great with a couple modifications, thanks for your help Johnicholas. ❤

P#11013 2015-05-30 14:48 ( Edited 2015-05-30 18:48)

[Please log in to post a comment]

About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-06-18 07:14 | 0.014s | 4194k | Q:21