zscript-doc/language/Members.md

60 lines
3.7 KiB
Markdown
Raw Permalink Normal View History

2019-04-02 06:36:03 -07:00
<!-- vim-markdown-toc GFM -->
2019-08-14 03:31:41 -07:00
* [Member Declarations](#member-declarations)
* [Example: Member declarations](#example-member-declarations)
2019-04-02 06:36:03 -07:00
* [Member Declaration Flags](#member-declaration-flags)
<!-- vim-markdown-toc -->
2019-08-14 03:31:41 -07:00
# Member Declarations
2019-04-02 06:36:03 -07:00
Member declarations define data within a structure or class that can be
accessed directly within methods of the object (or its derived classes,) or
indirectly from instances of it with the member access operator.
A member declaration is formed as so:
```
$[Member-declaration-flags...]$ Type Variable-name $[ , Variable-name]$... ;
```
## Example: Member declarations
Some basic member variables.
```
2019-04-05 16:34:55 -07:00
// An integer. Visible to and modifiable by everything.
2019-04-02 06:36:03 -07:00
int m_MyCoolInt;
2019-04-05 16:34:55 -07:00
// Three separate integers, defined short-hand.
2019-04-02 06:36:03 -07:00
int m_CoolInt1, m_CoolInt2, m_CoolInt3;
2019-04-05 16:34:55 -07:00
// Ten integers in one variable.
2019-04-02 06:36:03 -07:00
int[10] m_CoolIntArray;
2019-04-05 16:34:55 -07:00
// Can only be seen by this type.
2019-04-02 06:36:03 -07:00
private int m_CoolPrivateInt;
2019-04-05 16:34:55 -07:00
// Read-only (part of the class data, can only be seen by descendant types.
2019-04-02 06:36:03 -07:00
protected meta int m_CoolMetaInt;
```
2019-04-02 08:28:16 -07:00
# Member Declaration Flags
2019-04-02 06:36:03 -07:00
2019-09-10 02:53:21 -07:00
| Flag | Description |
| ---- | ----------- |
| `deprecated ( "ver" $[ , "reason" ]$ )` | If accessed, a script warning will occur on load if the archive version is greater than `ver`, with the reason `reason` specified in the message. |
| `internal` | Member is only writable from the base resource archive (`gzdoom.pk3`.) *Version 3.4.0 and newer.* |
| `latent` | Does nothing. Purpose unknown. |
| `meta` | Member is read-only static class data. Only really useful on actors, since these can be set via properties on them. |
| `native` | Member is from the engine. Only usable internally. |
| `play` | Member has Play scope. |
| `private` | Member is not visible to any class but this one. |
| `protected` | Member is not visible to any class but this one and any descendants of it. |
| `readonly` | Member is not writable. |
| `transient` | Member is not saved into save games. Required for unserializable objects and recommended for UI context objects. |
| `ui` | Member has UI scope. |
| `version ( "ver" )` | Restricted to ZScript version `ver` or higher. |
2019-04-02 06:36:03 -07:00
<!-- EOF -->