Mod:Creation Kit/CallFunction - ScriptObject

Member of: Mod:Creation Kit/ScriptObject Script

Calls a function on this script synchronously and returns whatever that function does.

Syntax
Var Function CallFunction(string asFuncName, Var[] aParams) native

Parameters

 * asFuncName: The name of the function to call
 * aParams: The list of parameters to pass

Return Value
Whatever the function returns.

Examples
ScriptObject coldScript = FormFromOtherMod.CastAs("CommonCold") Var result = coldScript.CallFunction("NumberOfInfections", new Var[0]) int count = result as int if (count > 10000) Debug.Trace("Someone should probably make some chicken soup...") endIf ScriptObject coldScript = FormFromOtherMod.CastAs("CommonCold") Var[] params = new Var[1] params[0] = Game.GetPlayer as Form ; Must cast as form by hand, even though actor is derived from form coldScript.CallFunction("Infect", params)
 * Call "int Function NumberOfInfections" on script "CommonCold" and make a choice based on the return value
 * We use CastAs to make sure we don't depend on the script we want to call the function on
 * Call "Function Infect(Form aTarget)" on script "CommonCold"
 * We use CastAs to make sure we don't depend on the script we want to call the function on