Hello, today i will explain how to use another idea of "if" statement since i forgot to cover it hehehe
so now we got a normal script:
so this is how we do it:
we use "if" statement as usual , but after our conditions we remove "jf @MAIN" and we add "then" keyword
like this:
so what is the different between "jf" and "then" statement?
well as far as i know , it is a replace for "jf" , in some conditions we use "then" because we want the code to continue if the conditions is not right << you may not understand this yet don't worry
ok to explain more , after "then" we need the keyword "end" , so while our conditions are true after the codes finished , "end" will end the current "if - then" statement after it is finished ...
so we do it like this:
now if the conditions are true , "end" will end our "if-then" statement after all codes (which is in our case it is this>> 0AD0: show_formatted_text_lowpriority "This is lazzy massage" time 2000) and then jump at main to loop again ,,
BUT if our conditions is false(not true) , the codes from "then" keyword to "end" will be skipped
it is like "jf" it will skip the codes under it and jump again at the label (in our case @MAIN) ,, but with "then" statement , we can put more codes under "end" keyword , and these codes will be Read even if the conditions are false ,, because as i said if the conditions are false it will skip the codes between "then" keyword and "end" keyword , but under "end" the codes are not effected by the "if-then-end" statement..
so it will be read and run ,, so here "end" is a good keyword , because in "jf" keyword if the conditions is false it will directly go to the label(MAIN) again , but with "end" keyword it will bypass the codes between "then" and "end" and continue to read after "end" keyword, so we can make many conditions without making many labels.
(i know this is hard to understand , but it is the way it is , and you better know this heh,, read again , if you didn't understand ,and i'm always here to help)
we do it like this:
so here we can run 2 different codes and conditions under the same label ,,
and think about that , "if" is the function starter ,, "then" is the opener ,, "end" is the closer
and every "then" keyword need one "end" keyword to close it
and "end" is close from the inner to outer
like this:
this is how "end" works , it is pretty easy and you will get use to it fast,
if you didn't understand a point in the tutorial , please comment so i can explain it more for you ,, but i recommended to read the tutorial again before asking because this tutorial need to be read at least 2 times..
if i helped you don't forgot to hit the thanks button
thanks for following my tutorials.
so now we got a normal script:
Code:
{$cleo}
0000:
:MAIN
wait 0
if and // our conditions keyword
056D: actor $PLAYER_ACTOR defined //define the actor
0AB0: key_pressed 115 //f4
jf @MAIN
//here we put our codes to do if the conditions are true ,, like this:
0AD0: show_formatted_text_lowpriority "This is lazzy massage" time 2000
jump @MAIN
so this is how we do it:
we use "if" statement as usual , but after our conditions we remove "jf @MAIN" and we add "then" keyword
like this:
Code:
{$cleo}
0000:
:MAIN
wait 0
if and // our conditions keyword
056D: actor $PLAYER_ACTOR defined //define the actor
0AB0: key_pressed 115 //f4
then // then is another keyword which do the same as jf , but not very the same
//here we put our codes to do if the conditions are true ,, like this:
0AD0: show_formatted_text_lowpriority "This is lazzy massage" time 2000
end // i will explain this later (continue reading)..
jump @MAIN
so what is the different between "jf" and "then" statement?
well as far as i know , it is a replace for "jf" , in some conditions we use "then" because we want the code to continue if the conditions is not right << you may not understand this yet don't worry
ok to explain more , after "then" we need the keyword "end" , so while our conditions are true after the codes finished , "end" will end the current "if - then" statement after it is finished ...
so we do it like this:
Code:
{$cleo}
0000:
:MAIN
wait 0
if and // our conditions keyword
056D: actor $PLAYER_ACTOR defined //define the actor
0AB0: key_pressed 115 //f4
then // then is another keyword which do the same as jf , but not very the same
//here we put our codes to do if the conditions are true,, like this:
0AD0: show_formatted_text_lowpriority "This is lazzy massage" time 2000
end
jump @MAIN
now if the conditions are true , "end" will end our "if-then" statement after all codes (which is in our case it is this>> 0AD0: show_formatted_text_lowpriority "This is lazzy massage" time 2000) and then jump at main to loop again ,,
BUT if our conditions is false(not true) , the codes from "then" keyword to "end" will be skipped
it is like "jf" it will skip the codes under it and jump again at the label (in our case @MAIN) ,, but with "then" statement , we can put more codes under "end" keyword , and these codes will be Read even if the conditions are false ,, because as i said if the conditions are false it will skip the codes between "then" keyword and "end" keyword , but under "end" the codes are not effected by the "if-then-end" statement..
so it will be read and run ,, so here "end" is a good keyword , because in "jf" keyword if the conditions is false it will directly go to the label(MAIN) again , but with "end" keyword it will bypass the codes between "then" and "end" and continue to read after "end" keyword, so we can make many conditions without making many labels.
(i know this is hard to understand , but it is the way it is , and you better know this heh,, read again , if you didn't understand ,and i'm always here to help)
we do it like this:
Code:
{$cleo}
0000:
:MAIN
wait 0
if and // our conditions keyword
056D: actor $PLAYER_ACTOR defined //define the actor
0AB0: key_pressed 115 //f4
then // then is another keyword which do the same as jf , but not very the same
//here we put our codes to do if the conditions is true ,, like this:
0AD0: show_formatted_text_lowpriority "This is lazzy massage" time 2000
end
//here we can add more codes and conditions
//like this:
if and // our conditions keyword
056D: actor $PLAYER_ACTOR defined //define the actor
0AB0: key_pressed 116//f5
then // then is another keyword which do the same as jf , but not very the same
//here we put our codes to do if the conditions is true ,, like this:
0AD0: show_formatted_text_lowpriority "This is not a lazzy massage" time 2000
end
jump @MAIN
so here we can run 2 different codes and conditions under the same label ,,
and think about that , "if" is the function starter ,, "then" is the opener ,, "end" is the closer
and every "then" keyword need one "end" keyword to close it
and "end" is close from the inner to outer
like this:
Code:
{$cleo}
0000:
:MAIN
wait 0
if
056D: actor $PLAYER_ACTOR defined //define the actor
then
if
0AB0: key_pressed 115 //f4
then
0AD0: show_formatted_text_lowpriority "This is a super massage" time 2000
end // this will close the second "then" after the "key_pressed" opcode
end // this will close the first "then" after "actor define" opcode
jump @MAIN
this is how "end" works , it is pretty easy and you will get use to it fast,
if you didn't understand a point in the tutorial , please comment so i can explain it more for you ,, but i recommended to read the tutorial again before asking because this tutorial need to be read at least 2 times..
if i helped you don't forgot to hit the thanks button
thanks for following my tutorials.