ZScript special words

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

ZScript contains special words for certain circumstances.

  • is
    Compares a pointer to a class type. Similar to CheckClass with ancestor checks always enabled.
if (mobj is "classname")
  • let
    Auto deduces class types to a pointer. If the class is not the specified type, the pointer will be null.
let ptr = DoomImp(target);
  • out
    Qualifier for function parameters. Allows passing of a parameter by reference.
  • in
    Qualifier for function parameters, but has no purpose aside for documentation. Can be specified with 'out'.
  • dot
    Serves as an operator that results in a double. The syntax can take either a Vector2 or Vector3, but they must be the same on both sides. It is equivalent to a.length() * b.length() * cos(angle), where angle is the angle between the two vectors.
<Vector2> dot <Vector2>
<Vector3> dot <Vector3>
  • cross
    Similar to the dot function but returns a vector. The vector being assigned must be the same type its performing cross multiplication upon. The return value is a new vector that is perpendicular to both of the inputs (unless one of them is a 0 vector, or they are parallel/antiparallel), and therefore it cannot be used on 2D vectors.
<Vector3> = <Vector3> cross <Vector3>
Vector3 a = (1, 2, 3);
Vector3 b = (3, 2, 1);
double dot_prod = a dot b;
Vector3 cross_prod = a cross b;
  • self
    Used to reference the world actor currently running ZScript code. Typically implied, but sometimes useful to specify, such as when a variable in a function has the same name as a variable in the class. In such cases, self will refer to the variable in the actor instead of the function when appended with self.
  • invoker
    Used to reference the inventory actor currently running ZScript code. Note that this includes player weapons. It is necessary to prefix an inventory items' local variable references or methods with invoker!
  • owner
    Used to reference the owner of the inventory actor currently running ZScript code.

See also