How do I add 1 each time a button is pressed[SOLVED]

Started by Borislav, May 16, 2018, 13:41:36

Previous topic - Next topic

Borislav

I want the script to add 1 once when the button is pressed, but instead, it adds and adds and adds 1 to the value.
I am trying to make a program that will create bricks once when a button is pressed.

STEVIE G

I suspect you are using KeyDown rather than Keyhit?  There are various ways of doing this but it might be helpful to see your code first?

Cheers
Stevie


Matty

Depending on the language used (blitz3d keyhit) you might want to detect on a 'keyup' state - ie when it changes from keydown to keyup....it is a change in key state you want not the actual state. So store the previous state 'down' and then when the state changes to 'up' record the increment.

Borislav

#3
Quote from: STEVIE G on May 16, 2018, 16:53:36
I suspect you are using KeyDown rather than Keyhit?  There are various ways of doing this but it might be helpful to see your code first?

Cheers
Stevie
Oh my god thank you so much! (I used KeyDown because normal buttons glitch with KeyHit)  :D