• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

WHY CODE NOT WORK!!!

L

LegionZ_Gaming

Guest
im trying to toggle a button like if i were to be changing items and keeping it on so if i press the 1 key the item will stay on until i press 1 again

My Code:

//Toggle I/O Key 1
if keyboard_check_pressed(ord(1))
{
if Toggle_Trigger1 == true
{
Toggle_Trigger1 = false;
}

if Toggle_Trigger1 == false
{
Toggle_Trigger1 = true;
}
}
 

Bingdom

Googledom
It is because you're setting the value back to what it used to be.
Both of the if checks are being executed. You'll want to use an else.

This can also be shortened to one line, however, I'll let you figure that one out.
NOT (!) Will be used
 
L

LegionZ_Gaming

Guest
It is because you're setting the value back to what it used to be.
Both of the if checks are being executed. You'll want to use an else.

This can also be shortened to one line, however, I'll let you figure that one out.
NOT (!) Will be used
Thx I figured it out
 
P

ParodyKnaveBob

Guest
I'm glad you figured it out, but in case anyone's wondering (since LegionZ_Gaming didn't explain what the solution was), the ord(1) has a logic error: ord("1") will produce the intended result.

Regards,
Bob $:^ J
 
Top