IF vs IF AND statement

Hello, today i will explain how to use "IF OR" statement

ok so this is a very simple script:

Code:
{$CLEO}

0000: NOP


// this is comment ...


:MAIN
wait 0
if and
056D:   actor $PLAYER_ACTOR defined
0AB0: 49 //key 1 pressed?
jf @MAIN
0332: set_actor $PLAYER_ACTOR bleeding 1  
jump @MAIN

now you see we used "if and"

now "if and" can handle 8 conditions as max
and "if and" means that (if this condition is true AND if this condition is true)
means that all conditions must be true to run the code


so here:

Code:
:MAIN
wait 0
if and
056D:   actor $PLAYER_ACTOR defined
0AB0: 49 //key 1 pressed?
jf @MAIN
actor must be defined and key 1 must be pressed to run the script , else jump @main (the label)


but now we want to run the code if we pressed 1 or 2

so we do it like this:

Code:
:MAIN
wait 0
if  
056D:   actor $PLAYER_ACTOR defined //we separated it to force check it !
jf @MAIN
IF OR //this is our statement
0AB0: 49 //key 1 pressed? ,, if key 1 pressed
0AB0: 50 //key 2  pressed?,, or key 2 pressed 
jf @MAIN //none of the keys pressed? then jump @main again
0332: set_actor $PLAYER_ACTOR bleeding 1 //active the bleeding state 

so now if we pressed key 1
or if we pressed key 2
the script will run
so our activation keys is  1 or 2 , not 1+2 means if we pressed 1 we run the cheat , and if we pressed 2 we run the cheat too.

and here as you can see that we separated the actor define condition
because we need it to define before run the script and if we put it in "if or" statement , the script will run if we pressed 1 or 2 even if the actor is not defined !

so we separated it to force the script to check to define the actor

so here it will check if actor is defined first , if yes then it will check if we pressed 1 or 2 so the script run and set bleeding state to 1 (active it)
but if the actor is not defined it will jump at main so it will loop until the actor get defined
and if we didn't pressed 1 or 2 the cheat will jump at main again so it will loop to check again if the actor is defined and if we pressed 1 or 2


FAST RECAP:
IF OR:
if this key pressed or if this key pressed then run the code , else jump @main

IF AND:
if this key pressed and if this key pressed also (at the same time) then run the code , else jump @main



thanks for following my tutorials.
if i helped you please hit the thanks button and the little heart(rep.) under my name so you can make me more trusted for users so they can reach me easily.
 
Top