Spoiler
Spoiler
if ( timer < 2 )
set timer to ( timer + GetSecondsPassed )
return
endif
set timer to 0 ; as soon as possible to not forget it!
; ...
if ( state == blah )
set button to GetButtonPressed
if ( button == -1 )
return
endif
set state to somethingelse ; as soon as possible to not forget it!
if ( button == blah )
; ....
Abot, wouldn't the script skip over "if ( button == blah )" in that setup? It appears that it would process setting the button to GetButtonPressed, would check for -1, and then switch the state regardless of what happened with -1.
Edit: Whoops, the state change wouldn't take effect until the return.
short state
short b1
short b2
if ( state == 0 )
set state to 1
MessageBox "Press a button" "1" "2"
return
elseif ( state == 1 )
set button to GetButtonPressed
if ( button == -1 )
return ; return until a button pressed
endif
set state to 2 ; a button was pressed, ensure to exit code block regardless of what button
if ( button == 0 )
set b1 to ( b1 + 1 ) ; process button 1
else
set b2 to ( b2 + 1 ) ; process button 2
endif
return
elseif ( state == 2 )
set state to 0 ; reset state, ensure to exit code block
MessageBox "button 1 pressed %g times, button 2 pressed %g times" b1 b2 ; give information
endif
So it's better to "if->endif, if->endif" for the "button == -1" portion rather than "if->elseif"?
Greatness7 solved the problem by adding some StopScript and StartScripts to the scripts. It essentially boiled down to the game having an issue with two scripts running at the same time + two instances of GetButtonPressed.