Coding language differences
Jump to navigation
Jump to search
When programming ZScript, it is often recommended practicing a different coding language to become familiar with how things work. However, every language has its own quirks that make it different from the next one. Here is a list of identified coding languages that possess many similarities to ZScript and their differences, including (but not limited to) syntax.
From C(++)
- No dereference or address variable pointers (* and & respectively) -- only by pointers (i.e.
target.health
) - 'new' syntax is
<ClassName> thing = new('<ClassName>');
- NOTE: Actor classes and all inheriting from it cannot be created with the
new
keyword, only the Spawn function or related.
- 'auto' is known as 'let'
- 'this' is known as
self
readonly
keyword available
From Java
- 'boolean' is known as
bool
- No 'public' keyword. Everything is public by default, unless otherwise specified with
private
orprotected
.
From Lua
ZScript has multi-return and named arguments from Lua, with the following differences:
- Multi-return values must be encased in square brackets:
[val1, val2] = A_MyFunctionWithTwoReturns();
- Named arguments must be used after the required parameters, and must be in order according to the function's specifications.
From DECORATE
- ZScript uses
;
like in C-style languages. - Default Actor properties and Actor flags must be enclosed in the
Default { }
block. - ZScript has more strict checking for how values are specified. For example, in DECORATE you can define an actor's DamageType as
DamageType Fire
, but ZScript doesn't allow that, it has to beDamageType 'Fire';
orDamageType "Fire";
. The reason is,damageType
internally is a name, and names must be specified in quotation marks.
- All Actor properties that take a string, name or a class name, must be enclosed in quotation marks.
- DoomEdNums aka editor numbers cannot be added in ZScript directly. They must be specified through MAPINFO, in the
DoomEdNums
block. (This method is recommended for DECORATE as well, however, since it's generally more convenient.) - Names of ZScript classes cannot begin with a number. For example,
12Gauge
would not be a valid class name in ZScript. Use something likeShotgunAmmo_12Gauge
for example.