mirror of https://github.com/marrub--/zscript-doc
44 lines
1.3 KiB
Markdown
44 lines
1.3 KiB
Markdown
Top-level
|
|
=========
|
|
|
|
A ZScript file can have one of several things at the top level of the file:
|
|
|
|
- Class definitions
|
|
- Structure definitions
|
|
- Enumeration definitions
|
|
- Constant definitions
|
|
- Include directives
|
|
|
|
Class definitions
|
|
=================
|
|
|
|
A class definition starts with a class header, followed by an opening brace, class data and a closing brace. Alternatively, you can follow the class header with a semicolon and the rest of the file will be considered class data.
|
|
|
|
Class headers
|
|
-------------
|
|
|
|
The class header is formed as such:
|
|
|
|
```cs
|
|
class Name [: BaseClass] [Class flags...]
|
|
```
|
|
|
|
Class flags include:
|
|
|
|
| Flag | Description |
|
|
| --------------------- | --- |
|
|
| abstract | Cannot be instantiated with new(). |
|
|
| native | Class is from the engine. |
|
|
| ui | Has UI scope. |
|
|
| play | Has Play scope. |
|
|
| replaces ReplaceClass | Replaces ReplaceClass with this class. Only works on objects which are descendants of Actor. |
|
|
| version("ver") | Restricted to version <ver>. |
|
|
|
|
Example usages:
|
|
|
|
```cs
|
|
class MyCoolObject play // automatically inherits Object
|
|
class MyCoolThinker : Thinker // inherits Thinker
|
|
class MyCoolActor : Actor replaces OtherActor
|
|
class MyCoolInterface abstract // can only be inherited
|
|
``` |