Eden Editor Event Handlers – Arma 3

From Bohemia Interactive Community
Jump to navigation Jump to search
(typo)
(Note about none of the entity specific event handlers working for triggers)
 
(44 intermediate revisions by 7 users not shown)
Line 1: Line 1:
__NOEDITSECTION__
__NOEDITSECTION__
[[Eden Editor]] event handlers. When added, they will remain until Eden Editor is closed. Playing preview will not erase them.
{{TOC|side}}
== Editor Event Handlers ==


{{Horizontoc|include=3|also=nonumtoc}}
[[:Category:Eden Editor|Eden Editor]] Event Handlers are added to the editor instance and will remain active for the duration of a session.
Launching a preview will keep the event handlers, but closing the editor will erase all of them and you will have to add them again on the next Eden instance.


== Editor Event Handlers ==
=== Related commands ===
Editor handlers are added to the editor instance and will remain active for the duration of a session. Launching a preview won't erase them, but leaving to main menu will close the editor and erase all handlers with it.


=== Scripting ===
Commands:
* [[add3DENEventHandler]]
* [[add3DENEventHandler]]
* [[remove3DENEventHandler]]
* [[remove3DENEventHandler]]


'''Example:'''
=== Event Scripts ===
add3DENEventHandler ["onUndo",{[[hint]] "Undo";}]
 
* See [[Event Scripts#init3DEN.sqf|init3DEN.sqf]]


=== Config ===
=== Config ===
Alternatively, you can define event handlers directly in the config. Use your custom section (<span style="color:green;">mySection</span> in the example) to prevent overriding handlers from other sources.
Handlers defined here will be added automatically when Eden Editor is opened.
class Cfg3DEN
{
class EventHandlers
{
class <span style="color:green;">mySection</span>
{
onUndo = "hint 'Undo';";
{{codecomment|// <handlerName> <nowiki>=</nowiki> <handlerExpression>}}
};
};
};


=== List ===
Alternatively, you can define event handlers directly in the config.
Most handlers don't receive any arguments. That is intended, because in most cases, required data can be obtained either using [[get3DENActionState]], or by specialized 'get' commands.
Use your custom section ('''{{Color|#00F|mySection}}''' in the example) to prevent overriding handlers from other sources.
{| class="wikitable sortable"
Handlers defined here will automatically be added when Eden Editor is opened.
! Class
<syntaxhighlight lang="cpp">
! class="unsortable" | Description
class Cfg3DEN
! class="unsortable" | Arguments
{
|-
class EventHandlers
| <!-- Title -->
{
class mySection
{
onUndo = "hint 'Undo';";
// <handlerName> = <handlerExpression>
};
};
};
</syntaxhighlight>
 
=== Events ===
The following [[Magic Variables]] are available inside the event's code:
* Event Handler parameters are accessible via <sqf inline>_this</sqf> (only if event has parameters)
* The Event Handler type is available as <sqf inline>_thisEvent</sqf>
* The Event Handler index is available as <sqf inline>_thisEventHandler</sqf>
 
{{Feature|informative|
* Most handlers do not receive any arguments; this is intended, as in most cases required data can be obtained using either [[get3DENActionState]] or specialised 'get*' [[:Category:Command Group: Eden Editor|Eden Editor commands]].
* Note that unlike [[Arma 3: Event Handlers|object's]] or [[Arma 3: Mission Event Handlers|mission's]] event handlers, the '''On''' prefix is present in both config and command event name.
}}
 
{{ConfigPage|start}}
{{ConfigPage|abc}}
==== Init ====
Is executed when [[Eden Editor]] display was created. Only happens when Eden Editor is opened for the first time during game session.
<sqf>
add3DENEventHandler ["Init", {
params ["_display3DEN"];
}];
</sqf>
 
* display3DEN: [[Display]]
 
{{ArgTitle|4|OnBeforeMissionPreview|{{GVI|arma3|2.18}}}}
Runs before the scenario preview is started. If an event handler of this type returns [[true]], the mission preview will not be initialised.
<sqf>
add3DENEventHandler ["OnBeforeMissionPreview", {
params ["_isPreviewMultiplayer"];
}];
</sqf>
 
==== OnConnectingStart ====
==== OnConnectingStart ====
| <!-- Description -->
When [[Eden Editor: Connecting|Connecting]] operation is initiated.
When [[Eden_Editor:_Connecting|Connecting]] operation is initiated.
<sqf>
| <!-- Arguments -->
add3DENEventHandler ["OnConnectingStart", {
[<class>,<from>]
params ["_class", "_from"];
}];
</sqf>
 
* class: [[Config]] - connection config class
* class: [[Config]] - connection config class
* from: [[Array of Eden Entities]]
* from: [[Array of Eden Entities]]
|-
 
| <!-- Title -->
 
==== OnConnectingEnd ====
==== OnConnectingEnd ====
| <!-- Description -->
When [[Eden Editor: Connecting|Connecting]] operation is terminated, no matter if it was confirmed or canceled.
When [[Eden_Editor:_Connecting|Connecting]] operation is terminated, no matter if it was confirmed or canceled.
<sqf>
| <!-- Arguments -->
add3DENEventHandler ["OnConnectingEnd", {
[<class>,<from>,<to>]
params ["_class", "_from", "_to"];
}];
</sqf>
 
* class: Config - connection config class
* class: Config - connection config class
* from: Array of 3DEN entities
* from: Array of 3DEN entities
* to: [[Eden Entity]] (when connecting was successful) or nil (when connecting was terminated)
* to: [[Eden Entity]] (when connecting was successful) or [[nil]] (when connecting was terminated)
|-
 
| <!-- Title -->
 
==== OnCopy ====
==== OnCopy ====
| <!-- Description -->
Fires when entities are copied.<br>
When entities are copied.
Also fires when entities are cut, but unlike {{Link|#OnCut}}, {{Link|#OnCopy}} fires before the entities are deleted, meaning the entities are still accessible with [[get3DENSelected]].
| <!-- Arguments -->
<sqf>
''None''
add3DENEventHandler ["OnCopy", {
|-
// no arguments
| <!-- Title -->
}];
</sqf>
 
 
==== OnCut ====
==== OnCut ====
| <!-- Description -->
Fires when entities are cut (after the entities have been deleted).
When entities are cut.
<sqf>
| <!-- Arguments -->
add3DENEventHandler ["OnCut", {
''None''
// no arguments
|-
}];
| <!-- Title -->
</sqf>
 
 
==== OnDeleteUnits ====
==== OnDeleteUnits ====
| <!-- Description -->
When entities are deleted.
When entities are deleted.
| <!-- Arguments -->
<sqf>
''None''
add3DENEventHandler ["OnDeleteUnits", {
|-
// no arguments
| <!-- Title -->
}];
</sqf>
 
 
{{ArgTitle|4|OnEditableEntityAdded|{{GVI|arma3|2.18}}}}
When an entity gets added to the scenario. When compositions are added, the event triggers for every entity in the composition.
<sqf>
add3DENEventHandler ["OnEditableEntityAdded", {
params ["_entity"];
}];
</sqf>
 
entity - [[Eden Entity]]
 
{{ArgTitle|4|OnEditableEntityRemoved|{{GVI|arma3|2.18}}}}
When an entity gets removed from the scenario.
<sqf>
add3DENEventHandler ["OnEditableEntityRemoved", {
params ["_entity"];
}];
</sqf>
 
entity - [[Eden Entity]]
 
{{ArgTitle|4|OnEntityAttributeChanged|{{GVI|arma3|2.18}}}}
When an entity's attribute got changed. Fires for each changed attribute separately.
<sqf>
add3DENEventHandler ["OnEditableEntityAttributeChanged", {
params ["_entity", "_property"];
}];
</sqf>
* entity: [[Eden Entity]]
* property: [[String]] - property name of the attribute that was changed
 
{{ArgTitle|4|OnEntityDragged|{{GVI|arma3|2.18}}}}
When an entity gets dragged. Fires continiously until the left mouse button is released.
<sqf>
add3DENEventHandler ["OnEntityDragged", {
params ["_entity"];
}];
</sqf>
 
entity - [[Eden Entity]]
 
==== OnEntityMenu ====
==== OnEntityMenu ====
| <!-- Description -->
When [[Eden Editor: Entity Context Menu|Entity Context Menu]] is opened.
When [[Eden_Editor:_Entity_Context_Menu|Entity Context Menu]] is opened.
<sqf>
| <!-- Arguments -->
add3DENEventHandler ["OnEntityMenu", {
[position, entity, listPath]
params ["_position", "_entity", "_listPath"];
}];
</sqf>
 
* position: [[Array]] - [[Position]] where user clicked to open the menu.
* position: [[Array]] - [[Position]] where user clicked to open the menu.
** Entity position when clicked on an entity.
** Entity position when clicked on an entity.
** Empty array when clicked on something that doesn't have position (i.e., abstract folder in Edit list like BLUFOR, Trigger, etc.)
** Empty array when clicked on something that doesn't have position (i.e. abstract folder in Edit list like BLUFOR, Trigger, etc.)
* entity: [[Eden Entity]]
* entity: [[Eden Entity]]
** Nil when clicked on empty space
** Nil when clicked on empty space
* listPath: [[Array]] - UI tree path when clicked on entity in the [[Eden Editor: Entity List|Entity List]].
* listPath: [[Array]] - UI tree path when clicked on entity in the entity list.
** Nil when clicked in the scene (we cannot use empty array, because that's a path to root item)
** Nil when clicked in the scene (we cannot use empty array, because that's a path to root item)
|-
 
| <!-- Title -->
 
{{ArgTitle|4|OnEntityParentChanged|{{GVI|arma3|2.18}}}}
Fires when the parent of an entity changes. For example, creating waypoints, moving entities into layers or out of layers.
It seems that this EH always fires twice. First event returns [[objNull]] for _newParentEntityID.
<sqf>
add3DENEventHandler ["OnEntityParentChanged", {
params ["_affectedEntity", "_newParentEntityID"]
}];
</sqf>
 
* affectedEntity: [[Array]], [[Object]], [[String]], [[Number]]
** [[Array]] - waypoint
** [[Object]] - trigger, unit, vehicle, logic
** [[String]] - marker
** [[Number]] - layer
* newParentEntityID: [[Number]] or [[objNull]]
** [[Number]]- the new parent entity
** [[objNull]] - If new parent entity is a system layer.
 
==== OnGridChange ====
==== OnGridChange ====
| <!-- Description -->
When grid changes, either using [[Eden Editor: Toolbar|Toolbar]] option, ot by scripting command [[set3DENGrid]].
When grid changes, either using [[Eden Editor: Toolbar|Toolbar]] option, ot by scripting command [[set3DENGrid]].
| <!-- Arguments -->
<sqf>
[gridType, gridValue]
add3DENEventHandler ["OnGridChange", {
params ["_gridType", "_gridValue"];
}];
</sqf>
 
* gridType: [[String]] - can be "translation", "rotation" or "scaling"
* gridType: [[String]] - can be "translation", "rotation" or "scaling"
* gridValue: [[Number]]
* gridValue: [[Number]]
|-
 
| <!-- Title -->
 
==== OnHistoryChange ====
When history changes.
<sqf>
add3DENEventHandler ["OnHistoryChange", {
// no arguments
}];
</sqf>
 
 
==== OnMapClosed ====
==== OnMapClosed ====
| <!-- Description -->
When map is closed.
When map is closed.
| <!-- Arguments -->
<sqf>
''None''
add3DENEventHandler ["OnMapClosed", {
|-
// no arguments
| <!-- Title -->
}];
</sqf>
 
 
==== OnMapOpened ====
==== OnMapOpened ====
| <!-- Description -->
When map is opened.
When map is opened.
| <!-- Arguments -->
<sqf>
''None''
add3DENEventHandler ["OnMapOpened", {
|-
// no arguments
| <!-- Title -->
}];
</sqf>
 
 
==== OnMessage ====
==== OnMessage ====
| <!-- Description -->
Handler used for showing on-screen notifications, triggered by various range of events.
Handler used for showing on-screen notifications, triggered by various range of events.
Message IDs:
Message IDs:
*0 - Mission saved
* 0 - Mission saved
*1 - Mission autosaved
* 1 - Mission autosaved
*2 - Trying to move a character into full vehicle
* 2 - Trying to move a character into full vehicle
*3 - Moved character into enemy vehicle
* 3 - Moved character into enemy vehicle
*4 - Trying to run mission without any player
* 4 - Trying to run mission without any player
*5 - Mission exported to SP
* 5 - Mission exported to SP
*6 - Mission exported to MP
* 6 - Mission exported to MP
*7 - Attempting to delete a default layer
* 7 - Attempting to delete a default layer
| <!-- Arguments -->
<sqf>
[messageID]
add3DENEventHandler ["OnMessage", {
params ["_messageID"];
}];
</sqf>
 
* messageID: [[Number]]
* messageID: [[Number]]
|-
 
| <!-- Title -->
 
{{ArgTitle|4|OnMissionAttributeChanged|{{GVI|arma3|2.18}}}}
When a mission attribute or the preferences are changed.
<sqf>
add3DENEventHandler ["OnMissionAttributeChanged", {
params ["_section", "_property"];
}];
</sqf>
 
* section - [[String]] - section name, see [[Eden_Editor:_Setting_Attributes#Sections_.26_Properties|sections]]
* property - [[String]] - property name of the attribute, see [[Eden_Editor:_Setting_Attributes#Sections_.26_Properties|properties]]
 
 
==== OnMissionAutosave ====
==== OnMissionAutosave ====
| <!-- Description -->
When scenario is autosaved.
When scenario is autosaved.
| <!-- Arguments -->
<sqf>
''None''
add3DENEventHandler ["OnMissionAutosave", {
|-
// no arguments
| <!-- Title -->
}];
</sqf>
 
==== OnMissionExportSP ====
When a scenario is exported to singleplayer.
<sqf>
add3DENEventHandler ["OnMissionExportSP", {
// no arguments
}];
</sqf>
 
 
==== OnMissionExportMP ====
When a scenario is exported to multiplayer.
<sqf>
add3DENEventHandler ["OnMissionExportMP", {
// no arguments
}];
</sqf>
 
 
==== OnMissionListChange ====
When the current list of missions in the open/save mission dialog changes, i.e when first opened or a different folder is selected.
<sqf>
add3DENEventHandler ["OnMissionListChange", {
// no arguments
}];
</sqf>
 
 
==== OnMissionLoad ====
==== OnMissionLoad ====
| <!-- Description -->
When scenario is loaded.
When scenario is loaded.
| <!-- Arguments -->
 
''None''
If a missing config is preventing the scenario from being loaded, this event handler will only be executed after pressing the "Force Load" button.
|-
<sqf>
| <!-- Title -->
add3DENEventHandler ["OnMissionLoad", {
// no arguments
}];
</sqf>
 
 
==== OnMissionNew ====
==== OnMissionNew ====
| <!-- Description -->
When new scenario is started. Executed also when Eden is opened with an empty scenario.
When new scenario is started. Executed also when Eden is opened with an empty scenario.
| <!-- Arguments -->
<sqf>
''None''
add3DENEventHandler ["OnMissionNew", {
|-
// no arguments
| <!-- Title -->
}];
</sqf>
 
 
==== OnMissionPreview ====
==== OnMissionPreview ====
| <!-- Description -->
When scenario preview is started. Executed when the scenario is already loaded, so entities in it can be accessed.
When scenario preview is started. Executed when the scenario is already loaded, so entities in it can be accessed.
| <!-- Arguments -->
<sqf>
[objects, groups, waypoints, markers]
add3DENEventHandler ["OnMissionPreview", {
params ["_objects", "_groups", "_waypoints", "_markers"];
}];
</sqf>
 
* objects: Array
* objects: Array
* groups: Array
* groups: Array
Line 166: Line 335:
* entity: [[Object]], [[Group]], [[Array]] or [[String]]
* entity: [[Object]], [[Group]], [[Array]] or [[String]]
* ID: [[Number]]
* ID: [[Number]]
|-
 
| <!-- Title -->
 
==== OnMissionPreviewEnd ====
==== OnMissionPreviewEnd ====
| <!-- Description -->
When preview ends and user returns back to Eden Editor.
When preview ends and user returns back to Eden Editor.
| <!-- Arguments -->
<sqf>
''None''
add3DENEventHandler ["OnMissionPreviewEnd", {
|-
// no arguments
| <!-- Title -->
}];
</sqf>
 
 
==== OnMissionSave ====
==== OnMissionSave ====
| <!-- Description -->
When scenario is saved.
When scenario is saved.
| <!-- Arguments -->
<sqf>
''None''
add3DENEventHandler ["OnMissionSave", {
|-
// no arguments
| <!-- Title -->
}];
</sqf>
 
 
==== OnMissionSaveAs ====
==== OnMissionSaveAs ====
| <!-- Description -->
When ''Save As'' action is triggered (i.e. Save window is opened, but the mission is not necessarily saved yet).
When ''Save As'' action is triggered (i.e., Save window is opened, but the mission is not necessarily saved yet).
<sqf>
| <!-- Arguments -->
add3DENEventHandler ["OnMissionSaveAs", {
''None''
// no arguments
|-
}];
| <!-- Title -->
</sqf>
 
 
==== OnModeChange ====
==== OnModeChange ====
| <!-- Description -->
When editing mode is changed (i.e. from Objects to Triggers).
When editing mode is changed (i.e., from Objects to Triggers).
<sqf>
| <!-- Arguments -->
add3DENEventHandler ["OnModeChange", {
''None''
// no arguments
|-
}];
| <!-- Title -->
</sqf>
 
 
==== OnMoveGridDecrease ====
 
{{Wiki|TODO}}
<sqf>
add3DENEventHandler ["OnMoveGridDecrease", {
// params ["?"];
}];
</sqf>
 
 
==== OnMoveGridIncrease ====
 
{{Wiki|TODO}}
<sqf>
add3DENEventHandler ["OnMoveGridIncrease", {
// params ["?"];
}];
</sqf>
 
 
==== OnMoveGridToggle ====
==== OnMoveGridToggle ====
| <!-- Description -->
When '''translation''' grid is toggled on or off.
When '''translation''' grid is toggled on or off.
| <!-- Arguments -->
<sqf>
''None''
add3DENEventHandler ["OnMoveGridToggle", {
|-
// no arguments
| <!-- Title -->
}];
</sqf>
 
 
==== OnPaste ====
==== OnPaste ====
| <!-- Description -->
When entities are pasted.
When entities are pasted.
| <!-- Arguments -->
<sqf>
''None''
add3DENEventHandler ["OnPaste", {
|-
// no arguments
| <!-- Title -->
}];
</sqf>
 
 
==== OnPasteUnitOrig ====
==== OnPasteUnitOrig ====
| <!-- Description -->
When entities are pasted on their original positions.
When entities are pasted on their original positions.
| <!-- Arguments -->
<sqf>
''None''
add3DENEventHandler ["OnPasteUnitOrig", {
|-
// no arguments
| <!-- Title -->
}];
</sqf>
 
 
==== OnRedo ====
==== OnRedo ====
| <!-- Description -->
When undo operation is redone.
When undo operation is redone.
| <!-- Arguments -->
<sqf>
''None''
add3DENEventHandler ["OnRedo", {
|-
// no arguments
| <!-- Title -->
}];
</sqf>
 
 
==== OnRotateGridDecrease ====
{{Wiki|TODO}}
<sqf>
add3DENEventHandler ["OnRotateGridDecrease", {
// params ["?"];
}];
</sqf>
 
 
==== OnRotateGridIncrease ====
{{Wiki|TODO}}
<sqf>
add3DENEventHandler ["OnRotateGridIncrease", {
// params ["?"];
}];
</sqf>
 
 
==== OnRotateGridToggle ====
==== OnRotateGridToggle ====
| <!-- Description -->
When '''rotation''' grid is toggled on or off.
When '''rotation''' grid is toggled on or off.
| <!-- Arguments -->
<sqf>
''None''
add3DENEventHandler ["OnRotateGridToggle", {
|-
// no arguments
| <!-- Title -->
}];
</sqf>
 
 
==== OnScaleGridToggle ====
==== OnScaleGridToggle ====
| <!-- Description -->
When '''area scaling''' grid is toggled on or off.
When '''area scaling''' grid is toggled on or off.
| <!-- Arguments -->
<sqf>
''None''
add3DENEventHandler ["OnScaleGridToggle", {
|-
// no arguments
| <!-- Title -->
}];
</sqf>
 
 
==== OnSearchCreate ====
==== OnSearchCreate ====
| <!-- Description -->
When "SearchCreate" action is triggered (e.g. when pressing Ctrl+Shift+F).
When "SearchCreate" action is triggered (e.g., when pressing Ctrl+Shift+F).
<sqf>
| <!-- Arguments -->
add3DENEventHandler ["OnSearchCreate", {
''None''
// no arguments
|-
}];
| <!-- Title -->
</sqf>
 
 
==== OnSearchEdit ====
==== OnSearchEdit ====
| <!-- Description -->
When "SearchEdit" action is triggered (e.g. when pressing Ctrl+F).
When "SearchEdit" action is triggered (e.g., when pressing Ctrl+F).
<sqf>
| <!-- Arguments -->
add3DENEventHandler ["OnSearchEdit", {
''None''
// no arguments
|-
}];
| <!-- Title -->
</sqf>
 
 
==== OnSelectionChange ====
When entity selection changes. Use [[get3DENSelected]] to return currently selected entities.
<sqf>
add3DENEventHandler ["OnSelectionChange", {
// no arguments
}];
</sqf>
 
 
==== OnServerToggle ====
==== OnServerToggle ====
| <!-- Description -->
When server is created or destroyed from the preview.
When server is created or destroyed from the preview.
| <!-- Arguments -->
<sqf>
''None''
add3DENEventHandler ["OnServerToggle", {
|-
// no arguments
| <!-- Title -->
}];
</sqf>
 
 
==== OnSubmodeChange ====
==== OnSubmodeChange ====
| <!-- Description -->
When submode (e.g. BLUFOR or OFPOR for Objects, or Modules for Systems) changes.
When submode (e.g., BLUFOR or OFPOR for Objects, or Modules for Systems) changes.
<sqf>
| <!-- Arguments -->
add3DENEventHandler ["OnSubmodeChange", {
''None''
// no arguments
|-
}];
| <!-- Title -->
</sqf>
 
 
==== OnSurfaceSnapToggle ====
==== OnSurfaceSnapToggle ====
| <!-- Description -->
When surface snap settings are changed.
When surface snap settings are changed.
| <!-- Arguments -->
<sqf>
''None''
add3DENEventHandler ["OnSurfaceSnapToggle", {
|-
// no arguments
| <!-- Title -->
}];
</sqf>
 
 
==== OnTerrainNew ====
==== OnTerrainNew ====
| <!-- Description -->
When new terrain is loaded. Executed also when Eden is opened.
When new terrain is loaded. Executed also when Eden is opened.
| <!-- Arguments -->
<sqf>
''None''
add3DENEventHandler ["OnTerrainNew", {
|-
// no arguments
| <!-- Title -->
}];
</sqf>
 
 
==== OnToggleMapIDs ====
When map IDs are toggled with <sqf inline>do3DENAction "ToggleMapIDs"</sqf>. Only triggers if map is open.
<sqf>
add3DENEventHandler ["OnToggleMapIDs", {
// no arguments
}];
</sqf>
 
 
==== OnToggleMapTextures ====
==== OnToggleMapTextures ====
| <!-- Description -->
When map textures are toggled on or off.
When map textures are toggled on or off.
| <!-- Arguments -->
<sqf>
''None''
add3DENEventHandler ["OnToggleMapTextures", {
|-
// no arguments
| <!-- Title -->
}];
</sqf>
 
 
==== OnTogglePlaceEmptyVehicle ====
When the ''Place vehicles with crew'' is toggled on/off in Objects mode.
<sqf>
add3DENEventHandler ["OnTogglePlaceEmptyVehicle", {
// no arguments
}];
</sqf>
 
 
==== OnUndo ====
==== OnUndo ====
| <!-- Description -->
When an operation is undone.
When an operation is undone.
| <!-- Arguments -->
<sqf>
''None''
add3DENEventHandler ["OnUndo", {
|-
// no arguments
| <!-- Title -->
}];
</sqf>
 
 
==== OnVerticalToggle ====
==== OnVerticalToggle ====
| <!-- Description -->
When vertical mode settings are changed.
When vertical mode settings are changed.
| <!-- Arguments -->
<sqf>
''None''
add3DENEventHandler ["OnVerticalToggle", {
|-
// no arguments
| <!-- Title -->
}];
</sqf>
 
 
==== OnWidgetArea ====
When [[Eden Editor: Transformation Widget|area widget]] is selected.
<sqf>
add3DENEventHandler ["OnWidgetArea", {
// no arguments
}];
</sqf>
 
 
==== OnWidgetNone ====
==== OnWidgetNone ====
| <!-- Description -->
When no [[Eden Editor: Transformation Widget|widget]] is selected.
When no [[Eden_Editor:_Transformation_Widget|widget]] is selected.
<sqf>
| <!-- Arguments -->
add3DENEventHandler ["OnWidgetNone", {
''None''
// no arguments
|-
}];
| <!-- Title -->
</sqf>
 
 
==== OnWidgetRotation ====
==== OnWidgetRotation ====
| <!-- Description -->
When [[Eden Editor: Transformation Widget|rotation widget]] is selected.
When '''rotation''' [[Eden_Editor:_Transformation_Widget|widget]] is selected.
<sqf>
| <!-- Arguments -->
add3DENEventHandler ["OnWidgetRotation", {
''None''
// no arguments
|-
}];
| <!-- Title -->
</sqf>
 
 
==== OnWidgetScale ====
==== OnWidgetScale ====
| <!-- Description -->
When [[Eden Editor: Transformation Widget|scaling widget]] is selected.
When '''area scaling''' [[Eden_Editor:_Transformation_Widget|widget]] is selected.
<sqf>
| <!-- Arguments -->
add3DENEventHandler ["OnWidgetScale", {
''None''
// no arguments
|-
}];
| <!-- Title -->
</sqf>
 
 
==== OnWidgetToggle ====
==== OnWidgetToggle ====
| <!-- Description -->
When [[Eden Editor: Transformation Widget|widget]] is toggled (i.e. browsing through all widget types)
When [[Eden_Editor:_Transformation_Widget|widget]] is toggled (i.e., browsing through all widget types)
<sqf>
| <!-- Arguments -->
add3DENEventHandler ["OnWidgetToggle", {
''None''
// no arguments
|-
}];
| <!-- Title -->
</sqf>
 
 
==== OnWidgetTranslation ====
==== OnWidgetTranslation ====
| <!-- Description -->
When [[Eden Editor: Transformation Widget|translation widget]] is selected.
When '''translation''' [[Eden_Editor:_Transformation_Widget|widget]] is selected.
<sqf>
| <!-- Arguments -->
add3DENEventHandler ["OnWidgetTranslation", {
''None''
// no arguments
|-
}];
| <!-- Title -->
</sqf>
 
 
==== OnWorkspacePartSwitch ====
==== OnWorkspacePartSwitch ====
| <!-- Description -->
When [[Eden Editor: Scenario Phases|scenario phase]] is selected.
When [[Eden_Editor:_Scenario_Phases|scenario phase]] is selected.
<sqf>
| <!-- Arguments -->
add3DENEventHandler ["OnWorkspacePartSwitch", {
''None''
// no arguments
|}
}];
</sqf>
{{ConfigPage|end}}




== Object Event Handlers ==
== Object Event Handlers ==
Editor specific event handlers can be also added directly to [[Eden Editor: Object|objects]], using [[addEventHandler]] command.


These handlers exist only for the duration of active workspace. Running a preview or loading the same scenario again will erase all object event handlers, because objects themselves are despawned from the world and then created again.
Editor specific event handlers can be also added directly to [[Eden Editor: Object|objects]], using [[addEventHandler]] command.<br>
{{Feature|important|These handlers exist only for the duration of active workspace.
Running a preview or loading the same scenario again will erase all object event handlers, because objects themselves are despawned from the world and then created again.}}


=== List ===
=== Related commands ===
Most handlers don't receive any arguments. That is intended, because in most cases, required data can be obtained either using [[get3DENActionState]], or by specialized 'get' commands.
 
{| class="wikitable sortable"
* [[addEventHandler]]
! Class
* [[removeEventHandler]]
! class="unsortable" | Description
 
! class="unsortable" | Arguments
=== Events ===
|-
 
| <!-- Title -->
{{Feature|informative|Most handlers do not receive any arguments.
This is intended, because in most cases, required data can be obtained using either [[get3DENActionState]] or specialised 'get' commands.}}
{{Feature|important|None of the following event handlers work for triggers.}}
 
{{ConfigPage|start}}
{{ConfigPage|abc}}
==== AttributesChanged3DEN ====
==== AttributesChanged3DEN ====
| <!-- Description -->
Fires when object's attributes are changed. Can happen when:
When object's attributes are changed. Can happen when moving or rotating the object, when changing its attributes in attributes window, or when some scripts change attributes using [[set3DENAttributes]] command.
* Changing the attributes by dragging, rotating or using one of the widgets
| <!-- Arguments -->
* Changing and saving the attributes from within the attributes window
[object]
* When attributes get changed using scripting commands such as [[set3DENAttributes]] or [[set3DENAttribute]]
Unlike ''Dragged3DEN'' this event handler will not fire continuously but only when the attributes were changed '''and''' saved
<sqf>
edenObject addEventHandler ["AttributesChanged3DEN", {
params ["_object"];
}];
</sqf>
 
* object: [[Object]] - affected object
* object: [[Object]] - affected object
|-
 
| <!-- Title -->
 
==== ConnectionChanged3DEN ====
==== ConnectionChanged3DEN ====
| <!-- Description -->
When a [[Eden Editor: Connecting|connection]] is added or removed from an object.
When a [[Eden Editor: Connecting|connection]] is added or removed from an object.
| <!-- Arguments -->
<sqf>
[object]
edenObject addEventHandler ["ConnectionChanged3DEN", {
params ["_object"];
}];
</sqf>
 
* object: [[Object]] - affected object
* object: [[Object]] - affected object
|-
 
| <!-- Title -->
 
==== RegisteredToWorld3DEN ====
==== RegisteredToWorld3DEN ====
| <!-- Description -->
When object is re-added to the scenario after undoing a delete operation.
When object is added to the scenario. That happens when you [[Eden Editor: Entity Placing|place]] it, but also when you paste it after copying, or when redoing placement operation after it was undone.
<sqf>
| <!-- Arguments -->
edenObject addEventHandler ["RegisteredToWorld3DEN", {
[object]
params ["_object"];
}];
</sqf>
 
* object: [[Object]] - affected object
* object: [[Object]] - affected object
|-
 
| <!-- Title -->
 
==== UnregisteredFromWorld3DEN ====
==== UnregisteredFromWorld3DEN ====
| <!-- Description -->
When object is removed from the scenario. That happens when you delete it, but also when you undo [[Eden Editor: Entity Placing|placement]] operation.
When object is removed from the scenario. That happens when you delete it, but also when you undo [[Eden Editor: Entity Placing|placement]] operation.
| <!-- Arguments -->
<sqf>
[object]
edenObject addEventHandler ["UnregisteredFromWorld3DEN", {
params ["_object"];
}];
</sqf>
 
* object: [[Object]] - affected object
* object: [[Object]] - affected object
|}


[[Category: Eden Editor|Event Handlers]]
 
==== Dragged3DEN ====
When object is '''dragged''' and/or '''rotated'''. Also triggers when widgets are used to manipulate position and orientation. Does not trigger when the object's size is changed.
<sqf>
edenObject addEventHandler ["Dragged3DEN", {
params ["_object"];
}];
</sqf>
 
* object: [[Object]] - affected object
{{ConfigPage|end}}
 
 
[[Category: Eden Editor: Modding|Event Handlers]]
[[Category: Eden Editor: Modding|Event Handlers]]
[[Category: Event Handlers|Eden Editor]]
[[Category: Event Handlers|Eden Editor]]
[[Category: Arma 3: Editing|Event Handlers]]

Latest revision as of 18:45, 11 March 2024

Editor Event Handlers

Eden Editor Event Handlers are added to the editor instance and will remain active for the duration of a session. Launching a preview will keep the event handlers, but closing the editor will erase all of them and you will have to add them again on the next Eden instance.

Related commands

Event Scripts

Config

Alternatively, you can define event handlers directly in the config. Use your custom section (mySection in the example) to prevent overriding handlers from other sources. Handlers defined here will automatically be added when Eden Editor is opened.

class Cfg3DEN
{
	class EventHandlers
	{
		class mySection
		{
			onUndo = "hint 'Undo';";
			// <handlerName> = <handlerExpression>
		};
	};
};

Events

The following Magic Variables are available inside the event's code:

  • Event Handler parameters are accessible via _this (only if event has parameters)
  • The Event Handler type is available as _thisEvent
  • The Event Handler index is available as _thisEventHandler
  • Most handlers do not receive any arguments; this is intended, as in most cases required data can be obtained using either get3DENActionState or specialised 'get*' Eden Editor commands.
  • Note that unlike object's or mission's event handlers, the On prefix is present in both config and command event name.

Init

Is executed when Eden Editor display was created. Only happens when Eden Editor is opened for the first time during game session.

add3DENEventHandler ["Init", { params ["_display3DEN"]; }];

OnBeforeMissionPreview

Runs before the scenario preview is started. If an event handler of this type returns true, the mission preview will not be initialised.

add3DENEventHandler ["OnBeforeMissionPreview", { params ["_isPreviewMultiplayer"]; }];

OnConnectingStart

When Connecting operation is initiated.

add3DENEventHandler ["OnConnectingStart", { params ["_class", "_from"]; }];


OnConnectingEnd

When Connecting operation is terminated, no matter if it was confirmed or canceled.

add3DENEventHandler ["OnConnectingEnd", { params ["_class", "_from", "_to"]; }];

  • class: Config - connection config class
  • from: Array of 3DEN entities
  • to: Eden Entity (when connecting was successful) or nil (when connecting was terminated)


OnCopy

Fires when entities are copied.
Also fires when entities are cut, but unlike OnCut, OnCopy fires before the entities are deleted, meaning the entities are still accessible with get3DENSelected.

add3DENEventHandler ["OnCopy", { // no arguments }];


OnCut

Fires when entities are cut (after the entities have been deleted).

add3DENEventHandler ["OnCut", { // no arguments }];


OnDeleteUnits

When entities are deleted.

add3DENEventHandler ["OnDeleteUnits", { // no arguments }];


OnEditableEntityAdded

When an entity gets added to the scenario. When compositions are added, the event triggers for every entity in the composition.

add3DENEventHandler ["OnEditableEntityAdded", { params ["_entity"]; }];

entity - Eden Entity

OnEditableEntityRemoved

When an entity gets removed from the scenario.

add3DENEventHandler ["OnEditableEntityRemoved", { params ["_entity"]; }];

entity - Eden Entity

OnEntityAttributeChanged

When an entity's attribute got changed. Fires for each changed attribute separately.

add3DENEventHandler ["OnEditableEntityAttributeChanged", { params ["_entity", "_property"]; }];

  • entity: Eden Entity
  • property: String - property name of the attribute that was changed

OnEntityDragged

When an entity gets dragged. Fires continiously until the left mouse button is released.

add3DENEventHandler ["OnEntityDragged", { params ["_entity"]; }];

entity - Eden Entity

OnEntityMenu

When Entity Context Menu is opened.

add3DENEventHandler ["OnEntityMenu", { params ["_position", "_entity", "_listPath"]; }];

  • position: Array - Position where user clicked to open the menu.
    • Entity position when clicked on an entity.
    • Empty array when clicked on something that doesn't have position (i.e. abstract folder in Edit list like BLUFOR, Trigger, etc.)
  • entity: Eden Entity
    • Nil when clicked on empty space
  • listPath: Array - UI tree path when clicked on entity in the entity list.
    • Nil when clicked in the scene (we cannot use empty array, because that's a path to root item)


OnEntityParentChanged

Fires when the parent of an entity changes. For example, creating waypoints, moving entities into layers or out of layers. It seems that this EH always fires twice. First event returns objNull for _newParentEntityID.

add3DENEventHandler ["OnEntityParentChanged", { params ["_affectedEntity", "_newParentEntityID"] }];

OnGridChange

When grid changes, either using Toolbar option, ot by scripting command set3DENGrid.

add3DENEventHandler ["OnGridChange", { params ["_gridType", "_gridValue"]; }];

  • gridType: String - can be "translation", "rotation" or "scaling"
  • gridValue: Number


OnHistoryChange

When history changes.

add3DENEventHandler ["OnHistoryChange", { // no arguments }];


OnMapClosed

When map is closed.

add3DENEventHandler ["OnMapClosed", { // no arguments }];


OnMapOpened

When map is opened.

add3DENEventHandler ["OnMapOpened", { // no arguments }];


OnMessage

Handler used for showing on-screen notifications, triggered by various range of events. Message IDs:

  • 0 - Mission saved
  • 1 - Mission autosaved
  • 2 - Trying to move a character into full vehicle
  • 3 - Moved character into enemy vehicle
  • 4 - Trying to run mission without any player
  • 5 - Mission exported to SP
  • 6 - Mission exported to MP
  • 7 - Attempting to delete a default layer

add3DENEventHandler ["OnMessage", { params ["_messageID"]; }];


OnMissionAttributeChanged

When a mission attribute or the preferences are changed.

add3DENEventHandler ["OnMissionAttributeChanged", { params ["_section", "_property"]; }];


OnMissionAutosave

When scenario is autosaved.

add3DENEventHandler ["OnMissionAutosave", { // no arguments }];

OnMissionExportSP

When a scenario is exported to singleplayer.

add3DENEventHandler ["OnMissionExportSP", { // no arguments }];


OnMissionExportMP

When a scenario is exported to multiplayer.

add3DENEventHandler ["OnMissionExportMP", { // no arguments }];


OnMissionListChange

When the current list of missions in the open/save mission dialog changes, i.e when first opened or a different folder is selected.

add3DENEventHandler ["OnMissionListChange", { // no arguments }];


OnMissionLoad

When scenario is loaded.

If a missing config is preventing the scenario from being loaded, this event handler will only be executed after pressing the "Force Load" button.

add3DENEventHandler ["OnMissionLoad", { // no arguments }];


OnMissionNew

When new scenario is started. Executed also when Eden is opened with an empty scenario.

add3DENEventHandler ["OnMissionNew", { // no arguments }];


OnMissionPreview

When scenario preview is started. Executed when the scenario is already loaded, so entities in it can be accessed.

add3DENEventHandler ["OnMissionPreview", { params ["_objects", "_groups", "_waypoints", "_markers"]; }];

  • objects: Array
  • groups: Array
  • waypoints: Array
  • markers: Array

Each array is in format:

[entity1, id1, entity2, id2, ..., entityN, idN]


OnMissionPreviewEnd

When preview ends and user returns back to Eden Editor.

add3DENEventHandler ["OnMissionPreviewEnd", { // no arguments }];


OnMissionSave

When scenario is saved.

add3DENEventHandler ["OnMissionSave", { // no arguments }];


OnMissionSaveAs

When Save As action is triggered (i.e. Save window is opened, but the mission is not necessarily saved yet).

add3DENEventHandler ["OnMissionSaveAs", { // no arguments }];


OnModeChange

When editing mode is changed (i.e. from Objects to Triggers).

add3DENEventHandler ["OnModeChange", { // no arguments }];


OnMoveGridDecrease

🚧
TODO: this must be updated.

add3DENEventHandler ["OnMoveGridDecrease", { // params ["?"]; }];


OnMoveGridIncrease

🚧
TODO: this must be updated.

add3DENEventHandler ["OnMoveGridIncrease", { // params ["?"]; }];


OnMoveGridToggle

When translation grid is toggled on or off.

add3DENEventHandler ["OnMoveGridToggle", { // no arguments }];


OnPaste

When entities are pasted.

add3DENEventHandler ["OnPaste", { // no arguments }];


OnPasteUnitOrig

When entities are pasted on their original positions.

add3DENEventHandler ["OnPasteUnitOrig", { // no arguments }];


OnRedo

When undo operation is redone.

add3DENEventHandler ["OnRedo", { // no arguments }];


OnRotateGridDecrease

🚧
TODO: this must be updated.

add3DENEventHandler ["OnRotateGridDecrease", { // params ["?"]; }];


OnRotateGridIncrease

🚧
TODO: this must be updated.

add3DENEventHandler ["OnRotateGridIncrease", { // params ["?"]; }];


OnRotateGridToggle

When rotation grid is toggled on or off.

add3DENEventHandler ["OnRotateGridToggle", { // no arguments }];


OnScaleGridToggle

When area scaling grid is toggled on or off.

add3DENEventHandler ["OnScaleGridToggle", { // no arguments }];


OnSearchCreate

When "SearchCreate" action is triggered (e.g. when pressing Ctrl+Shift+F).

add3DENEventHandler ["OnSearchCreate", { // no arguments }];


OnSearchEdit

When "SearchEdit" action is triggered (e.g. when pressing Ctrl+F).

add3DENEventHandler ["OnSearchEdit", { // no arguments }];


OnSelectionChange

When entity selection changes. Use get3DENSelected to return currently selected entities.

add3DENEventHandler ["OnSelectionChange", { // no arguments }];


OnServerToggle

When server is created or destroyed from the preview.

add3DENEventHandler ["OnServerToggle", { // no arguments }];


OnSubmodeChange

When submode (e.g. BLUFOR or OFPOR for Objects, or Modules for Systems) changes.

add3DENEventHandler ["OnSubmodeChange", { // no arguments }];


OnSurfaceSnapToggle

When surface snap settings are changed.

add3DENEventHandler ["OnSurfaceSnapToggle", { // no arguments }];


OnTerrainNew

When new terrain is loaded. Executed also when Eden is opened.

add3DENEventHandler ["OnTerrainNew", { // no arguments }];


OnToggleMapIDs

When map IDs are toggled with do3DENAction "ToggleMapIDs". Only triggers if map is open.

add3DENEventHandler ["OnToggleMapIDs", { // no arguments }];


OnToggleMapTextures

When map textures are toggled on or off.

add3DENEventHandler ["OnToggleMapTextures", { // no arguments }];


OnTogglePlaceEmptyVehicle

When the Place vehicles with crew is toggled on/off in Objects mode.

add3DENEventHandler ["OnTogglePlaceEmptyVehicle", { // no arguments }];


OnUndo

When an operation is undone.

add3DENEventHandler ["OnUndo", { // no arguments }];


OnVerticalToggle

When vertical mode settings are changed.

add3DENEventHandler ["OnVerticalToggle", { // no arguments }];


OnWidgetArea

When area widget is selected.

add3DENEventHandler ["OnWidgetArea", { // no arguments }];


OnWidgetNone

When no widget is selected.

add3DENEventHandler ["OnWidgetNone", { // no arguments }];


OnWidgetRotation

When rotation widget is selected.

add3DENEventHandler ["OnWidgetRotation", { // no arguments }];


OnWidgetScale

When scaling widget is selected.

add3DENEventHandler ["OnWidgetScale", { // no arguments }];


OnWidgetToggle

When widget is toggled (i.e. browsing through all widget types)

add3DENEventHandler ["OnWidgetToggle", { // no arguments }];


OnWidgetTranslation

When translation widget is selected.

add3DENEventHandler ["OnWidgetTranslation", { // no arguments }];


OnWorkspacePartSwitch

When scenario phase is selected.

add3DENEventHandler ["OnWorkspacePartSwitch", { // no arguments }];


Object Event Handlers

Editor specific event handlers can be also added directly to objects, using addEventHandler command.

These handlers exist only for the duration of active workspace. Running a preview or loading the same scenario again will erase all object event handlers, because objects themselves are despawned from the world and then created again.

Related commands

Events

Most handlers do not receive any arguments. This is intended, because in most cases, required data can be obtained using either get3DENActionState or specialised 'get' commands.
None of the following event handlers work for triggers.

AttributesChanged3DEN

Fires when object's attributes are changed. Can happen when:

  • Changing the attributes by dragging, rotating or using one of the widgets
  • Changing and saving the attributes from within the attributes window
  • When attributes get changed using scripting commands such as set3DENAttributes or set3DENAttribute

Unlike Dragged3DEN this event handler will not fire continuously but only when the attributes were changed and saved

edenObject addEventHandler ["AttributesChanged3DEN", { params ["_object"]; }];

  • object: Object - affected object


ConnectionChanged3DEN

When a connection is added or removed from an object.

edenObject addEventHandler ["ConnectionChanged3DEN", { params ["_object"]; }];

  • object: Object - affected object


RegisteredToWorld3DEN

When object is re-added to the scenario after undoing a delete operation.

edenObject addEventHandler ["RegisteredToWorld3DEN", { params ["_object"]; }];

  • object: Object - affected object


UnregisteredFromWorld3DEN

When object is removed from the scenario. That happens when you delete it, but also when you undo placement operation.

edenObject addEventHandler ["UnregisteredFromWorld3DEN", { params ["_object"]; }];

  • object: Object - affected object


Dragged3DEN

When object is dragged and/or rotated. Also triggers when widgets are used to manipulate position and orientation. Does not trigger when the object's size is changed.

edenObject addEventHandler ["Dragged3DEN", { params ["_object"]; }];

  • object: Object - affected object