Global variables - FreeSlave/halflife-featureful GitHub Wiki
Wiki is deprecated. Proceed to GitHub pages!
Global variables are named variables accessible across multiple levels. This feature existed in original Half-Life and has been extended in Featureful SDK.
In addition to State (which can be On, Off or Dead) each global variable has an associated numeric integer Value.
Just like in original HL, global variables can be set and read via env_global entity. It got some new parameters in Featureful SDK.
env_global
- New spawnflag
Act as Master. See Master entities - New
Trigger Modeoptions:Modify/Set valueandSet State: Obey Use-type. - New parameter
Initial Valueto set the initial numeric value of the global variable. - When used as
[LR]parameter it reports the numeric value of the global variable. See Locus system and Math.
Reaction to use-type:
- Depending on the
Trigger Modeit might ignore the input use-type and change the associated global variable state according to the selected trigger mode. SelectingSet State: Obey Use-typemakes it obey the use-type. - If
Trigger ModeisModify/Set valueit reacts as follows: -
- If use-type is
Set(e.g. fired bygame_counter_setorcalc_eval_number) it assigns the input value to the numeric value of the associated global variable.
- If use-type is
-
- If use-type is
ToggleorOnit increments the numeric value of the associated global variable by 1.
- If use-type is
-
- If use-type is
Offit decrements the numeric value of the associated global variable by 1.
- If use-type is
-
- In all cases if the global variable doesn't exist yet, it gets created first with the numeric value from
Initial Value.
- In all cases if the global variable doesn't exist yet, it gets created first with the numeric value from
See also: env_global on twhl wiki
Accessing global variables via console
To see the output of the following commands you must set developer cvar to 1 or higher.
impulse 104is used to output all existing global variables.set_global_state- set a global variable state (off,on,dead). This is for debugging purposes and it's allowed only whensv_cheatsis enabled.set_global_value- set a number value associated with a global variable. This is for debugging purposes and it's allowed only whensv_cheatsis enabled.