Eden Editor Event Handlers – Arma 3

From Bohemia Interactive Community
Revision as of 18:45, 11 March 2024 by R3vo (talk | contribs) (Note about none of the entity specific event handlers working for triggers)
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 _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