Syntax Reference
Last updated
Last updated
A script is contained in a script
block. This is equivalent to ScriptName extends...
in Papyrus. The only thing that can go before a script
block are comments and defines.
A state is a block with a name and an optional auto
flag.
Importing a script allows you to use its Global functions without having to prefix them with the script name.
A property is a script-scoped variable that's available to external scripts. A property itself does not actually store anything, it's an interface between a script's private variable and the outside world.
Auto properties represent a private variable and a basic setter like the one above. An auto property starts with auto property
and then follows the regular variable format. They can optionally have a default value.
Variable definitions begin with a name, followed by a type and finally an optional value. Since Papyrus doesn't do type inference, types must be explicitly defined. (Type inference is a future planned feature of PaperScript)
If you don't specify a value, the variable will be filled with the Papyrus default for that type.
A function starts with def
, has a name, optional arguments and an optional return type. Functions that don't have a return type (void
), don't need to specify one.
Events work the same as functions but start with event
instead of def
and never have a return type.
The If/ElseIf/Else syntax is virtually identical to Papyrus but with braces. Parentheses are optional and only used to denote precedence.
elseif does not work correctly as of v1.0.1-alpha.1 , this is a known issue that will be fixed
Should work correctly as of v1.0.3-alpha.1
The while
syntax is the same as Papyrus but with braces. Parentheses are once again optional and used for precedence.
PaperScript has a simple implementation of the increment and decrement operators. It's basically just shorthand for adding or subtracting 1 from an int.
A switch
is one of the features sorely missing from Papyrus. PaperScript supports switch
statements that get translated into if/elseif/else in the resulting Papyrus.
Cases can be single-line or multi-line. Single-line cases must end with a semicolon. Multi-line cases are in braces.
The default case follows the same pattern and will match anything that doesn't have a case.
Cases do not fall through and there is no break
switch
is a PaperScript feature with no native equivalent in Papyrus and may not work correctly in some edge cases.
Check out Feature Deep Dive to see how this works
range
is another new addition to PaperScript that doesn't exist in Papyrus. It works as a foreach
loop and gets translated into a while in the resulting Papyrus.
range
is a PaperScript feature with no native equivalent in Papyrus and may not work correctly in some edge cases.
Check out Feature Deep Dive to see how this works
See the for more info
See the for more details