SetScript

From GECK
Jump to: navigation, search


A function added by the Fallout Script Extender.

Description

Sets the specified Script onto the specified BaseForm, and returns any previous script. If ScriptableObject is omitted and a calling reference is provided, that reference's BaseForm is modified.

Syntax

[help]
(previousScript:baseForm) reference.SetScript NewScript:baseForm ScriptableObject:baseForm 

Example

ref OldScript

set OldScript to SunnyREF.SetScript MyNewSunnyScript

; or (required if used for non-reference)

SetScript MyNewSunnyScript, SunnyREF

Warning

  • If the target object already has a script attached to it, after changing the script the stored values of local variables for references to that object will not match the variables in the new script. If called on a reference, the variable list for the calling reference will be updated to match the new script, but other references to the same base object will not be updated.
  • When changing the script of a Base Form, the references created from it will retain the original script until the game loads again. You can run SetScript in a MenuMode 4 block so that the base form's script is updated before references are loaded from it.
    • If a reference is passed, the script that reference uses will be refreshed instantly.
  • SetScript is safe to use with quests, with previously unscripted objects, and on unique references (for which no other references exist to the same base object). Using the command on base objects for which non-unique references exist may result in undefined behavior.

See Also