Category: Objects
/ Status
Since engine version: 1.0 OC
ChangeDef
Description
Assigns a new definition to an object.
Syntax
bool ChangeDef(id new_def);
Parameter
- new_def:
- id of the new definition.
Remarks
ChangeDef does not affect object local variables. The values of named local variables are transferred to local variables of the same name in the target definition.
Warning: if an object applies ChangeDef to itself, the executed object script will no longer match the object definition after the call. Because of this, following a ChangeDef call you should neither call any local function (use this()->function(...) instead) nor access any local variables (even if a variable of the same name exists in the new definition).
Example
GetCursor(0)->ChangeDef(Wipf);
Changes the selected clonk of the first player into a wipf.
See also: GetID