WorldEditorAPI Usage – Arma Reforger
World Editor API allows for plugin/tool world operations like obtaining terrain resolution, but mostly for Prefab operations such as editing and saving a Prefab (called Entity Template in the API for historical reason – hence the .et extension) using BaseContainer references.
General Usage
Game classes such as WorldEditorAPI, ScriptEditor etc must not be a strong ref script-side; on scripts reload, these references are not nulled and could point to anything.
Prefab Actions
Prefab actions allow editing Prefabs automatically, with or without user input.
{{Feature|important|
Editing a BaseContainer using .Set* methods does not modify the Prefab itself; it modifies the spawned entity itself.
Proper Prefab editing always happens in WorldEditorAPI methods, such as:
Get Prefab
Set Value
values are set as string through WorldEditorAPI in .et files. For example, a true bool value will be represented as 1 in a .et file, therefore "1" must be provided (see bool.ToString(true) for more information).
Direct Value
The SetVariableValue method is used:
Object Creation
Two cases are identified: the object can either be a direct object property or an array item.
In the first case (direct object property), the CreateObjectVariableMember method must be used:
In the second case (array element), the CreateObjectArrayVariableMember method is used:
Object Value
To set an object's value, the path parameter, an array of ContainerIdPathEntry must be used:
An array item is accessed using the ContainerIdPathEntry's index parameter, to determine which item is targeted
A component is accessed the same way - using the "components" path:
Delete Value
An array cannot be deleted this way. All its items should be removed through RemoveObjectArrayVariableMember usage instead:
Save Changes
Simply use the following:
Helpers
See also:
- SCR_WorldEditorToolHelper - a helper for WorldEditor/WorldEditorAPI usage
- SCR_PrefabHelper - a helper for various tools's Prefab management