Mod:Creation Kit/Statement Reference

A statement is an arrangement of expressions used to perform work (and may just be a simple expression). There are also some more complicated statements like "if" and "while".

Define Statement


A define statement defines a single variable and, optionally, initializes it to a value. If a value is not given to it, it starts with the standard default value. A variable defined inside a function does not conflict with a variable defined in another function. A variable defined in an if or while block will not conflict with a variable defined in another if or while block that is not a child or a parent of the block that defined it.

Assign Statement
( '+=' ) | ( '-=' ) | ( '*=' ) | ( '/=' ) | ( '%=' )          ::= ([ '.'] ) ( '[' ']')

An assignment statement calculates the results of the expression to the left of the assignment operator, and variable referred to by the l-value, and either assigns the result to the l-value, or modifies the l-value by the result.

Return Statement
'Return' [ ]

The return statement immediately stops running the function, calculates the result of the expression (if it exists), and returns it to the caller. The type the expression resolves to must match the return type of the function. If the function has no return type, then just use a return statement with no expression. If a function with a return type exits without a return statement, then None will be return (and a warning printed by the game if None is not allowed to be assigned to the return type)

If Statement
*                   ['elseif' *]*                   ['else' *]                   'endIf'

The if statement calculates its expression and, if the result is true, runs the statements underneath it until it runs into an "elseif", "else", or "endif". If the expression's result is false, then it jumps down the if, checking each "elseif" as well until it hits an "else" (which then runs its statements) or an "endif". At each "elseif" encountered, it will check the expression and, if true, run the statements under it and if false, will jump to the next "elseif", "else", or "endIf".

While Statement
'while' * 'endWhile'

The while statement is a loop and will repeatedly execute the statements inside it until the expression is false.

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