ZScript named arguments

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


ZScript supports the ability to add in named arguments. These arguments are useful for leaving other arguments blank in functions.

In order to use them, several conditions apply.

  1. Required parameters cannot be skipped and must be filled out.
  2. All parameters must be in chronological order as defined by the functions.
  3. The name of the parameter must be used followed immediately with a colon (:)
// Skips xofs, yofs, yvel, and angle parameters. These are also in chronological order.
A_SpawnItemEx("Rocket", zofs: 32, xvel: cos(pitch) * 20, zvel: -sin(pitch) * 20, flags: SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH|SXF_SETTARGET);