Thanks, fixed. Funny, nobody mentioned before the unrelated code (was from my original book).
So that's a bug with the Wintermute engine? What about using }else if{ instead of a switch, wouldn't that be quicker than writing a function
It's a bug in wme engine. To If/Else imagine having 10 different states:
if (a=="blue")
{
//do something
}
else
if (a="red")
{
//do something
}
etc.. etc..
will always look worse than:
switch(a)
{
case "red":
// Do something
break;
case "blue":
// Do something
break;
// etc...
}
But you can use both and sometimes you have to.
Is it a good idea to put your global variables in an include file (e.g. "global myVar;") so that you can get/set the value without having to remembering to write global before it the first time you reference it in each script?
I use it for variables I refer often to. For variables which need to be global but I use them only once or twice in the whole game (various game states) I use the normal inscript declaration.
The comment was to warn before having in base.inc for example:
global MyVariable = 0;
This would ALWAYS reset the variable to 0 every inclusion (so no chance to setting something reasonable).
Even worse is to have:
global MyObject = new Object("path to object"); which would create a new memory object everytime any script runs. This will very soon cause the game to eat all RAM and is sometimes a big problem of newcomer's games.