Eden Editor Event Handlers – Arma 3
(added Eden "init" EH) |
(Note about none of the entity specific event handlers working for triggers) |
||
(15 intermediate revisions by 3 users not shown) | |||
Line 35: | Line 35: | ||
=== Events === | === 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| | {{Feature|informative| | ||
Line 52: | Line 56: | ||
* display3DEN: [[Display]] | * 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 ==== | ||
Line 105: | Line 117: | ||
</sqf> | </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 ==== | ||
Line 122: | Line 174: | ||
** 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) | ||
{{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 ==== | ||
Line 180: | Line 250: | ||
* messageID: [[Number]] | * messageID: [[Number]] | ||
{{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]] | |||
Line 186: | Line 268: | ||
<sqf> | <sqf> | ||
add3DENEventHandler ["OnMissionAutosave", { | add3DENEventHandler ["OnMissionAutosave", { | ||
// no arguments | |||
}]; | |||
</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 | // no arguments | ||
}]; | }]; | ||
Line 193: | Line 301: | ||
==== OnMissionLoad ==== | ==== OnMissionLoad ==== | ||
When scenario is loaded. | 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. | |||
<sqf> | <sqf> | ||
add3DENEventHandler ["OnMissionLoad", { | add3DENEventHandler ["OnMissionLoad", { | ||
Line 225: | Line 335: | ||
* entity: [[Object]], [[Group]], [[Array]] or [[String]] | * entity: [[Object]], [[Group]], [[Array]] or [[String]] | ||
* ID: [[Number]] | * ID: [[Number]] | ||
Line 268: | Line 369: | ||
add3DENEventHandler ["OnModeChange", { | add3DENEventHandler ["OnModeChange", { | ||
// no arguments | // no arguments | ||
}]; | |||
</sqf> | |||
==== OnMoveGridDecrease ==== | |||
{{Wiki|TODO}} | |||
<sqf> | |||
add3DENEventHandler ["OnMoveGridDecrease", { | |||
// params ["?"]; | |||
}]; | |||
</sqf> | |||
==== OnMoveGridIncrease ==== | |||
{{Wiki|TODO}} | |||
<sqf> | |||
add3DENEventHandler ["OnMoveGridIncrease", { | |||
// params ["?"]; | |||
}]; | }]; | ||
</sqf> | </sqf> | ||
Line 308: | Line 429: | ||
==== | ==== OnRotateGridDecrease ==== | ||
{{Wiki|TODO}} | |||
<sqf> | |||
add3DENEventHandler ["OnRotateGridDecrease", { | |||
// params ["?"]; | |||
}]; | |||
</sqf> | |||
==== OnRotateGridIncrease ==== | |||
{{Wiki|TODO}} | |||
<sqf> | <sqf> | ||
add3DENEventHandler [" | add3DENEventHandler ["OnRotateGridIncrease", { | ||
// | // params ["?"]; | ||
}]; | }]; | ||
</sqf> | </sqf> | ||
==== | ==== OnRotateGridToggle ==== | ||
When | When '''rotation''' grid is toggled on or off. | ||
<sqf> | <sqf> | ||
add3DENEventHandler [" | add3DENEventHandler ["OnRotateGridToggle", { | ||
// no arguments | // no arguments | ||
}]; | }]; | ||
Line 348: | Line 478: | ||
<sqf> | <sqf> | ||
add3DENEventHandler ["OnSearchEdit", { | add3DENEventHandler ["OnSearchEdit", { | ||
// no arguments | |||
}]; | |||
</sqf> | |||
==== OnSelectionChange ==== | |||
When entity selection changes. Use [[get3DENSelected]] to return currently selected entities. | |||
<sqf> | |||
add3DENEventHandler ["OnSelectionChange", { | |||
// no arguments | // no arguments | ||
}]; | }]; | ||
Line 384: | Line 523: | ||
<sqf> | <sqf> | ||
add3DENEventHandler ["OnTerrainNew", { | add3DENEventHandler ["OnTerrainNew", { | ||
// no arguments | |||
}]; | |||
</sqf> | |||
==== OnToggleMapIDs ==== | |||
When map IDs are toggled with <sqf inline>do3DENAction "ToggleMapIDs"</sqf>. Only triggers if map is open. | |||
<sqf> | |||
add3DENEventHandler ["OnToggleMapIDs", { | |||
// no arguments | // no arguments | ||
}]; | }]; | ||
Line 504: | Line 652: | ||
{{Feature|informative|Most handlers do not receive any arguments. | {{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.}} | 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|start}} |
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
- See init3DEN.sqf
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
Init
Is executed when Eden Editor display was created. Only happens when Eden Editor is opened for the first time during game session.
- display3DEN: Display
OnBeforeMissionPreview
Runs before the scenario preview is started. If an event handler of this type returns true, the mission preview will not be initialised.
OnConnectingStart
When Connecting operation is initiated.
- class: Config - connection config class
- from: Array of Eden Entities
OnConnectingEnd
When Connecting operation is terminated, no matter if it was confirmed or canceled.
- 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.
OnCut
Fires when entities are cut (after the entities have been deleted).
OnDeleteUnits
When entities are deleted.
OnEditableEntityAdded
When an entity gets added to the scenario. When compositions are added, the event triggers for every entity in the composition.
entity - Eden Entity
OnEditableEntityRemoved
When an entity gets removed from the scenario.
entity - Eden Entity
OnEntityAttributeChanged
When an entity's attribute got changed. Fires for each changed attribute separately.
- 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.
entity - Eden Entity
OnEntityMenu
When Entity Context Menu is opened.
- 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.
OnGridChange
When grid changes, either using Toolbar option, ot by scripting command set3DENGrid.
OnHistoryChange
When history changes.
OnMapClosed
When map is closed.
OnMapOpened
When map is opened.
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
- messageID: Number
OnMissionAttributeChanged
When a mission attribute or the preferences are changed.
- section - String - section name, see sections
- property - String - property name of the attribute, see properties
OnMissionAutosave
When scenario is autosaved.
OnMissionExportSP
When a scenario is exported to singleplayer.
OnMissionExportMP
When a scenario is exported to multiplayer.
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.
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.
OnMissionNew
When new scenario is started. Executed also when Eden is opened with an empty scenario.
OnMissionPreview
When scenario preview is started. Executed when the scenario is already loaded, so entities in it can be accessed.
- 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.
OnMissionSave
When scenario is saved.
OnMissionSaveAs
When Save As action is triggered (i.e. Save window is opened, but the mission is not necessarily saved yet).
OnModeChange
When editing mode is changed (i.e. from Objects to Triggers).
OnMoveGridDecrease
OnMoveGridIncrease
OnMoveGridToggle
When translation grid is toggled on or off.
OnPaste
When entities are pasted.
OnPasteUnitOrig
When entities are pasted on their original positions.
OnRedo
When undo operation is redone.
OnRotateGridDecrease
OnRotateGridIncrease
OnRotateGridToggle
When rotation grid is toggled on or off.
OnScaleGridToggle
When area scaling grid is toggled on or off.
OnSearchCreate
When "SearchCreate" action is triggered (e.g. when pressing Ctrl+Shift+F).
OnSearchEdit
When "SearchEdit" action is triggered (e.g. when pressing Ctrl+F).
OnSelectionChange
When entity selection changes. Use get3DENSelected to return currently selected entities.
OnServerToggle
When server is created or destroyed from the preview.
OnSubmodeChange
When submode (e.g. BLUFOR or OFPOR for Objects, or Modules for Systems) changes.
OnSurfaceSnapToggle
When surface snap settings are changed.
OnTerrainNew
When new terrain is loaded. Executed also when Eden is opened.
OnToggleMapIDs
When map IDs are toggled with do3DENAction "ToggleMapIDs". Only triggers if map is open.
OnToggleMapTextures
When map textures are toggled on or off.
OnTogglePlaceEmptyVehicle
When the Place vehicles with crew is toggled on/off in Objects mode.
OnUndo
When an operation is undone.
OnVerticalToggle
When vertical mode settings are changed.
OnWidgetArea
When area widget is selected.
OnWidgetNone
When no widget is selected.
OnWidgetRotation
When rotation widget is selected.
OnWidgetScale
When scaling widget is selected.
OnWidgetToggle
When widget is toggled (i.e. browsing through all widget types)
OnWidgetTranslation
When translation widget is selected.
OnWorkspacePartSwitch
When scenario phase is selected.
Object Event Handlers
Editor specific event handlers can be also added directly to objects, using addEventHandler command.
Related commands
Events
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
- object: Object - affected object
ConnectionChanged3DEN
When a connection is added or removed from an object.
- object: Object - affected object
RegisteredToWorld3DEN
When object is re-added to the scenario after undoing a delete operation.
- 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.
- 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.
- object: Object - affected object