Difference between revisions of "SetScript"

From the Fallout3 GECK Wiki
Jump to navigation Jump to search
imported>Geckbot
(Automated import of articles)
 
imported>Odessa
(expanded. sources: gribbleshnibbit, me.)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
'''SetScript'''
{{Function
{{Function
  |origin = FOSE1
  |origin = FOSE1
  |summary = Sets the script of the reference or passed object.
  |summary = Sets the specified script onto the calling reference or passed object, and returns any previous script.  
 
  |name = SetScript
  |name = SetScript
  |returnType = ref
  |returnType = script:form
  |referenceType = ref
  |referenceType = ref
  |arguments =  
  |arguments =  
   {{FunctionArgument
   {{FunctionArgument
   |Name = scriptInRef
   |Name = NewScript
   |Type = ref
   |Type = script
   }}{{FunctionArgument
   }}{{FunctionArgument
   |Name = item
   |Name = ScriptableObject
   |Type = ref
   |Type = form
   |Optional = optional
   |Optional = optional
   }}
   }}
}}
}}
==Example==
<pre>
ref OldScript
set OldScript to SunnyREF.SetScript MyNewSunnyScript
; or (required if used for non-reference)
SetScript MyNewSunnyScript, SunnyREF
</pre>
==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.
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==
*[[GetScript]]
*[[ResetAllVariables]]
*[[CompareScripts]]
*[[GetCurrentScript]]
[[Category:Functions_(FOSE)]]
[[Category:Functions_(FOSE)]]
[[Category:Script Functions]]

Latest revision as of 06:20, 6 August 2014

< [[::Category:Functions|Category:Functions]]

A function added by the Fallout Script Extender.

Description

Sets the specified script onto the calling reference or passed object, and returns any previous script.

Syntax

[help]
(script:form) ref.SetScript NewScript:script ScriptableObject:form

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.

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