Mod:Creation Kit/Property Reference

A property is a pair of functions (or, sometimes, only one function) that looks and behaves kind of like a variable. You can read a value from it, or assign a new one, just like a variable, assuming that it's allowed. There are three kinds of property, the full property, the auto property, and the auto read-only property. All three of them appear the same to an external script. You can kind of think of them as public variables, but where the owning script can control how they are used.

Full Property
[ ]               'endProperty'

The full property gives you full control over exactly what the property does and what it does or does not allow. The functions inside the property definition are normal functions, with the exception that they must be either a "Get" function (which returns the same type as the property and takes no parameters), or a "Set" function (which returns nothing and takes a single parameter of the same type as the property). You may omit either one of them, but at least one must exist.

When someone assigns a value to the property, it will call the set function, passing in the desired value. When someone tries to get the value a property holds, it will call the get function and take the result. If the set function does not exist, then no one can write to the property. If the get function does not exist, then no one can read from it.

If you want the property to show up in the editor, it should at least have a set function, and not have the hidden flag.

Auto Property


An auto property is, for all intents and purposes, a public variable. It will create a hidden variable and hidden get and set functions that manipulate it, so you don't have to. It may optionally be initialized with a value using the same syntax as an object variable. (There are also internal optimizations that make these properties more efficient than the "full" type.)

Auto properties may not be defined in native scripts.

An auto property is made immutable by adding "Const" to the end of the definition line. The value of a "Const" property can only be set in the editor, so any value recorded in a save game will be ignored, allowing changes to the master file to override save game data.

Auto Read-Only Property
 ::= 'Property' '=' 'AutoReadOnly' *

An auto read-only property is simply a publicly accessible value that cannot be changed. For obvious reasons, it must be assigned a value when declared. (There are also internal optimizations that make these properties more efficient than other properties.)

Examples
Mod:Creation Kit/Category:Scripting Mod:Creation Kit/Category:Papyrus Mod:Creation Kit/Category:Papyrus Language Reference