Mod:Creation Kit/Struct Reference

Structs are basically mini-objects that can hold several variables of different types, but cannot contain functions or events, and cannot extend any objects or other structs. However, like objects (and unlike structs in other languages) they are passed and held onto by reference, not by value. Structs may be used in arrays.

Defining a Struct
+             'endstruct'

A struct is defined by having its name on the line with the struct, followed by the list of variables the struct contains, and terminated with 'endStruct'. The variables inside a struct can be anything except another struct, an array, or a var. Struct variables also may not be defined as const. Unlike object variables, struct variables may have documentation strings attached.

Struct Creation


To create a struct, use the "new" keyword, followed by the type.

The initial value of each variable in the struct will be the default value specified for each member in the struct definition.

If you make a struct property, then the Creation Kit will create and set up the struct for you if the CK user gives it a value.

Note that this cannot appear in the script outside of a function.

Accessing Struct Types in Other Scripts


You can access a struct type defined in another script by prefixing the name of the struct with the name of the script containing the struct, separating them with a colon. If you don't want to type in the script name all the type, you can use Import, just like with global functions.

Struct Members


To get a specific struct member, put its name after a dot, just like accessing a property on a script.