Using Global Variables.
Wp:SetGlobalVariable(variable, value)
Wp:GetGlobalVariable(variable)
Sometimes it's useful to use a variable to control things in your script. The tutorial strategies use this to control things. The interaction between the cook and bosun are also controlled by variables. Variable values are stored with the save game.
You add a new variable to file init.aix. Increment the index by one for each variable you add. These variables are single digit only 0-9. I haven't tried letters.
Quote:
VAR_SQ_BOSUN_STATE = 13;
VAR_CR_NAV_STATE = 14;
VAR_CR_CHIEF_STATE = 15;
VAR_CR_SO_STATE = 16;
VAR_CR_SO_KILL_COOK_TRIGGER = 17; <-- here's our new entry
|
To set the variable:
Quote:
Wp:SetGlobalVariable(VAR_CR_SO_KILL_COOK_TRIGGER, 1);
|
To check the variable:
Quote:
if Wp:GetGlobalVariable(VAR_CR_SO_KILL_COOK_TRIGGER) == 1
{Wp:PlayAnimationAndWait( "Use_Machete_on_Cook" );
}
endif;
|