Top-Level

Full ZScript files are referred to as "translation units." This terminology comes from the C standard, and refers simply to the entirety of a ZScript source file. ZScript files are searched for in lumps named zscript with any extension, including none. The standard extension is .zs, but .zsc, .zc and .txt are common as well.

Translation Units

The base translation unit zscript may start with a version directive, then followed by any number of top-level definitions and #include directives. Included translation units may not have version directives.

All keywords and identifiers in ZScript are case insensitive.

TranslationUnit

VersionDirective? TopLevelDefinition*

Version Directives

A version directive may be placed at the very beginning of a ZScript file. The version directive describes the ZScript version to use. By default ZScript is version 2.3, the original ZScript specification. This old version is not supported by this documentation and it is highly encouraged to always use the latest version of ZScript. The minimum version supported by this documentation is 3.0.

VersionDirective

version StringLiteral

Top-level Definitions

A ZScript file can have one of several things at the top level of the file, following a version directive.

TopLevelDefinition

Include Directives

Include directives include other files to be processed by the ZScript compiler, allowing you to organize and separate code into different files.

Note that included files will conflict with other mods. If two mods have a file named zscript/MyCoolClasses.zsc and both include it, expecting to get different files, the engine will fail to load with a script error.

To avoid this, it is suggested to place your ZScript code under a uniquely named sub-folder.

IncludeDirective

#include StringLiteral

Examples

Version Directives

version "4.3.3"

Include Directives

#include "zscript/MyCoolMod/MyCoolClasses.zsc"