From ZCWiki
Revision as of 13:49, 16 February 2008 by ScaryBinary (talk | contribs) (Added example usage. Noted you must import the file with the import directive.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Std.zh is a file included with a download of Zelda Classic that contains several constant definitions used by ZScript scripts. It is crucial for both Zelda Classic's and ZQuest's proper functioning.


To use the definitions in the std.zh file, you must import it using the import compiler directive, as shown below.

import "std.zh"

The definitions can (and should!) be used to make ZScript scripts more readable. For example, when determining the direction Link is currently facing, you might write something like:

if(Link->Dir == 2){
  // Do something if Link is facing left (west).
  // ...

However, std.zh defines direction constants for you, so you should write:

if(Link->Dir == DIR_LEFT){
  // ...

Note that this style also practically eliminates the need for a comment, since it is clear from the ZScript code itself that you are checking to see if Link is facing left.

An example excerpt from the std.zh file is presented here. Note that since the std.zh file may change in future Zelda Classic releases, the real file (and not this Wiki) should be used as a final reference.

// Directions. Use with Link->Dir, etc.
const int DIR_UP         = 0;
const int DIR_DOWN       = 1;
const int DIR_LEFT       = 2;
const int DIR_RIGHT      = 3;
const int DIR_LEFTUP     = 4;
const int DIR_RIGHTUP    = 5;
const int DIR_LEFTDOWN   = 6;
const int DIR_RIGHTDOWN  = 7;