if-else statements might be bugged?
poombus opened this issue ยท 2 comments
I'm not sure what the cause might be, but it seems like SOMETIMES if-else statements don't function as intended.
I have...
//global_game_timer is changed to 60 by an implied function not mentioned.
global_game_timer = 0;
__on_tick() -> (
if (scoreboard('gamestate','val') == 1,
if (global_game_timer > 0,
print('true');
global_game_timer = global_game_timer - 1;
,
print('false');
function();
);
);
);
The problem is that even though global_game_timer is clearly above 0, it'll still run function()
. What I don't get is that even though it runs function()
, it doesn't run print('false')
. Is this a bug, or am I doing something wrong?
oh, and it does run both print('true')
and global_game_timer = global_game_timer - 1;
as intended.
Nevermind, I found a solution sort of. The code above worked as is when I removed fake players (I don't know what the fake players did that made it not work, nor do I know if it would've worked with real players).
It started working WITH the fake players when I added an extra condition in the if-statement.
if (scoreboard('gamestate','val') == 1 && global_game_timer > 0, ... );
I still don't know what the cause was, but even though it recognized that global_game_timer
changed and that it was above 0, it still somehow triggered the else statement that was checking to see if it was <= 0.