CompileScript

From GECK
Jump to: navigation, search


A function added by the New Vegas Script Extender version 6.3.3.

Description

Returns a compiled script from a text file pointed by the path arg. The path arg is relative to "data/nvse/user_defined_functions/..".

If it was formatted like a UDF, then the returned script can be used like a regular UDF, meaning it can be passed to functions like Call.

  • This makes it a great way to store long lines of code that wouldn't fit in a Lambda due to the line character limit.
    • Of course, it's only useful if you're running scripts without wanting to use an esp/esm file that could store an actual UDF.

The compiled script is cached for performance, so it won't be recompiled after the first call.
To "hot-reload" and recompile the script to account for mid-game changes, likely for testing purposes, set forceRecompile to 1.

Syntax

[help]
(script:form) CompileScript path:string forceRecompile:bool{0} 

Or:

(script:form) GetUDFFromFile path:string forceRecompile:bool{0} 

Example

Here is what my example script text file, "TestReturnRefUDF.txt" contains:

begin Function { ref rRefToReturn }

    print "Test UDF ran!"
    printvar rRefToReturn

end

This text file is placed at this path:

"data/nvse/user_defined_functions/SomeSubFolder/TestReturnRefUDF.txt"

To compile this text file UDF and test it, this can be done in script:

ref rUDF = CompileScript "SomeSubFolder/TestReturnRefUDF.txt"
printvar rUDF
call rUDF SunnyREF  ; should see a SunnyREF print in console

See Also