forked from FWGS/hlsdk-portable
-
Notifications
You must be signed in to change notification settings - Fork 10
Global variables
Roman Chistokhodov edited this page Jul 23, 2024
·
5 revisions
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.
- New spawnflag
Act as Master
. See Master entities - New
Trigger Mode
options:Modify/Set value
andSet State: Obey Use-type
. - New parameter
Initial Value
to 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 Mode
it might ignore the input use-type and change the associated global variable state according to the selected trigger mode. SelectingSet State: Obey Use-type
makes it obey the use-type. - If
Trigger Mode
isModify/Set value
it reacts as follows: -
- If use-type is
Set
(e.g. fired bygame_counter_set
orcalc_eval_number
) it assigns the input value to the numeric value of the associated global variable.
- If use-type is
-
- If use-type is
Toggle
orOn
it increments the numeric value of the associated global variable by 1.
- If use-type is
-
- If use-type is
Off
it 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
To see the output of the following commands you must set developer
cvar to 1 or higher.
-
impulse 104
is 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_cheats
is enabled. -
set_global_value
- set a number value associated with a global variable. This is for debugging purposes and it's allowed only whensv_cheats
is enabled.