Differences

This shows you the differences between the selected revision and the current
version of the page.


wmebook:ch2 2008/07/21 19:44 wmebook:ch2 2008/07/21 19:47 current
Line 193: Line 193:
I think you’re getting a bit tired of this //variable// talk so we’ll focus now on different things and return to the big strength called **objects** a tad bit later on. I think you’re getting a bit tired of this //variable// talk so we’ll focus now on different things and return to the big strength called **objects** a tad bit later on.
 +
====== 2.2 Conditions ====== ====== 2.2 Conditions ======
Line 260: Line 261:
**if ( (a>1 && a<10) || (b =="John") )** is one of the more complicated tests. It will execute the following command if the variable //a// is bigger than 1 AND smaller than 10 OR if variable //b// contains the word John. **if ( (a>1 && a<10) || (b =="John") )** is one of the more complicated tests. It will execute the following command if the variable //a// is bigger than 1 AND smaller than 10 OR if variable //b// contains the word John.
-//**Syntax rule no.4**+//**Syntax rule no.5**
If you want to execute multiple commands in the condition, you use **curly** brackets to enclose the commands which will then take place. If you want to execute multiple commands in the condition, you use **curly** brackets to enclose the commands which will then take place.
Example:// Example://
Line 381: Line 382:
Those loops are very nice for some background processes you need to carry on for the whole game. For example you can check if the background music is playing and if it stops, you can play another song from the play list or in the demo project those processes handle caption displaying. Those loops are very nice for some background processes you need to carry on for the whole game. For example you can check if the background music is playing and if it stops, you can play another song from the play list or in the demo project those processes handle caption displaying.
 +
Line 445: Line 447:
</code> </code>
-//**Syntax rule no. 5**+//**Syntax rule no. 6**
function name must contain only alphanumeric characters and there shouldn't be any whitespace characters.// function name must contain only alphanumeric characters and there shouldn't be any whitespace characters.//
Everything should be very clear at this point. If it’s not, please review the previous chapters before you can understand what’s going on. The only important thing is that we passed to **if** command, instead of our good old direct comparison, a //function//, which returns true or false. **if** command evaluates the function (which in this case returns //false//) and then executes the //else// block. Everything should be very clear at this point. If it’s not, please review the previous chapters before you can understand what’s going on. The only important thing is that we passed to **if** command, instead of our good old direct comparison, a //function//, which returns true or false. **if** command evaluates the function (which in this case returns //false//) and then executes the //else// block.
 +
====== 2.5. Includes ====== ====== 2.5. Includes ======
Line 462: Line 465:
**Important:** **Important:**
Never initialize your variables in the include files. They will get reinitialized with every inclusion of your script. Never initialize your variables in the include files. They will get reinitialized with every inclusion of your script.
- 
-<code script> 
-for (var a=0; a<10;a=a+1) Game.Msg("Hell"); 
-Game.Msg("1"); 
-for (a=0; a<10;a=a+1) Game.Msg("Hell"); // note that I had to put the var away as it was already declared before. 
-Game.Msg("2"); 
-for (a=0; a<10;a=a+1) Game.Msg("Hell"); // note that I had to put the var away as it was already declared before. 
-Game.Msg("3"); 
-</code> 
 
wmebook/ch2.1216662255.txt.gz · Last modified: 2008/07/21 19:44 by metamorphium
Recent changes RSS feed Creative Commons License Driven by DokuWiki