WorldEditorAPI Usage – Arma Reforger
Lou Montana (talk | contribs) m (Fix) |
Lou Montana (talk | contribs) (Add Native Type Array section) |
||
Line 117: | Line 117: | ||
worldEditorAPI.SetVariableValue(myEntitySource, null, "m_sVariable", sValue); // no .ToString() for string | worldEditorAPI.SetVariableValue(myEntitySource, null, "m_sVariable", sValue); // no .ToString() for string | ||
worldEditorAPI.SetVariableValue(myEntitySource, null, "m_vVariable", vValue.ToString(false)); // .ToString(false) to write it as "0 1 2" and not "<0, 1, 2>" | worldEditorAPI.SetVariableValue(myEntitySource, null, "m_vVariable", vValue.ToString(false)); // .ToString(false) to write it as "0 1 2" and not "<0, 1, 2>" | ||
</enforce> | |||
==== Native Type Array ==== | |||
The {{hl|SetVariableValue}} method is used, setting values with separating commas: | |||
<enforce> | |||
worldEditorAPI.SetVariableValue(myEntitySource, null, "m_aBoolArray", "0,1,0,0,1,1,0,0,0,1,1,0,1,1,1,1,0,1,1,1,0,1,0,1"); | |||
worldEditorAPI.SetVariableValue(myEntitySource, null, "m_aFloatArray", "1.1,2,3.14159"); | |||
worldEditorAPI.SetVariableValue(myEntitySource, null, "m_aIntArray", "1,2,3,4,5,6,-10"); | |||
worldEditorAPI.SetVariableValue(myEntitySource, null, "m_aStringArray", "value1,value2,value3"); // note: commas cannot be escaped, making string with commas NOT supported | |||
worldEditorAPI.SetVariableValue(myEntitySource, null, "m_aVectorArray", "0 1 0,0 0 1,1 0 0"); | |||
</enforce> | </enforce> | ||
Line 193: | Line 203: | ||
</enforce> | </enforce> | ||
<!-- | <!-- | ||
== Terrain Actions == | == Terrain Actions == | ||
Revision as of 13:28, 13 June 2024
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.
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