Am I missing something obvious?

I am trying to create a simple solution where the user should press three times at num1 key. After pressing three times the number 111 should be shown on the screen. My problem is that 111 is shown immediately after pressing num1 the first time. What am I doing wrong?

Cheers

Farid

I think GDevelop is so efficient it sees you released 1 and that numberPosition was 0 so now it’s 1, so now that it’s 1 it makes it 2, then now that it’s 2 it makes it 3. Sometimes changing the order is a quick fix so move them around to be 3, 2, 1, 0. I like to break them up though so that I’m not using the same variable compared against itself to change itself, so you can try something like that too.

And I’m sure there is a setup you can do with bool checks too but I just woke up so am not contemplating it.

1 Like

Wow,
I just changed the order and now it works! Weird though… Thanks!

//Farid

1 Like

It’s a common mistake. The events are read from top to bottom. Each time the variable is increased, it made the next condition true which made the next and so on. When you reverse their order the condition that checks for that value has already been evaluated.

if a = 0 then a =1
if a = 1 then a = 2
if a = 2 then a = 3

if a = 2 then a = 3
if a = 1 then a = 2
if a = 0 then a = 1

2 Likes