[DEV SERVER] Loading description...
Caveats
CK Wiki - Notes
- If the script doesn't exist, or isn't attached to the form in question the function will simply return None, just like a cast operation.
- Unlike a cast operation, you do not have to cast "down" the inheritance tree first. For example, it will let you cast from "ScriptA" directly to "ScriptB" if they are attached to the same form, even if you would normally have to go through "ObjectReference".
- If two copies of the same script are attached to the same form, it is undefined which one you will get. For example, if both "ScriptA" and "ScriptB" are attached to a reference, both inheriting from "ObjectReference" and you pass "ObjectReference" as the parameter to CastAs, which script you actually get is effectively random.
- The compiler cannot check the script name for you, so make sure to triple check everything!
Parameters
stringasScriptName
CK Wiki Description
The script to cast to
Examples
; Call "Function MakeACake()" on script "Latrop"
; We use CastAs to make sure we don't depend on the script we want to call the function on
ScriptObject latropScript = FormFromOtherMod.CastAs("Latrop")
if latropScript ; make sure the cast succeeded
latropScript.CallFunction("MakeACake", new Var[0])
endIfAuto-Generated Example
string myString__asScriptName
ScriptObject returnedValue = myScriptObject__toCallFunctionOn.CastAs(myString__asScriptName)Related Pages
Additional References
View this function’s page on the Fallout 4 Creation Kit Wiki
