WorldEditorAPI Usage – Arma Reforger
Lou Montana (talk | contribs) m (Some wiki formatting) |
Lou Montana (talk | contribs) m (Text replacement - "\{\{GameCategory\|armaR\|Modding\|(Guidelines|Tutorials)\|([^=↵]*)\}\}" to "{{GameCategory|armaR|Modding|$2|$1}}") |
||
Line 206: | Line 206: | ||
{{GameCategory|armaR|Modding | {{GameCategory|armaR|Modding|Scripting|Workbench|Tutorials}} |
Latest revision as of 13:31, 26 February 2025
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.
Do | Don't |
---|---|
Get WorldEditorAPI as a method variable where needed:
|
Store WorldEditorAPI as a class pointer: |
Prefab Actions
Prefab actions allow editing Prefabs automatically, with or without user input.
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:
Native Type Array
The SetVariableValue method is used, setting values with separating commas:
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