ZScript special words
From ZDoom Wiki
|Note: This feature is for ZScript only.|
ZScript contains special words for certain circumstances.
- Compares a pointer to a class type. Similar to CheckClass with ancestor checks always enabled.
if (mobj is "classname")
- Infer the type of a local variable, from what is initially assigned to it.
let a = 1; // The type of a is int. let b = self.Owner; // The type of b is Actor. let c = 1.25; // The type of c is double. let d = "Hello, world!"; // The type of d is String.
- You can use this as a shorthand for checking the real class of an object:
let i = Inventory(someObject); // The type of i is Inventory. // If someObject is an instance of Inventory, then i will refer to that object. // If someObject is of some other class, then i will be null.
- Qualifier for function parameters. Allows passing of a parameter by reference.
- Qualifier for function parameters, but has no purpose aside for documentation. Can be specified with 'out'.
- 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>
- 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;
- 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.
- 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!