ZScript global variables

From ZDoom Wiki
Jump to: navigation, search
Note: This feature is for ZScript only.

ZScript possesses several global structs accessible by classes.

Type Name Writable? Use/meaning
int validcount yes Internal variable used to avoid processing of the same data during one render frame.
bool multiplayer no Set to true if the game is networked.
LevelLocals level - Contains various level-related data, for example level's time, level and map name, settings and statistics.
DehInfo deh - Internal values used by DeHackEd-parsing code.
PlayerInfo[] players - List of all players in the level.
bool[] playeringame no An array that defines whether the specified PlayerInfo structure in players[] is set.
EGameAction gameaction yes Deeply internal variable used to get/set the current engine state.
WARNING: Do NOT use this unless you know GameAction works!
int consoleplayer no The player that owns the current client.
Weapon WP_NOCHANGE no An internal constant to describe the case when PlayerInfo.PendingWeapon doesn't have a value.

Creating Global Variables

By using Event Handlers, global variables are easily accessible to by everything. See Events and handlers for more information on how to set up and event handler.

Once prepared, individual classes can be given access by first using the Find() function.

Class MyEventHandler : EventHandler
	int MyGlobalInt;

Class MyCustomClass : Actor
	MyEventHandler Event;
	override void PostBeginPlay()
		Event = MyEventHandler(StaticEventHandler.Find("MyEventHandler"));
		if (Event)
			Event.MyGlobalInt = 1;
			Console.Printf("My global int is: %d", Event.MyGlobalInt);