Core API

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. If user will set to true, the Save/Save As functions will take it into account.

editor.username [string]

This is the username that is editing the current level. Not used right at the moment.

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(path)
Parameters:path – the level 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(path)
Parameters:path – the new path for the level

Save the scene level to the specified path.

editor.quitEditor()

Quit the editor.

editor.toggleActive()

Toggle the editor state active/inactive.

editor.isEditorActive()

Return true if editor is active (visible).

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.deleteObject(id)

Delete an object by its id.

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

Undo the last operation(s).

editor.redo(steps)
Parameters:steps – 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.setVisualizationType(name, visible)
Parameters:
  • name – the name of the type, allowed values can be found using editor.getVisualizationTypes()
  • visible – true/false for visibility

Set a visualization type’s status on or off.

editor.getVisualizationType(name)
Parameters:name – the vizualization name

Return a visualization type info.

editor.getVisualizationTypes()
Returns:the available visualization types. You can add custom ones adding an item to editor.registerVisualizationType(…)
editor.registerVisualizationType(typeData)
Parameters:typeData – the visualization type info

Add a new user visualization type.

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.getObjectTypeVisible(typeName)
Parameters:typeName – the name of the C++ object class/type
Returns:true/false for class visibility

Get the object type visibility.

editor.setObjectTypeSelectable(typeName, selectable)
Parameters:
  • typeName – the name of the C++ object class/type
  • selectable – true/false for class selectability

Set a certain object type from being editable/selectable.

editor.getObjectTypeSelectable(typeName)
Parameters:typeName – the name of the C++ object class/type

Return true if object type is editable/selectable.

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.

editor.getLevelName()

Return the current level name.

editor.getLevelPath()

Return the current level path.