Category: Script
Since engine version: 9.0 OC
AddFunctions
Description
Adds several functions to the calling context, by calling AddFunction on each item in the array.
Syntax
nil AddFunctions(array functions, bool override);
Parameters
- functions:
- These functions will be added. Each item may come from a different source.
- override:
- [opt] Overriding an existing function in the target context is not allowed and will lead to a FatalError if this is set to
false
(default). This is not checked beforehand, but only when the function is being added, so other functions may have already been added, but you receive an error only on the first function that already exists.
Remark
When using this function be sure that you know what you are doing. Replacing functions can have unintended side effects.
Example
// Make a specific rock explode if it hits with high velocity! var boom = CreateObject(Rock); boom->AddFunctions([Firestone.Hit, Firestone.Hit2, Firestone.Fuse], true);
This script makes a rock behave like a firestone. Note that Rock already has a function Hit(), therefore the override parameter is set to true, or the function reports an error.
See also: AddFunction, GetFunctionName