Inline Expression

From GECK
Jump to: navigation, search

Inline expressions are a new scripting feature added by xNVSE 6.1.0.


NVSE has its own compiler different from the GECK's that's usually only activated in commands that support NVSE expressions. The NVSE compiler is a lot more flexible than the limited GECK compiler: it supports more operators, arrays and string variables natively. A major pain point for scripters was that when passing arguments to functions you were required to first place the expression inside a variable before being able to pass it as an argument.

Compiles pre-xNVSE 6.1.0

let fTemp := Player.GetActorValue Health + 50
Player.SetActorValue Health fTemp

Doesn't compile pre-xNVSE 6.1.0

Player.SetActorValue Health (Player.GetActorValue Health + 50)

This has now been remedied by inline expressions, which allow you to emplace NVSE expressions inside parenthesis when passing arguments to functions. This also means you get all the benefits of the NVSE compiler while programming inside inline expressions, including array support and using string concatenation operator for example.

Compiles with xNVSE 6.1.0

Player.SetName (arStringsFirstNames[iCurIdx] + " " + arStringsLastNames[iCurIdx])

Inline expressions have no performance cost and can in some cases even increase performance of your script.

Notes

  • A single line of GECK script is limited to 512 characters. This is not specific to Lambdas and Inline Expressions, but is more likely to be encountered due to their nature.
    • Calling a full UDF can be used to get around this limit. If you wish to have a script that doesn't rely on an ESP/ESM-added UDF, you may instead use CompileScript.

See Also