Structure Definitions

A structure is an object type that does not inherit from Object and is not always — though occasionally is — a reference type, unlike classes. Structures marked as native are passed by-reference to and from the engine in an implicit pseudo-type Pointer<T>, and null can be passed in their place. Also note that this means the engine can return null structures. User defined structures cannot be passed as arguments or returned normally.

Structures are preferred for basic compound data types that do not need to be instanced and are often used as a way of generalizing code.

Structures are subject to object scoping.

StructureDefinition

struct Identifier StructureFlag* { StructureContent* } ;?

Structure Flags

KeywordDescription
clearScopeStructure has Data scope. Default.
nativeStructure is from the engine. Only usable internally.
playStructure has Play scope.
uiStructure has UI scope.
versionRestricted to the given ZScript version or higher.
StructureFlag

Structure Contents

StructureContent

Examples

Structure Definitions

// Simple structure.
struct MyCoolStructure
{
	int X;
	int Y;
	int Z;
}