ZScript

From ZCWiki
Jump to: navigation, search
Version-2.50.png The information below describes features introduced in Zelda Classic version 2.50.


ZScript is a programming language that can be used to create scripts for use with Zelda Classic. ZScript (and ZASM, the other supported scripting language) enables quest designers to interact with and control certain aspects of the Zelda Classic game engine during run-time (when the player is playing a quest). For example, through the use of scripting, quest designers have created custom items, weapons and enemies, devised new puzzles, and so forth.

ZScript and ZASM were introduced in beta versions of Zelda Classic 2.5.

Language Guide

This page presents an overview of the ZScript scripting language, with links to the more important features. If you are completely new to scripting, you may wish to view ZScript Concepts first. You may also browse all the ZScript articles.

Basic Hierarchy

The basic hierarchy for ZScript - that is, the "layout" of the various ZScript items that would make up a typical script - is shown below. The script is the top-level construct in a ZScript script, though compiler directives and global variable declarations typically precede the first script declaration. You may create multiple scripts. Each script may include 1 or more functions, and each script must include the run() function. Functions typically include some variable declarations of their own, as well as the statements that actually do something when the function is called.

General Constructs

Declarations

You use declarations to create scripts, functions, and variables in ZScript.

Operators

Use operators to alter or compare variables and values.

Assignment Operators

The assignment operator and its variants assign a value to a variable.

Mathematical Operators

Use mathematical operators to mathematically manipulate variables and numbers.

Relational Operators

Use relational operators to compare variables and numbers.

  • Is equal to ==
  • Is not equal to !=
  • Is greater than >
  • Is greater than or equal to >=
  • Is less than <
  • Is less than or equal to <=
Logical Operators

Use logical operators for boolean (true or false) operations.

Bitwise Operators

Use bitwise operators to set or clear bits in integer values.

Control Statements

Control statements are used to instruct Zelda Classic to execute only certain portions of a script, or to execute a portion of a script a certain number of times.

Built-in Objects, Methods, and Properties

Of the following objects, Link, Screen, and Game are automatically made available for your use. The remaining objects and their methods and properties are only made available to you when you create a pointer to one of those objects.

Miscellaneous

Compiling and Assigning Scripts

ZScript files must be compiled before they can be used by ZQuest and Zelda Classic. See compiling scripts and assigning scripts for details.