# Core API¶

Extension hooks:

onEditorAfterLoadPreferences

Called right after the editor preferences were loaded into: editor.preferences table

onEditorBeforeSavePreferences

Called right before the editor preferences are to be saved from: editor.preferences table

onEditorBeforeNewLevel

Called right before a new level is created

onEditorAfterNewLevel

Called right after a new level is created

onEditorBeforeSaveLevel

Called right before a level is saved

onEditorAfterOpenLevel

Called right after a level was opened

onEditorPlayGame

Called right before play game is activated (or deactivate the editor)

onEditorExit

Called right before editor exit (deactivated)

onEditorExitLevel

Called right before exiting a level

onEditorQuitGame

Called right before quit game

onEditorInitialized

Called right after editor is initialized. This is called once per game session. Afterwards, if the Lua scripts are reloaded with Ctrl+L, it will also be called again one time.

onEditorShutdown

Called right before editor is shutdown. This is called once per game session. If the Lua scripts are reloaded with Ctrl+L, it will be called before that happens.

onEditorActivated

Called right after editor is activated (shown)

onEditorDeactivated

Called right after editor is deactivated (hidden)

onEditorCut

Called on the Cut command, mainly for tools, they have to check if their window is focused and only after that they ca nact on this command

onEditorCopy

Called on the Copy command, mainly for tools, they have to check if their window is focused and only after that they can act on this command

onEditorPaste

Called on the Paste command, mainly for tools, they have to check if their window is focused and only after that they can act on this command

onEditorDuplicate

Called on the Duplicate command, mainly for tools, they have to check if their window is focused and only after that they can act on this command

onEditorSelectAll

Called on the Select All command, mainly for tools, they have to check if their window is focused and only after that they can act on this command

onEditorDeselect

Called on the Deselect command, mainly for tools, they have to check if their window is focused and only after that they can act on this command

onEditorDeleteSelection

Called on the Delete Selection command, mainly for tools, they have to check if their window is focused and only after that they can act on this command

Members:

editor.FloatMin

Minimum float value constant

editor.FloatMax

Maximum float value constant

editor.IntMin

Minimum integer value constant

editor.IntMax

Maximum integer value constant

editor.history [PRIVATE]

The history class instance that handles undo/redo (see history.lua). End-users do not really need to use this class directly, just call editor.undo() or redo.

editor.levelPath [string] [READONLY]

The current level path

editor.levelFile [string] [READONLY]

The current level filename

editor.dirty [boolean]

This is set to true when something changed in the editor state/current level.

editor.username [string]

This is the username that is editing the current level.

editor.log(msg)
Parameters: msg – the message to log

Editor logging, it is a special log type, which can be disabled/controlled by editor.

editor.logDebug(msg)
Parameters: msg – the message to log

Write a message to log, pertaining to editor debugging

editor.logError(msg)
Parameters: msg – the message to log

Write a message to log, as an editor error

editor.logWarn(msg)
Parameters: msg – the message to log

Write a message to log, as an editor warning

editor.newLevel()

Deletes the current scene from memory, clears up all variables and creates a new level in memory (not yet on disk, you need to save it to disk)

editor.openLevel(filename)
Parameters: filename – the JSON level filename relative to game folder

Open an existing level from disk. Will remove any unsaved changes made to the current level.

editor.saveLevel()

Save the current level data. There must be a level open.

editor.saveLevelAs(filename)
Parameters: filename – the new filename for the level

Save the scene level to the specified filename.

editor.resaveEverything()

Resave everything, including level, settings, etc.

editor.playLevel()

Play the current level.

editor.exitLevel()

Exit the current level [MIGHT BE DEPRECATED]

editor.quitEditor()

Quit the editor.

editor.toggleActive()

Toggle the editor state active/inactive.

editor.quitGame()

Quit the actual game.

editor.getDeltaTime()

Return the delta time in seconds between two frames. Used for various things like gizmo animation.

editor.undo(levels)
Parameters: levels – the number of undo steps to be performed, if omitted, then this is 1

Undo the last operation(s).

editor.redo(levels)
Parameters: levels – the number of redo steps to be performed, if omitted, then this is 1

Redo (revert the last undo operations) the last operation(s).

editor.setUndoHistory(history)
Parameters: history – the history table instance to be used from now on. If this is nil then the default history will be used.

Allows the user to change the current history table instance. This is useful for context aware undo, for example if the editor uses multiple windows/panes and when switching editing actions back and forth, each window/pane should keep its own undo context to allow proper undo/redo operation.

editor.clearUndoHistory()

Clears the current undo history (along with redo information), basically acting like a collapse of operations. From this moment all the past operations are irreversible.

editor.exportToCollada(filename)
Parameters: filename – exported DAE filename (it can be absolute or relative to game root)

editor.exportToFbx(filename)
Parameters: filename – exported FBX filename (it can be absolute or relative to game root)

Export the scene to FBX.

editor.exportToGLTF(filename)
Parameters: filename – exported GLTF filename (it can be absolute or relative to game root)

Export the scene to GLTF.

editor.createAudioParameter(param)
Parameters: param – the param table

Create an audio parameter.

editor.deleteAudioParameter(name)
Parameters: name – the parameter name

Delete an audio parameter by its name.

editor.getAudioParameters()
Returns: the parameters table, with the key as the parameter names
editor.setVisibilityMode(name, visible)
Parameters: name – the name of the mode, allowed values can be found using editor.getVisibilityModes() visible – true/false for visibility

Set a visibility mode’s status.

editor.getVisibilityModes()
editor.addVisibilityMode(name, variable)
Parameters: name – the visibility name, example “Wireframe Mode” variable – the string with the variable name, example: “\$gfx::wireframe”

Add a new user visibility mode.

editor.setObjectTypeVisible(typeName, visible)
Parameters: typeName – the name of the C++ object class/type to be visible visible – true/false for class visibility

Set the object type visibility.

editor.setObjectTypeLock(typeName, lock)
Parameters: typeName – the name of the C++ object class/type to be locked from editing lock – true/false for class locking

Locks a certain object type from being editable/selectable.

editor.getObjectTypesVisibility()
Returns: a table with keys: name of the type, values: boolean if object type is visible
editor.getObjectTypesLocking()
Returns: a table with keys: name of the type, values: boolean if object type is locked
editor.setLightingType(type) [MAY BE DEPRECATED]
Parameters: type – the lighting type, allowed values: editor.LightingType_Basic - basic lighting, faster, more editing friendly editor.LightingType_Advanced - full lighting quality, detailed & high quality

Sets the current editor lighting type.

editor.selectEditMode(mode)
Parameters: mode – the edit mode table, with the fields: displayName - the display name shown in the title bar for the current edit mode, example: “Edit Terrain” onActivate - a function called when the edit mode gets selected, optional onDeactivate - a function called when the edit mode gets deselected, optional onUpdate - a function called when the edit mode needs to update/check internal state onCut - a function called when the edit mode is required to cut the selection, optional onCopy - a function called when the edit mode is required to copy the selection, optional onPaste - a function called when the edit mode is required to paste the selection, optional onDuplicate - a function called when the edit mode is required to duplicate(clone) the selection, optional onSelectAll - a function called when the edit mode is required to select all items, optional onDeselect - a function called when the edit mode is required to deselect the selection, optional onDeleteSelection - a function called when the edit mode is required to delete the selected items, optional onToolbar - a function called when the edit mode is selected and it needs to render icon buttons in the vertical edit mode toolbar, optional actionMap - an action map for the input, which will be pushed to the action map stack when the edit mode is selected, optional icon - an icon for the edit mode, you can find the icons in the editor.icons table, if nil, no toolbar button will be shown in the edit modes toolbar iconTooltip - a tooltip for the button in the edit modes toolbar, optional
editor.cut()

Cut the current selection. The cut action is routed to the current edit mode, calling its onCut() callback, see Edit Modes_. The global extension hook onEditorCut will also be invoked, which can be used by other tools if they’re in focus and don’t have edit modes registered.

editor.copy()

Copy the current selection. The copy action is routed to the current edit mode, calling its onCopy() callback, see Edit Modes_. The global extension hook onEditorCopy will also be invoked, which can be used by other tools if they’re in focus and don’t have edit modes registered.

editor.paste()

Paste the current selection. The paste action is routed to the current edit mode, calling its onPaste() callback, see Edit Modes_. The global extension hook onEditorPaste will also be invoked, which can be used by other tools if they’re in focus and don’t have edit modes registered.

editor.duplicate()

Duplicate the current selection. The duplicate action is routed to the current edit mode, calling its onDuplicate() callback, see Edit Modes_. The global extension hook onEditorDuplicate will also be invoked, which can be used by other tools if they’re in focus and don’t have edit modes registered.

editor.selectAll()

Select all items. The select all action is routed to the current edit mode, calling its onSelectAll() callback, see Edit Modes_. The global extension hook onEditorSelectAll will also be invoked, which can be used by other tools if they’re in focus and don’t have edit modes registered.

editor.deselect()

Deselect the current selection. The deselect action is routed to the current edit mode, calling its onDeselect() callback, see Edit Modes_. The global extension hook onEditorDeselect will also be invoked, which can be used by other tools if they’re in focus and don’t have edit modes registered.

editor.deleteSelection()

Delete the items in the current selection. The delete selection action is routed to the current edit mode, calling its onDeleteSelection() callback, see Edit Modes_. The global extension hook onEditorDeleteSelection will also be invoked, which can be used by other tools if they’re in focus and don’t have edit modes registered.