Eden Editor Event Handlers – Arma 3

From Bohemia Interactive Community
Jump to navigation Jump to search

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 c_this (only if event has parameters)
  • The Event Handler type is available as c_thisEvent
  • The Event Handler index is available as c_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, only available through config modding.

init = " params ['_display3DEN']; systemChat 'First Eden launch this session'; ";

OnBeforeMissionPreview

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

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

OnConnectingStart

When Connecting operation is initiated.

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


OnConnectingEnd

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

Copy
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.

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


OnCut

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

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


OnDeleteUnits

When entities are deleted.

Copy
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.

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

entity - Eden Entity

OnEditableEntityRemoved

When an entity gets removed from the scenario.

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

entity - Eden Entity

OnEntityAttributeChanged

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

Copy
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.

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

entity - Eden Entity

OnEntityMenu

When Entity Context Menu is opened.

Copy
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.

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

OnGridChange

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

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

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


OnHistoryChange

When history changes.

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


OnMapClosed

When map is closed.

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


OnMapOpened

When map is opened.

Copy
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

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


OnMissionAttributeChanged

When a mission attribute or the preferences are changed.

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


OnMissionAutosave

When scenario is autosaved.

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

OnMissionExportSP

When a scenario is exported to singleplayer.

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


OnMissionExportMP

When a scenario is exported to multiplayer.

Copy
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.

Copy
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.

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


OnMissionNew

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

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


OnMissionPreview

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

Copy
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.

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


OnMissionSave

When scenario is saved.

Copy
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).

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


OnModeChange

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

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


OnMoveGridDecrease

🚧
TODO: this must be updated.

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


OnMoveGridIncrease

🚧
TODO: this must be updated.

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


OnMoveGridToggle

When translation grid is toggled on or off.

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


OnPaste

When entities are pasted.

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


OnPasteUnitOrig

When entities are pasted on their original positions.

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


OnRedo

When undo operation is redone.

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


OnRotateGridDecrease

🚧
TODO: this must be updated.

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


OnRotateGridIncrease

🚧
TODO: this must be updated.

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


OnRotateGridToggle

When rotation grid is toggled on or off.

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


OnScaleGridToggle

When area scaling grid is toggled on or off.

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


OnSearchCreate

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

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


OnSearchEdit

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

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


OnSelectionChange

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

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


OnServerToggle

When server is created or destroyed from the preview.

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


OnSubmodeChange

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

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


OnSurfaceSnapToggle

When surface snap settings are changed.

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


OnTerrainNew

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

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


OnToggleMapIDs

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

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


OnToggleMapTextures

When map textures are toggled on or off.

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


OnTogglePlaceEmptyVehicle

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

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


OnUndo

When an operation is undone.

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


OnVerticalToggle

When vertical mode settings are changed.

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


OnWidgetArea

When area widget is selected.

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


OnWidgetNone

When no widget is selected.

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


OnWidgetRotation

When rotation widget is selected.

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


OnWidgetScale

When scaling widget is selected.

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


OnWidgetToggle

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

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


OnWidgetTranslation

When translation widget is selected.

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


OnWorkspacePartSwitch

When scenario phase is selected.

Copy
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

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

  • object: Object - affected object


ConnectionChanged3DEN

When a connection is added or removed from an object.

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

  • object: Object - affected object


RegisteredToWorld3DEN

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

Copy
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.

Copy
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.

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

  • object: Object - affected object