Editor scripting documentation
Version: alpha
| TYPES | |
|---|---|
| editor.command | an editor command |
| editor.command.location | a location where an editor command can be displayed |
| editor.component | editor UI component |
| editor.create_resources.resource | a resource definition used by editor.create_resources |
| editor.image | image loaded for reading by an editor script |
| editor.message | localizable editor message |
| editor.schema | editor preference schema |
| editor.tiles | unbounded two-dimensional grid of tiles |
| editor.transaction_step | editor transaction step |
| http.request.method | hTTP request method, either a common method or a custom method string |
| http.response | hTTP server response |
| http.route | hTTP server route |
| http.server.handler | hTTP server request handler |
| zip.pack.entries | entries included in a ZIP archive |
| zip.pack.entry | zIP entry containing a source path, optional archive target path, and optional compression settings |
| RECORDS | |
|---|---|
| editor.command.context | context provided to editor command handler functions |
| editor.command.options | options used to create an editor command |
| editor.command.query | a query that controls command availability and provides context to its handler functions |
| editor.command.query.active_view | active editor view requested by an editor command |
| editor.command.query.selection | selection requested by an editor command |
| editor.execute.options | options for editor.execute |
| editor.external_file_attributes.result | external file attributes |
| editor.prefs.schema.array.options | options for editor.prefs.schema.array |
| editor.prefs.schema.boolean.options | options for editor.prefs.schema.boolean |
| editor.prefs.schema.enum.options | options for editor.prefs.schema.enum |
| editor.prefs.schema.integer.options | options for editor.prefs.schema.integer |
| editor.prefs.schema.keyword.options | options for editor.prefs.schema.keyword |
| editor.prefs.schema.number.options | options for editor.prefs.schema.number |
| editor.prefs.schema.object.options | options for editor.prefs.schema.object |
| editor.prefs.schema.object_of.options | options for editor.prefs.schema.object_of |
| editor.prefs.schema.one_of.options | options for editor.prefs.schema.one_of |
| editor.prefs.schema.password.options | options for editor.prefs.schema.password |
| editor.prefs.schema.set.options | options for editor.prefs.schema.set |
| editor.prefs.schema.string.options | options for editor.prefs.schema.string |
| editor.prefs.schema.tuple.options | options for editor.prefs.schema.tuple |
| editor.resource_attributes.result | project resource attributes |
| editor.ui.button.props | properties for editor.ui.button |
| editor.ui.check_box.props | properties for editor.ui.check_box |
| editor.ui.dialog.props | properties for editor.ui.dialog |
| editor.ui.dialog_button.props | properties for editor.ui.dialog_button |
| editor.ui.external_file_field.props | properties for editor.ui.external_file_field |
| editor.ui.external_file_filter | external file dialog filter |
| editor.ui.grid.constraint | grid row or column constraint |
| editor.ui.grid.props | properties for editor.ui.grid |
| editor.ui.heading.props | properties for editor.ui.heading |
| editor.ui.horizontal.props | properties for editor.ui.horizontal |
| editor.ui.icon.props | properties for editor.ui.icon |
| editor.ui.image.props | properties for editor.ui.image |
| editor.ui.integer_field.props | properties for editor.ui.integer_field |
| editor.ui.issue | issue associated with an input component |
| editor.ui.label.props | properties for editor.ui.label |
| editor.ui.number_field.props | properties for editor.ui.number_field |
| editor.ui.paragraph.props | properties for editor.ui.paragraph |
| editor.ui.resource_field.props | properties for editor.ui.resource_field |
| editor.ui.scroll.props | properties for editor.ui.scroll |
| editor.ui.select_box.props | properties for editor.ui.select_box |
| editor.ui.separator.props | properties for editor.ui.separator |
| editor.ui.show_external_directory_dialog.options | options for editor.ui.show_external_directory_dialog |
| editor.ui.show_external_file_dialog.options | options for editor.ui.show_external_file_dialog |
| editor.ui.show_resource_dialog.options | options for editor.ui.show_resource_dialog |
| editor.ui.string_field.props | properties for editor.ui.string_field |
| editor.ui.tab.props | properties for editor.ui.tab |
| editor.ui.tabs.props | properties for editor.ui.tabs |
| editor.ui.vertical.props | properties for editor.ui.vertical |
| http.request.options | options for http.request |
| http.request.response | response returned by http.request |
| http.server.request | hTTP server request |
| json.decode.options | options for json.decode |
| tilemap.tiles.get_info.result | full tile information returned by tilemap.tiles.get_info |
| tilemap.tiles.set.info | tile information accepted by tilemap.tiles.set |
| zip.pack.options | options for zip.pack |
| zip.unpack.options | options for zip.unpack |
| ENUMS | |
|---|---|
| editor.prefs.SCOPE | constants for scope enums |
| editor.ui.ALIGNMENT | constants for alignment enums |
| editor.ui.COLOR | constants for color enums |
| editor.ui.HEADING_STYLE | constants for heading style enums |
| editor.ui.ICON | constants for icon enums |
| editor.ui.ISSUE_SEVERITY | constants for issue severity enums |
| editor.ui.ORIENTATION | constants for orientation enums |
| editor.ui.PADDING | constants for padding enums |
| editor.ui.SPACING | constants for spacing enums |
| editor.ui.TEXT_ALIGNMENT | constants for text alignment enums |
| zip.METHOD | constants for zip compression methods |
| zip.ON_CONFLICT | constants defining conflict resolution strategies for zip archive extraction |
| FUNCTIONS | |
|---|---|
| editor.bob() | run bob the builder program |
| editor.browse() | open a URL in the default browser or a registered application |
| editor.can_add() | check whether this list property supports add, clear, and remove operations on the supplied node. |
| editor.can_get() | check whether this property is exposed for reading on the supplied node or resource. |
| editor.can_reorder() | check whether this list property supports reordering on the supplied node. |
| editor.can_reset() | check whether this property supports reset on the supplied node. |
| editor.can_set() | check whether this property is exposed for setting on the supplied node. |
| editor.command() | create an editor command |
| editor.create_directory() | create a directory if it does not exist, and all non-existent parent directories. |
| editor.create_resources() | create resources (including non-existent parent directories). |
| editor.delete_directory() | delete a directory if it exists, and all existent child directories and files. |
| editor.execute() | execute a shell command. |
| editor.external_file_attributes() | query information about file system path |
| editor.fetch_libraries() | download the latest version of the project library dependencies and reload library-provided editor scripts. |
| editor.get() | get a value of a node property inside the editor. |
| editor.open_external_file() | open a file in a registered application |
| editor.prefs.get() | get preference value |
| editor.prefs.is_set() | check if preference value is explicitly set |
| editor.prefs.schema.array() | array schema |
| editor.prefs.schema.boolean() | boolean schema |
| editor.prefs.schema.enum() | enum value schema |
| editor.prefs.schema.integer() | integer schema |
| editor.prefs.schema.keyword() | keyword schema |
| editor.prefs.schema.number() | floating-point number schema |
| editor.prefs.schema.object() | heterogeneous object schema |
| editor.prefs.schema.object_of() | homogeneous object schema |
| editor.prefs.schema.one_of() | one of schema |
| editor.prefs.schema.password() | password schema |
| editor.prefs.schema.set() | set schema |
| editor.prefs.schema.string() | string schema |
| editor.prefs.schema.tuple() | tuple schema |
| editor.prefs.set() | set preference value |
| editor.properties() | list property names for a node. |
| editor.resource_attributes() | query information about a project resource |
| editor.save() | persist any unsaved changes to disk |
| editor.transact() | change the editor state in a single, undoable transaction |
| editor.tx.add() | create a transaction step that will add a child item to a node's list property when transacted with editor.transact(). |
| editor.tx.clear() | create a transaction step that will remove all items from node's list property when transacted with editor.transact(). |
| editor.tx.remove() | create a transaction step that will remove a child node from the node's list property when transacted with editor.transact(). |
| editor.tx.reorder() | create a transaction step that reorders child nodes in a node list defined by the property if supported (see editor.can_reorder()) |
| editor.tx.reset() | create a transaction step that will reset an overridden property to its default value when transacted with editor.transact(). |
| editor.tx.set() | create transaction step that will set the node's property to a supplied value when transacted with editor.transact(). |
| editor.ui.button() | button with a label and/or an icon |
| editor.ui.check_box() | check box with a label |
| editor.ui.component() | convert a function to a UI component. |
| editor.ui.dialog() | dialog component, a top-level window component that can't be used as a child of other components |
| editor.ui.dialog_button() | dialog button shown in the footer of a dialog |
| editor.ui.external_file_field() | input component for selecting files from the file system |
| editor.ui.grid() | layout container that places its children in a 2D grid |
| editor.ui.heading() | a text heading |
| editor.ui.horizontal() | layout container that places its children in a horizontal row one after another |
| editor.ui.icon() | an icon from a predefined set |
| editor.ui.image() | an image |
| editor.ui.integer_field() | integer input component based on a text field, reports changes on commit (Enter or focus loss) |
| editor.ui.label() | label intended for use with input components |
| editor.ui.number_field() | number input component based on a text field, reports changes on commit (Enter or focus loss) |
| editor.ui.open_resource() | open a resource using its primary or selected view, either in the editor or in a third-party app. Code and Text views accept a one-based cursor or range in args: {line = 42}, {line = 42, column = 12}, or {from = {line = 42, column = 12}, to = {line = 43, column = 4}} |
| editor.ui.paragraph() | a paragraph of text |
| editor.ui.resource_field() | input component for selecting project resources |
| editor.ui.scroll() | layout container that optionally shows scroll bars if child contents overflow the assigned bounds |
| editor.ui.select_box() | dropdown select box with an array of options |
| editor.ui.separator() | thin line for visual content separation, by default horizontal and aligned to center |
| editor.ui.show_dialog() | show a dialog and await a result |
| editor.ui.show_external_directory_dialog() | show a modal OS directory selection dialog and await a result |
| editor.ui.show_external_file_dialog() | show a modal OS file selection dialog and await a result |
| editor.ui.show_resource_dialog() | show a modal resource selection dialog and await a result |
| editor.ui.string_field() | string input component based on a text field, reports changes on commit (Enter or focus loss) |
| editor.ui.tab() | tab used in the tabs prop of editor.ui.tabs(...) |
| editor.ui.tabs() | layout container that shows one selected tab content at a time |
| editor.ui.use_memo() | a hook that caches the result of a computation between re-renders. |
| editor.ui.use_state() | a hook that adds local state to the component. |
| editor.ui.vertical() | layout container that places its children in a vertical column one after another |
| http.request() | perform an HTTP request |
| http.server.external_file_response() | create HTTP response that will stream the content of a file defined by the path |
| http.server.json_response() | create HTTP response with a JSON value |
| http.server.resource_response() | create HTTP response that will stream the content of a resource defined by the resource path |
| http.server.response() | create HTTP response |
| http.server.route() | create route definition for the editor's HTTP server |
| image.load_file() | load an image file for reading |
| image.pixel() | return the color of a pixel from a loaded image. |
| image.pixels() | iterate over pixels in a loaded image. |
| image.size() | return the width and height of a loaded image. |
| json.decode() | decode JSON string to Lua value |
| json.encode() | encode Lua value to JSON string |
| localization.and_list() | create a message pattern that renders a list with the "and" conjunction (for example: a, b, and c) once it is stringified |
| localization.concat() | create a message pattern that concatenates values (similar to table.concat) and performs the actual concatenation when stringified |
| localization.message() | create a message pattern for a localization key defined in an .editor_localization file; the actual localization happens when the returned value is stringified |
| localization.or_list() | create a message pattern that renders a list with the "or" conjunction (for example: a, b, or c) once it is stringified |
| pprint() | pretty-print Lua values |
| tilemap.tiles.clear() | remove all tiles |
| tilemap.tiles.get_info() | get full information from a tile at a particular coordinate |
| tilemap.tiles.get_tile() | get a tile index at a particular coordinate |
| tilemap.tiles.iterator() | create an iterator over all tiles in a tiles data structure |
| tilemap.tiles.new() | create a new unbounded 2d grid data structure for storing tilemap layer tiles |
| tilemap.tiles.remove() | remove a tile at a particular coordinate |
| tilemap.tiles.set() | set a tile at a particular coordinate |
| zip.pack() | create a ZIP archive |
| zip.unpack() | extract a ZIP archive |
| zlib.deflate() | deflate (compress) a buffer |
| zlib.inflate() | inflate (decompress) a buffer |
| CONSTANTS | |
|---|---|
| editor.editor_sha1 | a string, SHA1 of Defold editor |
| editor.engine_sha1 | a string, SHA1 of Defold engine |
| editor.platform | editor platform id. |
| editor.version | a string, version name of Defold |
| http.server.local_url | editor's HTTP server local url |
| http.server.port | editor's HTTP server port |
| http.server.url | editor's HTTP server url |
editor.command.location = "Assets" | "Bundle" | "Code" | "Debug" | "Edit" | "Help" | "Outline" | "Project" | "Scene" | "View"
A location where an editor command can be displayed
editor.create_resources.resource = {[1]:string, [2]?:string}
A resource definition used by editor.create_resources
http.request.method = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS" | string
HTTP request method, either a common method or a custom method string
http.server.handler = fun(request:http.server.request):(http.response|integer|nil, table<string, string>|nil, string|nil)
HTTP server request handler
zip.pack.entry = {[1]:string, [2]?:string, method?:zip.METHOD, level?:integer}
ZIP entry containing a source path, optional archive target path, and optional compression settings
Context provided to editor command handler functions
FIELDS
[selection] |
string|userdata|(string|userdata)[] |
current selection, populated when requested by the command query |
[active_view] |
userdata |
current active editor view, populated when requested by the command query |
[argument] |
any |
command argument, populated when requested by the command query |
Options used to create an editor command
FIELDS
label |
string|editor.message |
user-visible command name, either a string or a localization message |
locations |
editor.command.location[] |
non-empty list of locations where the command is displayed |
[query] |
editor.command.query |
query that controls command availability and provides context to its handler functions |
[id] |
string |
keyword identifier that may be used for assigning a shortcut to a command; should be a dot-separated identifier string, e.g. "my-extension.do-stuff" |
[active] |
fun(opts:editor.command.context):boolean |
function that additionally checks if a command is active in the current context; should be fast to execute since the editor might invoke it in response to UI interactions |
[run] |
fun(opts:editor.command.context):any |
function that is invoked when the user decides to execute the command |
A query that controls command availability and provides context to its handler functions
FIELDS
[selection] |
editor.command.query.selection |
current selection request |
[active_view] |
editor.command.query.active_view |
current active editor view request |
[argument] |
true |
set to true to provide the command argument to the handler functions |
Active editor view requested by an editor command
FIELDS
type |
"code"|"scene"|"html"|"form" |
active editor view type |
Selection requested by an editor command
FIELDS
type |
"resource"|"outline"|"scene" |
selection type |
cardinality |
"one"|"many" |
either the first selected item or all selected items |
Options for editor.execute
FIELDS
[reload_resources] |
boolean |
whether the editor reloads resources from disk after the command is executed; defaults to true |
[out] |
"pipe"|"capture"|"discard" |
standard output mode; defaults to "pipe" |
[err] |
"pipe"|"stdout"|"discard" |
standard error output mode; defaults to "pipe" |
External file attributes
FIELDS
path |
string |
resolved file path |
exists |
boolean |
whether there is a file system entry at the path |
is_file |
boolean |
whether the path corresponds to a file |
is_directory |
boolean |
whether the path corresponds to a directory |
Options for editor.prefs.schema.array
FIELDS
item |
editor.schema |
array item schema |
[default] |
any[] |
default value |
[scope] |
editor.prefs.SCOPE |
preference scope; global values are shared by every project on this computer, while project values are stored separately per project |
Options for editor.prefs.schema.boolean
FIELDS
[default] |
boolean |
default value |
[scope] |
editor.prefs.SCOPE |
preference scope; global values are shared by every project on this computer, while project values are stored separately per project |
Options for editor.prefs.schema.enum
FIELDS
values |
(nil|boolean|number|string)[] |
allowed values, must be scalar (nil, boolean, number or string) |
[default] |
any |
default value |
[scope] |
editor.prefs.SCOPE |
preference scope; global values are shared by every project on this computer, while project values are stored separately per project |
Options for editor.prefs.schema.integer
FIELDS
[default] |
integer |
default value |
[scope] |
editor.prefs.SCOPE |
preference scope; global values are shared by every project on this computer, while project values are stored separately per project |
Options for editor.prefs.schema.keyword
FIELDS
[default] |
string |
default value |
[scope] |
editor.prefs.SCOPE |
preference scope; global values are shared by every project on this computer, while project values are stored separately per project |
Options for editor.prefs.schema.number
FIELDS
[default] |
number |
default value |
[scope] |
editor.prefs.SCOPE |
preference scope; global values are shared by every project on this computer, while project values are stored separately per project |
Options for editor.prefs.schema.object
FIELDS
properties |
table<string, editor.schema> |
a table from property key (string) to value schema |
[default] |
table<string, any> |
default value |
[scope] |
editor.prefs.SCOPE |
preference scope; global values are shared by every project on this computer, while project values are stored separately per project |
Options for editor.prefs.schema.object_of
FIELDS
key |
editor.schema |
table key schema |
val |
editor.schema |
table value schema |
[default] |
table<any, any> |
default value |
[scope] |
editor.prefs.SCOPE |
preference scope; global values are shared by every project on this computer, while project values are stored separately per project |
Options for editor.prefs.schema.one_of
FIELDS
schemas |
editor.schema[] |
alternative schemas |
[default] |
any |
default value |
[scope] |
editor.prefs.SCOPE |
preference scope; global values are shared by every project on this computer, while project values are stored separately per project |
Options for editor.prefs.schema.password
FIELDS
[default] |
string |
default value |
[scope] |
editor.prefs.SCOPE |
preference scope; global values are shared by every project on this computer, while project values are stored separately per project |
Options for editor.prefs.schema.set
FIELDS
item |
editor.schema |
set item schema |
[default] |
table<any, true> |
default value |
[scope] |
editor.prefs.SCOPE |
preference scope; global values are shared by every project on this computer, while project values are stored separately per project |
Options for editor.prefs.schema.string
FIELDS
[default] |
string |
default value |
[scope] |
editor.prefs.SCOPE |
preference scope; global values are shared by every project on this computer, while project values are stored separately per project |
Options for editor.prefs.schema.tuple
FIELDS
items |
editor.schema[] |
schemas for the items |
[default] |
any[] |
default value |
[scope] |
editor.prefs.SCOPE |
preference scope; global values are shared by every project on this computer, while project values are stored separately per project |
Project resource attributes
FIELDS
exists |
boolean |
whether a resource identified by the path exists in the project |
is_file |
boolean |
whether the resource represents a file with some content |
is_directory |
boolean |
whether the resource represents a directory |
Properties for editor.ui.button
FIELDS
[on_pressed] |
function |
button press callback, will be invoked without arguments when the user presses the button |
[text] |
string|editor.message |
the text, either a string or a localization message |
[text_alignment] |
editor.ui.TEXT_ALIGNMENT |
text alignment within paragraph bounds |
[icon] |
editor.ui.ICON |
predefined icon name |
[enabled] |
boolean |
determines if the input component can be interacted with |
[alignment] |
editor.ui.ALIGNMENT |
alignment of the component content within its assigned bounds, defaults to editor.ui.ALIGNMENT.TOP_LEFT |
[grow] |
boolean |
determines if the component should grow to fill available space in a horizontal or vertical layout container |
[row_span] |
integer |
how many rows the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
[column_span] |
integer |
how many columns the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
Properties for editor.ui.check_box
FIELDS
[value] |
boolean |
determines if the checkbox should appear checked |
[on_value_changed] |
function |
change callback, will receive the new value |
[indeterminate] |
boolean |
determines if the checkbox should appear in the mixed state |
[text] |
string|editor.message |
the text, either a string or a localization message |
[text_alignment] |
editor.ui.TEXT_ALIGNMENT |
text alignment within paragraph bounds |
[issue] |
editor.ui.issue|false |
issue related to the input, or false if there is no issue |
[tooltip] |
string|editor.message |
tooltip message shown on hover; either a string or a localization message |
[enabled] |
boolean |
determines if the input component can be interacted with |
[alignment] |
editor.ui.ALIGNMENT |
alignment of the component content within its assigned bounds, defaults to editor.ui.ALIGNMENT.TOP_LEFT |
[grow] |
boolean |
determines if the component should grow to fill available space in a horizontal or vertical layout container |
[row_span] |
integer |
how many rows the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
[column_span] |
integer |
how many columns the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
Properties for editor.ui.dialog
FIELDS
title |
string|editor.message |
OS dialog window title, either a string or a localization message |
[header] |
editor.component|false |
top part of the dialog, defaults to editor.ui.heading({text = props.title}) |
[content] |
editor.component|false |
content of the dialog |
[width] |
number |
initial width of the dialog window in pixels |
[height] |
number |
initial height of the dialog window in pixels |
[resizable] |
boolean |
determines if the dialog window can be resized by the user |
[buttons] |
(editor.component|false)[] |
array of editor.ui.dialog_button(...) components, footer of the dialog. Defaults to a single Close button |
[modal] |
boolean |
if set to false, the dialog window stays on top but does not block interaction with the editor |
Properties for editor.ui.dialog_button
FIELDS
text |
string|editor.message |
button text, either a string or a localization message |
[result] |
any |
value returned by editor.ui.show_dialog(...) if this button is pressed |
[default] |
boolean |
if set, pressing Enter in the dialog will trigger this button |
[cancel] |
boolean |
if set, pressing Escape in the dialog will trigger this button |
[enabled] |
boolean |
determines if the button can be interacted with |
Properties for editor.ui.external_file_field
FIELDS
[value] |
string |
file or directory path; resolved against project root if relative |
[on_value_changed] |
function |
value change callback, will receive the absolute path of a selected file/folder or nil if the field was cleared; even though the selector dialog allows selecting only files, it's possible to receive directories and non-existent file system entries using text field input |
[title] |
string|editor.message |
OS window title, either a string or a localization message |
[filters] |
editor.ui.external_file_filter[] |
File filters |
[issue] |
editor.ui.issue|false |
issue related to the input, or false if there is no issue |
[tooltip] |
string|editor.message |
tooltip message shown on hover; either a string or a localization message |
[enabled] |
boolean |
determines if the input component can be interacted with |
[alignment] |
editor.ui.ALIGNMENT |
alignment of the component content within its assigned bounds, defaults to editor.ui.ALIGNMENT.TOP_LEFT |
[grow] |
boolean |
determines if the component should grow to fill available space in a horizontal or vertical layout container |
[row_span] |
integer |
how many rows the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
[column_span] |
integer |
how many columns the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
External file dialog filter
FIELDS
description |
string|editor.message |
text explaining the filter, either a literal string like "Text files (*.txt)" or a localization message |
extensions |
string[] |
file extension patterns, e.g. ".txt", ".*", or "game.project" |
Grid row or column constraint
FIELDS
[grow] |
boolean |
whether the row or column should grow to fill available space |
Properties for editor.ui.grid
FIELDS
[children] |
((editor.component|false)[]|false)[] |
array of arrays of child components |
[rows] |
(editor.ui.grid.constraint|false)[] |
separate configuration for each row |
[columns] |
(editor.ui.grid.constraint|false)[] |
separate configuration for each column |
[padding] |
editor.ui.PADDING|number |
empty space from the edges of the container to its children, either a predefined padding value or a non-negative number of pixels |
[spacing] |
editor.ui.SPACING|number |
empty space between child components, either a predefined spacing value or a non-negative number of pixels; defaults to editor.ui.SPACING.MEDIUM |
[alignment] |
editor.ui.ALIGNMENT |
alignment of the component content within its assigned bounds, defaults to editor.ui.ALIGNMENT.TOP_LEFT |
[grow] |
boolean |
determines if the component should grow to fill available space in a horizontal or vertical layout container |
[row_span] |
integer |
how many rows the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
[column_span] |
integer |
how many columns the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
Properties for editor.ui.heading
FIELDS
[text] |
string|editor.message |
the text, either a string or a localization message |
[text_alignment] |
editor.ui.TEXT_ALIGNMENT |
text alignment within paragraph bounds |
[color] |
editor.ui.COLOR |
semantic color, defaults to editor.ui.COLOR.TEXT |
[word_wrap] |
boolean |
determines if the lines of text are word-wrapped when they don't fit in the assigned bounds, defaults to true |
[style] |
editor.ui.HEADING_STYLE |
heading style, defaults to editor.ui.HEADING_STYLE.H3 |
[alignment] |
editor.ui.ALIGNMENT |
alignment of the component content within its assigned bounds, defaults to editor.ui.ALIGNMENT.TOP_LEFT |
[grow] |
boolean |
determines if the component should grow to fill available space in a horizontal or vertical layout container |
[row_span] |
integer |
how many rows the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
[column_span] |
integer |
how many columns the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
Properties for editor.ui.horizontal
FIELDS
[children] |
(editor.component|false)[] |
array of child components |
[padding] |
editor.ui.PADDING|number |
empty space from the edges of the container to its children, either a predefined padding value or a non-negative number of pixels |
[spacing] |
editor.ui.SPACING|number |
empty space between child components, either a predefined spacing value or a non-negative number of pixels; defaults to editor.ui.SPACING.MEDIUM |
[alignment] |
editor.ui.ALIGNMENT |
alignment of the component content within its assigned bounds, defaults to editor.ui.ALIGNMENT.TOP_LEFT |
[grow] |
boolean |
determines if the component should grow to fill available space in a horizontal or vertical layout container |
[row_span] |
integer |
how many rows the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
[column_span] |
integer |
how many columns the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
Properties for editor.ui.icon
FIELDS
icon |
editor.ui.ICON |
predefined icon name |
[alignment] |
editor.ui.ALIGNMENT |
alignment of the component content within its assigned bounds, defaults to editor.ui.ALIGNMENT.TOP_LEFT |
[grow] |
boolean |
determines if the component should grow to fill available space in a horizontal or vertical layout container |
[row_span] |
integer |
how many rows the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
[column_span] |
integer |
how many columns the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
Properties for editor.ui.image
FIELDS
image |
string |
either a resource path (starts with /), or an URL |
[width] |
number |
width of the image view, the image will be fit inside it while preserving its aspect ratio |
[height] |
number |
height of the image view, the image will be fit inside it while preserving its aspect ratio |
[alignment] |
editor.ui.ALIGNMENT |
alignment of the component content within its assigned bounds, defaults to editor.ui.ALIGNMENT.TOP_LEFT |
[grow] |
boolean |
determines if the component should grow to fill available space in a horizontal or vertical layout container |
[row_span] |
integer |
how many rows the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
[column_span] |
integer |
how many columns the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
Properties for editor.ui.integer_field
FIELDS
[value] |
any |
value |
[on_value_changed] |
function |
value change callback, will receive the new value |
[issue] |
editor.ui.issue|false |
issue related to the input, or false if there is no issue |
[tooltip] |
string|editor.message |
tooltip message shown on hover; either a string or a localization message |
[enabled] |
boolean |
determines if the input component can be interacted with |
[alignment] |
editor.ui.ALIGNMENT |
alignment of the component content within its assigned bounds, defaults to editor.ui.ALIGNMENT.TOP_LEFT |
[grow] |
boolean |
determines if the component should grow to fill available space in a horizontal or vertical layout container |
[row_span] |
integer |
how many rows the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
[column_span] |
integer |
how many columns the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
Issue associated with an input component
FIELDS
severity |
editor.ui.ISSUE_SEVERITY |
issue severity |
message |
string|editor.message |
issue message shown in a tooltip, either a string or a localization message |
Properties for editor.ui.label
FIELDS
[text] |
string|editor.message |
the text, either a string or a localization message |
[text_alignment] |
editor.ui.TEXT_ALIGNMENT |
text alignment within paragraph bounds |
[color] |
editor.ui.COLOR |
semantic color, defaults to editor.ui.COLOR.TEXT |
[tooltip] |
string|editor.message |
tooltip message shown on hover; either a string or a localization message |
[alignment] |
editor.ui.ALIGNMENT |
alignment of the component content within its assigned bounds, defaults to editor.ui.ALIGNMENT.TOP_LEFT |
[grow] |
boolean |
determines if the component should grow to fill available space in a horizontal or vertical layout container |
[row_span] |
integer |
how many rows the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
[column_span] |
integer |
how many columns the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
Properties for editor.ui.number_field
FIELDS
[value] |
any |
value |
[on_value_changed] |
function |
value change callback, will receive the new value |
[issue] |
editor.ui.issue|false |
issue related to the input, or false if there is no issue |
[tooltip] |
string|editor.message |
tooltip message shown on hover; either a string or a localization message |
[enabled] |
boolean |
determines if the input component can be interacted with |
[alignment] |
editor.ui.ALIGNMENT |
alignment of the component content within its assigned bounds, defaults to editor.ui.ALIGNMENT.TOP_LEFT |
[grow] |
boolean |
determines if the component should grow to fill available space in a horizontal or vertical layout container |
[row_span] |
integer |
how many rows the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
[column_span] |
integer |
how many columns the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
Properties for editor.ui.paragraph
FIELDS
[text] |
string|editor.message |
the text, either a string or a localization message |
[text_alignment] |
editor.ui.TEXT_ALIGNMENT |
text alignment within paragraph bounds |
[color] |
editor.ui.COLOR |
semantic color, defaults to editor.ui.COLOR.TEXT |
[word_wrap] |
boolean |
determines if the lines of text are word-wrapped when they don't fit in the assigned bounds, defaults to true |
[alignment] |
editor.ui.ALIGNMENT |
alignment of the component content within its assigned bounds, defaults to editor.ui.ALIGNMENT.TOP_LEFT |
[grow] |
boolean |
determines if the component should grow to fill available space in a horizontal or vertical layout container |
[row_span] |
integer |
how many rows the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
[column_span] |
integer |
how many columns the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
Properties for editor.ui.resource_field
FIELDS
[value] |
string |
resource path (must start with /) |
[on_value_changed] |
function |
value change callback, will receive either resource path of a selected resource or nil when the field is cleared; even though the resource selector dialog allows filtering on resource extensions, it's possible to receive resources with other extensions and non-existent resources using text field input |
[title] |
string|editor.message |
dialog title, either a string or a localization message, defaults to localization.message("dialog.select-resource.title") |
[extensions] |
string[] |
if specified, restricts selectable resources in the dialog to specified file extensions; e.g. {"collection", "go"} |
[issue] |
editor.ui.issue|false |
issue related to the input, or false if there is no issue |
[tooltip] |
string|editor.message |
tooltip message shown on hover; either a string or a localization message |
[enabled] |
boolean |
determines if the input component can be interacted with |
[alignment] |
editor.ui.ALIGNMENT |
alignment of the component content within its assigned bounds, defaults to editor.ui.ALIGNMENT.TOP_LEFT |
[grow] |
boolean |
determines if the component should grow to fill available space in a horizontal or vertical layout container |
[row_span] |
integer |
how many rows the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
[column_span] |
integer |
how many columns the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
Properties for editor.ui.scroll
FIELDS
content |
editor.component |
content component |
[grow] |
boolean |
determines if the component should grow to fill available space in a horizontal or vertical layout container |
[row_span] |
integer |
how many rows the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
[column_span] |
integer |
how many columns the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
Properties for editor.ui.select_box
FIELDS
[value] |
any |
selected value |
[on_value_changed] |
function |
change callback, will receive the selected value |
[options] |
any[] |
array of selectable options |
[to_string] |
function |
function that converts an item to a string (or a localization message); defaults to tostring |
[issue] |
editor.ui.issue|false |
issue related to the input, or false if there is no issue |
[tooltip] |
string|editor.message |
tooltip message shown on hover; either a string or a localization message |
[enabled] |
boolean |
determines if the input component can be interacted with |
[alignment] |
editor.ui.ALIGNMENT |
alignment of the component content within its assigned bounds, defaults to editor.ui.ALIGNMENT.TOP_LEFT |
[grow] |
boolean |
determines if the component should grow to fill available space in a horizontal or vertical layout container |
[row_span] |
integer |
how many rows the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
[column_span] |
integer |
how many columns the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
Properties for editor.ui.separator
FIELDS
[orientation] |
editor.ui.ORIENTATION |
separator line orientation, editor.ui.ORIENTATION.VERTICAL or editor.ui.ORIENTATION.HORIZONTAL |
[alignment] |
editor.ui.ALIGNMENT |
alignment of the component content within its assigned bounds, defaults to editor.ui.ALIGNMENT.TOP_LEFT |
[grow] |
boolean |
determines if the component should grow to fill available space in a horizontal or vertical layout container |
[row_span] |
integer |
how many rows the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
[column_span] |
integer |
how many columns the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
Options for editor.ui.show_external_directory_dialog
FIELDS
[path] |
string |
initial file or directory path; resolved against project root if relative |
[title] |
string|editor.message |
OS window title, either a string or a localization message |
Options for editor.ui.show_external_file_dialog
FIELDS
[path] |
string |
initial file or directory path; resolved against project root if relative |
[title] |
string|editor.message |
OS window title, either a string or a localization message |
[filters] |
editor.ui.external_file_filter[] |
File filters |
Options for editor.ui.show_resource_dialog
FIELDS
[extensions] |
string[] |
if specified, restricts selectable resources in the dialog to specified file extensions; e.g. {"collection", "go"} |
[selection] |
"single"|"multiple" |
selection mode, defaults to "single" |
[title] |
string|editor.message |
dialog title, either a string or a localization message, defaults to localization.message("dialog.select-resource.title") |
Properties for editor.ui.string_field
FIELDS
[value] |
any |
value |
[on_value_changed] |
function |
value change callback, will receive the new value |
[issue] |
editor.ui.issue|false |
issue related to the input, or false if there is no issue |
[tooltip] |
string|editor.message |
tooltip message shown on hover; either a string or a localization message |
[enabled] |
boolean |
determines if the input component can be interacted with |
[alignment] |
editor.ui.ALIGNMENT |
alignment of the component content within its assigned bounds, defaults to editor.ui.ALIGNMENT.TOP_LEFT |
[grow] |
boolean |
determines if the component should grow to fill available space in a horizontal or vertical layout container |
[row_span] |
integer |
how many rows the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
[column_span] |
integer |
how many columns the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
Properties for editor.ui.tab
FIELDS
text |
string|editor.message |
tab header text, either a string or a localization message |
[content] |
editor.component |
tab content component |
[icon] |
editor.component |
tab header icon component |
[enabled] |
boolean |
determines if the tab can be selected |
Properties for editor.ui.tabs
FIELDS
[tabs] |
(editor.component|false)[] |
array of editor.ui.tab(...) components |
[grow] |
boolean |
determines if the component should grow to fill available space in a horizontal or vertical layout container |
[row_span] |
integer |
how many rows the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
[column_span] |
integer |
how many columns the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
Properties for editor.ui.vertical
FIELDS
[children] |
(editor.component|false)[] |
array of child components |
[padding] |
editor.ui.PADDING|number |
empty space from the edges of the container to its children, either a predefined padding value or a non-negative number of pixels |
[spacing] |
editor.ui.SPACING|number |
empty space between child components, either a predefined spacing value or a non-negative number of pixels; defaults to editor.ui.SPACING.MEDIUM |
[alignment] |
editor.ui.ALIGNMENT |
alignment of the component content within its assigned bounds, defaults to editor.ui.ALIGNMENT.TOP_LEFT |
[grow] |
boolean |
determines if the component should grow to fill available space in a horizontal or vertical layout container |
[row_span] |
integer |
how many rows the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
[column_span] |
integer |
how many columns the component spans inside a grid container, must be positive. This prop is only useful for components inside a grid container. |
Options for http.request
FIELDS
[method] |
http.request.method |
request method, defaults to "GET" |
[headers] |
table<string, string> |
request headers |
[body] |
string |
request body |
[as] |
"string"|"json" |
response body converter; mutually exclusive with path |
[path] |
string |
destination file path, resolved against project root if relative; mutually exclusive with as |
Response returned by http.request
FIELDS
status |
integer |
response code |
headers |
table<string, string|string[]> |
response headers, where keys are lowercase and repeated headers have arrays of values |
[body] |
any |
response body, present only when the as option was provided |
[path] |
string |
resolved absolute destination path, present after a successful response was written using the path option |
HTTP server request
FIELDS
[string] |
any |
route path parameter extracted from a path pattern |
path |
string |
full matched path, starting with / |
method |
string |
HTTP request method, e.g. "POST" |
headers |
table<string, string|string[]> |
request headers, keyed by lowercase header name |
[query] |
string |
query string |
[body] |
any |
request body, whose type depends on the route's as argument |
Options for json.decode
FIELDS
[all] |
boolean |
if true, decodes all JSON values in a string and returns an array |
Full tile information returned by tilemap.tiles.get_info
FIELDS
index |
integer |
1-indexed tile index of a tilemap's tilesource |
h_flip |
boolean |
horizontal flip |
v_flip |
boolean |
vertical flip |
rotate_90 |
boolean |
whether the tile is rotated 90 degrees clockwise |
Tile information accepted by tilemap.tiles.set
FIELDS
index |
integer |
1-indexed tile index of a tilemap's tilesource |
[h_flip] |
boolean |
horizontal flip |
[v_flip] |
boolean |
vertical flip |
[rotate_90] |
boolean |
whether the tile is rotated 90 degrees clockwise |
Options for zip.pack
FIELDS
[method] |
zip.METHOD |
compression method, defaults to zip.METHOD.DEFLATED |
[level] |
integer |
compression level from 0 to 9 for deflated entries; defaults to 6 |
Options for zip.unpack
FIELDS
on_conflict |
zip.ON_CONFLICT |
conflict resolution strategy |
editor.prefs.SCOPE: string
Constants for scope enums
VALUES
editor.prefs.SCOPE.GLOBAL |
"global" |
editor.prefs.SCOPE.PROJECT |
"project" |
editor.ui.ALIGNMENT: string
Constants for alignment enums
VALUES
editor.ui.COLOR: string
Constants for color enums
VALUES
editor.ui.COLOR.TEXT |
"text" |
editor.ui.COLOR.HINT |
"hint" |
editor.ui.COLOR.OVERRIDE |
"override" |
editor.ui.COLOR.WARNING |
"warning" |
editor.ui.COLOR.ERROR |
"error" |
editor.ui.HEADING_STYLE: string
Constants for heading style enums
VALUES
editor.ui.ICON: string
Constants for icon enums
VALUES
editor.ui.ICON.OPEN_RESOURCE |
"open-resource" |
editor.ui.ICON.PLUS |
"plus" |
editor.ui.ICON.MINUS |
"minus" |
editor.ui.ICON.CLEAR |
"clear" |
editor.ui.ISSUE_SEVERITY: string
Constants for issue severity enums
VALUES
editor.ui.ISSUE_SEVERITY.WARNING |
"warning" |
editor.ui.ISSUE_SEVERITY.ERROR |
"error" |
editor.ui.ORIENTATION: string
Constants for orientation enums
VALUES
editor.ui.ORIENTATION.VERTICAL |
"vertical" |
editor.ui.ORIENTATION.HORIZONTAL |
"horizontal" |
editor.ui.PADDING: string
Constants for padding enums
VALUES
editor.ui.PADDING.NONE |
"none" |
editor.ui.PADDING.SMALL |
"small" |
editor.ui.PADDING.MEDIUM |
"medium" |
editor.ui.PADDING.LARGE |
"large" |
editor.ui.SPACING: string
Constants for spacing enums
VALUES
editor.ui.SPACING.NONE |
"none" |
editor.ui.SPACING.SMALL |
"small" |
editor.ui.SPACING.MEDIUM |
"medium" |
editor.ui.SPACING.LARGE |
"large" |
editor.ui.TEXT_ALIGNMENT: string
Constants for text alignment enums
VALUES
editor.ui.TEXT_ALIGNMENT.LEFT |
"left" |
editor.ui.TEXT_ALIGNMENT.CENTER |
"center" |
editor.ui.TEXT_ALIGNMENT.RIGHT |
"right" |
editor.ui.TEXT_ALIGNMENT.JUSTIFY |
"justify" |
zip.METHOD: string
Constants for zip compression methods
VALUES
zip.METHOD.DEFLATED |
"deflated" compression method |
zip.METHOD.STORED |
"stored" compression method, i.e. no compression |
zip.ON_CONFLICT: string
Constants defining conflict resolution strategies for zip archive extraction
VALUES
zip.ON_CONFLICT.ERROR |
"error", any conflict aborts extraction |
zip.ON_CONFLICT.SKIP |
"skip", existing file is preserved |
zip.ON_CONFLICT.OVERWRITE |
"overwrite", existing file is overwritten |
editor.bob([options:table<string, string|integer|boolean|(string|integer|boolean)[]>], [...:string])
Run bob the builder program For the full documentation of the available commands and options, see the bob manual.
PARAMETERS
[options] |
table<string, string|integer|boolean|(string|integer|boolean)[]> |
table of command line options for bob, without the leading dashes (--). You can use snake_case instead of kebab-case for option keys. Only long option names are supported (i.e. output, not o). Supported value types are strings, integers and booleans. If an option takes no arguments, use a boolean (i.e. true). If an option may be repeated, you can use an array of values.
|
[...] |
string |
bob commands, e.g. "resolve" or "build"
|
EXAMPLES
Print help in the console:editor.bob({help = true})
local opts = {
archive = true,
platform = editor.platform
}
editor.bob(opts, "distclean", "resolve", "build", "bundle")
local opts = {
archive = true,
platform = editor.platform,
build_server = "https://build.my-company.com",
settings = {"test.ini", "headless.ini"}
}
editor.bob(opts, "distclean", "resolve", "build")
editor.browse(url:string)
Open a URL in the default browser or a registered application
PARAMETERS
url |
string |
http(s) or file URL |
editor.can_add(node:string|userdata, property:string)→value:boolean
Check whether this list property supports add, clear, and remove operations on the supplied node.
PARAMETERS
node |
stringuserdata |
Either resource path (e.g. "/main/game.script"), or internal node id passed to the script by the editor
|
property |
string |
Either "path", "text", or a property from the Outline view (hover the label to see its editor script name)
|
RETURNS
value |
boolean |
editor.can_get(node:string|userdata, property:string)→value:boolean
Check whether this property is exposed for reading on the supplied node or resource.
PARAMETERS
node |
stringuserdata |
Either resource path (e.g. "/main/game.script"), or internal node id passed to the script by the editor
|
property |
string |
Either "path", "text", or a property from the Outline view (hover the label to see its editor script name)
|
RETURNS
value |
boolean |
editor.can_reorder(node:string|userdata, property:string)→value:boolean
Check whether this list property supports reordering on the supplied node.
PARAMETERS
node |
stringuserdata |
Either resource path (e.g. "/main/game.script"), or internal node id passed to the script by the editor
|
property |
string |
Either "path", "text", or a property from the Outline view (hover the label to see its editor script name)
|
RETURNS
value |
boolean |
editor.can_reset(node:string|userdata, property:string)→value:boolean
Check whether this property supports reset on the supplied node.
PARAMETERS
node |
stringuserdata |
Either resource path (e.g. "/main/game.script"), or internal node id passed to the script by the editor
|
property |
string |
Either "path", "text", or a property from the Outline view (hover the label to see its editor script name)
|
RETURNS
value |
boolean |
editor.can_set(node:string|userdata, property:string)→value:boolean
Check whether this property is exposed for setting on the supplied node.
PARAMETERS
node |
stringuserdata |
Either resource path (e.g. "/main/game.script"), or internal node id passed to the script by the editor
|
property |
string |
Either "path", "text", or a property from the Outline view (hover the label to see its editor script name)
|
RETURNS
value |
boolean |
editor.command(opts:editor.command.options)→command:editor.command
Create an editor command
PARAMETERS
opts |
editor.command.options |
command options |
RETURNS
command |
editor.command |
EXAMPLES
Print Git history for a file:editor.command({
label = "Git History",
query = {
selection = {
type = "resource",
cardinality = "one"
}
},
run = function(opts)
editor.execute(
"git",
"log",
"--follow",
"." .. editor.get(opts.selection, "path"),
{reload_resources=false})
end
})
editor.create_directory(resource_path:string)
Create a directory if it does not exist, and all non-existent parent directories. Throws an error if the directory can't be created.
PARAMETERS
resource_path |
string |
Resource path (starting with /)
|
EXAMPLES
editor.create_directory("/assets/gen")
editor.create_resources(resources:(string|editor.create_resources.resource)[])
Create resources (including non-existent parent directories). Throws an error if any of the provided resource paths already exist
PARAMETERS
resources |
(string|editor.create_resources.resource)[] |
resource paths (strings starting with /) or pairs containing a resource path and optional content
|
EXAMPLES
Create a single resource from template:editor.create_resources({
"/npc.go"
})
editor.create_resources({
"/npc.go",
"/levels/1.collection",
"/levels/2.collection",
})
editor.create_resources({
{"/npc.script", "go.property('hp', 100)"}
})
editor.delete_directory(resource_path:string)
Delete a directory if it exists, and all existent child directories and files. Throws an error if the directory can't be deleted.
PARAMETERS
resource_path |
string |
Resource path (starting with /)
|
EXAMPLES
editor.delete_directory("/assets/gen")
editor.execute(command:string, [...:string], [options:editor.execute.options])→result:nil|string
Execute a shell command.
Any shell command arguments should be provided as separate argument strings to this function. If the exit code of the process is not zero, this function throws error. By default, the function returns nil, but it can be configured to capture the output of the shell command as string and return it — set out option to "capture" to do it.
By default, after this shell command is executed, the editor will reload resources from disk.
PARAMETERS
command |
string |
Shell command name to execute |
[...] |
string |
Optional shell command arguments |
[options] |
editor.execute.options |
execution options |
RETURNS
result |
nilstring |
If out option is set to "capture", returns the output as string with trimmed trailing newlines. Otherwise, returns nil.
|
EXAMPLES
Make a directory with spaces in it:editor.execute("mkdir", "new dir")
local status = editor.execute("git", "status", "--porcelain", {
reload_resources = false,
out = "capture"
})
editor.external_file_attributes(path:string)→attributes:editor.external_file_attributes.result
Query information about file system path
PARAMETERS
path |
string |
External file path, resolved against project root if relative |
RETURNS
attributes |
editor.external_file_attributes.result |
external file attributes |
editor.fetch_libraries()
Download the latest version of the project library dependencies and reload library-provided editor scripts. This function may replace library-provided editor commands, hooks, routes, and UI contributed by editor scripts, so it should typically be the last operation performed by a command.
PARAMETERS
None
editor.get(node:string|userdata, property:string)→value:any
Get a value of a node property inside the editor.
Some properties might be read-only, and some might be unavailable in different contexts, so you should use editor.can_get() before reading them and editor.can_set() before making the editor set them.
PARAMETERS
node |
stringuserdata |
Either resource path (e.g. "/main/game.script"), or internal node id passed to the script by the editor
|
property |
string |
Either "path", "text", or a property from the Outline view (hover the label to see its editor script name)
|
RETURNS
value |
any |
property value |
editor.open_external_file(path:string)
Open a file in a registered application
PARAMETERS
path |
string |
file path |
editor.prefs.get(key:string)→value:any
Get preference value The schema for the preference value should be defined beforehand.
PARAMETERS
key |
string |
dot-separated preference key path |
RETURNS
value |
any |
current pref value or default if a schema for the key path exists, nil otherwise |
editor.prefs.is_set(key:string)→value:boolean
Check if preference value is explicitly set The schema for the preference value should be defined beforehand.
PARAMETERS
key |
string |
dot-separated preference key path |
RETURNS
value |
boolean |
flag indicating if the value is explicitly set |
editor.prefs.schema.array(opts:editor.prefs.schema.array.options)→value:editor.schema
array schema
PARAMETERS
opts |
editor.prefs.schema.array.options |
schema options |
RETURNS
value |
editor.schema |
Prefs schema |
editor.prefs.schema.boolean([opts:editor.prefs.schema.boolean.options])→value:editor.schema
boolean schema
PARAMETERS
[opts] |
editor.prefs.schema.boolean.options |
schema options |
RETURNS
value |
editor.schema |
Prefs schema |
editor.prefs.schema.enum(opts:editor.prefs.schema.enum.options)→value:editor.schema
enum value schema
PARAMETERS
opts |
editor.prefs.schema.enum.options |
schema options |
RETURNS
value |
editor.schema |
Prefs schema |
editor.prefs.schema.integer([opts:editor.prefs.schema.integer.options])→value:editor.schema
integer schema
PARAMETERS
[opts] |
editor.prefs.schema.integer.options |
schema options |
RETURNS
value |
editor.schema |
Prefs schema |
editor.prefs.schema.keyword([opts:editor.prefs.schema.keyword.options])→value:editor.schema
keyword schema A keyword is a short string that is interned within the editor runtime, useful e.g. for identifiers
PARAMETERS
[opts] |
editor.prefs.schema.keyword.options |
schema options |
RETURNS
value |
editor.schema |
Prefs schema |
editor.prefs.schema.number([opts:editor.prefs.schema.number.options])→value:editor.schema
floating-point number schema
PARAMETERS
[opts] |
editor.prefs.schema.number.options |
schema options |
RETURNS
value |
editor.schema |
Prefs schema |
editor.prefs.schema.object(opts:editor.prefs.schema.object.options)→value:editor.schema
heterogeneous object schema
PARAMETERS
opts |
editor.prefs.schema.object.options |
schema options |
RETURNS
value |
editor.schema |
Prefs schema |
editor.prefs.schema.object_of(opts:editor.prefs.schema.object_of.options)→value:editor.schema
homogeneous object schema
PARAMETERS
opts |
editor.prefs.schema.object_of.options |
schema options |
RETURNS
value |
editor.schema |
Prefs schema |
editor.prefs.schema.one_of(opts:editor.prefs.schema.one_of.options)→value:editor.schema
one of schema
PARAMETERS
opts |
editor.prefs.schema.one_of.options |
schema options |
RETURNS
value |
editor.schema |
Prefs schema |
editor.prefs.schema.password([opts:editor.prefs.schema.password.options])→value:editor.schema
password schema A password is a string that is encrypted when stored in a preference file
PARAMETERS
[opts] |
editor.prefs.schema.password.options |
schema options |
RETURNS
value |
editor.schema |
Prefs schema |
editor.prefs.schema.set(opts:editor.prefs.schema.set.options)→value:editor.schema
set schema
Set is represented as a lua table with true values
PARAMETERS
opts |
editor.prefs.schema.set.options |
schema options |
RETURNS
value |
editor.schema |
Prefs schema |
editor.prefs.schema.string([opts:editor.prefs.schema.string.options])→value:editor.schema
string schema
PARAMETERS
[opts] |
editor.prefs.schema.string.options |
schema options |
RETURNS
value |
editor.schema |
Prefs schema |
editor.prefs.schema.tuple(opts:editor.prefs.schema.tuple.options)→value:editor.schema
tuple schema A tuple is a fixed-length array where each item has its own defined type
PARAMETERS
opts |
editor.prefs.schema.tuple.options |
schema options |
RETURNS
value |
editor.schema |
Prefs schema |
editor.prefs.set(key:string, value:any)
Set preference value The schema for the preference value should be defined beforehand.
PARAMETERS
key |
string |
dot-separated preference key path |
value |
any |
new pref value to set |
editor.properties(node:string|userdata)→properties:string[]
List property names for a node.
The result is context-sensitive and can vary by node/resource type and editor state. Returned names are readable with editor.get(node, property). Mutating capabilities are per-property; use editor.can_set(), editor.can_reset(), editor.can_add(), and editor.can_reorder() to check which operations are supported.
PARAMETERS
node |
stringuserdata |
Either resource path (e.g. "/main/game.script"), or internal node id passed to the script by the editor
|
RETURNS
properties |
string[] |
sorted unique editor property names available in the current context |
editor.resource_attributes(resource_path:string)→value:editor.resource_attributes.result
Query information about a project resource
PARAMETERS
resource_path |
string |
Resource path (starting with /)
|
RETURNS
value |
editor.resource_attributes.result |
resource attributes |
editor.transact(txs:editor.transaction_step[])
Change the editor state in a single, undoable transaction
PARAMETERS
txs |
editor.transaction_step[] |
An array of transaction steps created using editor.tx.* functions
|
editor.tx.add(node:string|userdata, property:string, value:table<string, any>)→tx:editor.transaction_step
Create a transaction step that will add a child item to a node's list property when transacted with editor.transact().
PARAMETERS
node |
stringuserdata |
Either resource path (e.g. "/main/game.script"), or internal node id passed to the script by the editor
|
property |
string |
Either "path", "text", or a property from the Outline view (hover the label to see its editor script name)
|
value |
table<string, any> |
Added item for the property, a table from property key to either a valid editor.tx.set()-able value, or an array of valid editor.tx.add()-able values
|
RETURNS
tx |
editor.transaction_step |
A transaction step |
editor.tx.clear(node:string|userdata, property:string)→tx:editor.transaction_step
Create a transaction step that will remove all items from node's list property when transacted with editor.transact().
PARAMETERS
node |
stringuserdata |
Either resource path (e.g. "/main/game.script"), or internal node id passed to the script by the editor
|
property |
string |
Either "path", "text", or a property from the Outline view (hover the label to see its editor script name)
|
RETURNS
tx |
editor.transaction_step |
A transaction step |
editor.tx.remove(node:string|userdata, property:string, child_node:string|userdata)→tx:editor.transaction_step
Create a transaction step that will remove a child node from the node's list property when transacted with editor.transact().
PARAMETERS
node |
stringuserdata |
Either resource path (e.g. "/main/game.script"), or internal node id passed to the script by the editor
|
property |
string |
Either "path", "text", or a property from the Outline view (hover the label to see its editor script name)
|
child_node |
stringuserdata |
Either resource path (e.g. "/main/game.script"), or internal node id passed to the script by the editor
|
RETURNS
tx |
editor.transaction_step |
A transaction step |
editor.tx.reorder(node:string|userdata, property:string, child_nodes:any[])→tx:editor.transaction_step
Create a transaction step that reorders child nodes in a node list defined by the property if supported (see editor.can_reorder())
PARAMETERS
node |
stringuserdata |
Either resource path (e.g. "/main/game.script"), or internal node id passed to the script by the editor
|
property |
string |
Either "path", "text", or a property from the Outline view (hover the label to see its editor script name)
|
child_nodes |
any[] |
array of child nodes (the same as returned by editor.get(node, property)) in new order
|
RETURNS
tx |
editor.transaction_step |
A transaction step |
editor.tx.reset(node:string|userdata, property:string)→tx:editor.transaction_step
Create a transaction step that will reset an overridden property to its default value when transacted with editor.transact().
PARAMETERS
node |
stringuserdata |
Either resource path (e.g. "/main/game.script"), or internal node id passed to the script by the editor
|
property |
string |
Either "path", "text", or a property from the Outline view (hover the label to see its editor script name)
|
RETURNS
tx |
editor.transaction_step |
A transaction step |
editor.tx.set(node:string|userdata, property:string, value:any)→tx:editor.transaction_step
Create transaction step that will set the node's property to a supplied value when transacted with editor.transact().
PARAMETERS
node |
stringuserdata |
Either resource path (e.g. "/main/game.script"), or internal node id passed to the script by the editor
|
property |
string |
Either "path", "text", or a property from the Outline view (hover the label to see its editor script name)
|
value |
any |
A new value for the property |
RETURNS
tx |
editor.transaction_step |
A transaction step |
editor.ui.button(props:editor.ui.button.props)→value:editor.component
Button with a label and/or an icon
PARAMETERS
props |
editor.ui.button.props |
component properties |
RETURNS
value |
editor.component |
UI component |
editor.ui.check_box(props:editor.ui.check_box.props)→value:editor.component
Check box with a label
PARAMETERS
props |
editor.ui.check_box.props |
component properties |
RETURNS
value |
editor.component |
UI component |
editor.ui.component(fn:fun(props:T):editor.component)→value:fun(props:T):editor.component
Convert a function to a UI component.
The wrapped function may call any hooks functions (editor.ui.use_*), but on any function invocation, the hooks calls must be the same, and in the same order. This means that hooks should not be used inside loops and conditions or after a conditional return statement.
The grow, row_span, and column_span props are supported automatically.
PARAMETERS
fn |
function(
props:T):editor.component |
function, will receive a single table of props when called |
RETURNS
value |
function(
props:T):editor.component |
decorated component function that may be invoked with a props table to create a component |
editor.ui.dialog(props:editor.ui.dialog.props)→value:editor.component
Dialog component, a top-level window component that can't be used as a child of other components
PARAMETERS
props |
editor.ui.dialog.props |
component properties |
RETURNS
value |
editor.component |
UI component |
editor.ui.dialog_button(props:editor.ui.dialog_button.props)→value:editor.component
Dialog button shown in the footer of a dialog
PARAMETERS
props |
editor.ui.dialog_button.props |
component properties |
RETURNS
value |
editor.component |
UI component |
editor.ui.external_file_field(props:editor.ui.external_file_field.props)→value:editor.component
Input component for selecting files from the file system
PARAMETERS
props |
editor.ui.external_file_field.props |
component properties |
RETURNS
value |
editor.component |
UI component |
editor.ui.grid(props:editor.ui.grid.props)→value:editor.component
Layout container that places its children in a 2D grid
PARAMETERS
props |
editor.ui.grid.props |
component properties |
RETURNS
value |
editor.component |
UI component |
editor.ui.heading(props:editor.ui.heading.props)→value:editor.component
A text heading
PARAMETERS
props |
editor.ui.heading.props |
component properties |
RETURNS
value |
editor.component |
UI component |
editor.ui.horizontal(props:editor.ui.horizontal.props)→value:editor.component
Layout container that places its children in a horizontal row one after another
PARAMETERS
props |
editor.ui.horizontal.props |
component properties |
RETURNS
value |
editor.component |
UI component |
editor.ui.icon(props:editor.ui.icon.props)→value:editor.component
An icon from a predefined set
PARAMETERS
props |
editor.ui.icon.props |
component properties |
RETURNS
value |
editor.component |
UI component |
editor.ui.image(props:editor.ui.image.props)→value:editor.component
An image
PARAMETERS
props |
editor.ui.image.props |
component properties |
RETURNS
value |
editor.component |
UI component |
editor.ui.integer_field(props:editor.ui.integer_field.props)→value:editor.component
Integer input component based on a text field, reports changes on commit (Enter or focus loss)
PARAMETERS
props |
editor.ui.integer_field.props |
component properties |
RETURNS
value |
editor.component |
UI component |
editor.ui.label(props:editor.ui.label.props)→value:editor.component
Label intended for use with input components
PARAMETERS
props |
editor.ui.label.props |
component properties |
RETURNS
value |
editor.component |
UI component |
editor.ui.number_field(props:editor.ui.number_field.props)→value:editor.component
Number input component based on a text field, reports changes on commit (Enter or focus loss)
PARAMETERS
props |
editor.ui.number_field.props |
component properties |
RETURNS
value |
editor.component |
UI component |
editor.ui.open_resource(resource_path:string, [view:string], [args:any])
Open a resource using its primary or selected view, either in the editor or in a third-party app. Code and Text views accept a one-based cursor or range in args: {line = 42}, {line = 42, column = 12}, or {from = {line = 42, column = 12}, to = {line = 43, column = 4}}
PARAMETERS
resource_path |
string |
Resource path (starting with /)
|
[view] |
string |
View to open: "code", "text", "scene", "html", or "form"
|
[args] |
any |
View-specific open arguments; requires view. Currently supported by Code and Text views.
|
editor.ui.paragraph(props:editor.ui.paragraph.props)→value:editor.component
A paragraph of text
PARAMETERS
props |
editor.ui.paragraph.props |
component properties |
RETURNS
value |
editor.component |
UI component |
editor.ui.resource_field(props:editor.ui.resource_field.props)→value:editor.component
Input component for selecting project resources
PARAMETERS
props |
editor.ui.resource_field.props |
component properties |
RETURNS
value |
editor.component |
UI component |
editor.ui.scroll(props:editor.ui.scroll.props)→value:editor.component
Layout container that optionally shows scroll bars if child contents overflow the assigned bounds
PARAMETERS
props |
editor.ui.scroll.props |
component properties |
RETURNS
value |
editor.component |
UI component |
editor.ui.select_box(props:editor.ui.select_box.props)→value:editor.component
Dropdown select box with an array of options
PARAMETERS
props |
editor.ui.select_box.props |
component properties |
RETURNS
value |
editor.component |
UI component |
editor.ui.separator(props:editor.ui.separator.props)→value:editor.component
Thin line for visual content separation, by default horizontal and aligned to center
PARAMETERS
props |
editor.ui.separator.props |
component properties |
RETURNS
value |
editor.component |
UI component |
editor.ui.show_dialog(dialog:editor.component)→value:any
Show a dialog and await a result
PARAMETERS
dialog |
editor.component |
a component that resolves to editor.ui.dialog(...)
|
RETURNS
value |
any |
dialog result, the value used as a result prop in a editor.ui.dialog_button({...}) selected by the user, or nil if the dialog was closed and there was no cancel = true dialog button with result prop set
|
editor.ui.show_external_directory_dialog([opts:editor.ui.show_external_directory_dialog.options])→value:string|nil
Show a modal OS directory selection dialog and await a result
PARAMETERS
[opts] |
editor.ui.show_external_directory_dialog.options |
dialog options |
RETURNS
value |
stringnil |
either absolute directory path or nil if user canceled directory selection |
editor.ui.show_external_file_dialog([opts:editor.ui.show_external_file_dialog.options])→value:string|nil
Show a modal OS file selection dialog and await a result
PARAMETERS
[opts] |
editor.ui.show_external_file_dialog.options |
dialog options |
RETURNS
value |
stringnil |
either absolute file path or nil if user canceled file selection |
editor.ui.show_resource_dialog([opts:editor.ui.show_resource_dialog.options])→value:string|string[]|nil
Show a modal resource selection dialog and await a result
PARAMETERS
[opts] |
editor.ui.show_resource_dialog.options |
dialog options |
RETURNS
value |
stringstring[]nil |
if user made no selection, returns nil. Otherwise, if selection mode is "single", returns selected resource path; otherwise returns a non-empty array of selected resource paths.
|
editor.ui.string_field(props:editor.ui.string_field.props)→value:editor.component
String input component based on a text field, reports changes on commit (Enter or focus loss)
PARAMETERS
props |
editor.ui.string_field.props |
component properties |
RETURNS
value |
editor.component |
UI component |
editor.ui.tab(props:editor.ui.tab.props)→value:editor.component
Tab used in the tabs prop of editor.ui.tabs(...)
PARAMETERS
props |
editor.ui.tab.props |
component properties |
RETURNS
value |
editor.component |
UI component |
editor.ui.tabs(props:editor.ui.tabs.props)→value:editor.component
Layout container that shows one selected tab content at a time
PARAMETERS
props |
editor.ui.tabs.props |
component properties |
RETURNS
value |
editor.component |
UI component |
editor.ui.use_memo(compute:function, [...:any])→values:any
A hook that caches the result of a computation between re-renders.
See editor.ui.component for hooks caveats and rules. If any of the arguments to use_memo change during a component refresh (checked with ==), the value will be recomputed.
PARAMETERS
compute |
function |
function that will be used to compute the cached value |
[...] |
any |
args to the computation function |
RETURNS
values |
any |
all returned values of the compute function |
EXAMPLES
local function increment(n)
return n + 1
end
local function make_listener(set_count)
return function()
set_count(increment)
end
end
local counter_button = editor.ui.component(function(props)
local count, set_count = editor.ui.use_state(props.count)
local on_pressed = editor.ui.use_memo(make_listener, set_count)
return editor.ui.text_button {
text = tostring(count),
on_pressed = on_pressed
}
end)
editor.ui.use_state(init:any|function, [...:any])→(state:any, set_state:function)
A hook that adds local state to the component.
See editor.ui.component for hooks caveats and rules. If any of the arguments to use_state change during a component refresh (checked with ==), the current state will be reset to the initial one.
PARAMETERS
init |
anyfunction |
local state initializer, either initial data structure or function that produces the data structure |
[...] |
any |
used when init is a function, the args are passed to the initializer function
|
RETURNS
state |
any |
current local state, starts with initial state, then may be changed using the returned set_state function
|
set_state |
function |
function that changes the local state and causes the component to refresh. Pass a value to set the new state directly, or pass an updater function that receives the current state and any additional arguments; the updater's return value becomes the new state. |
EXAMPLES
local function increment(n)
return n + 1
end
local counter_button = editor.ui.component(function(props)
local count, set_count = editor.ui.use_state(props.count)
return editor.ui.text_button {
text = tostring(count),
on_pressed = function()
set_count(increment)
end
}
end)
editor.ui.vertical(props:editor.ui.vertical.props)→value:editor.component
Layout container that places its children in a vertical column one after another
PARAMETERS
props |
editor.ui.vertical.props |
component properties |
RETURNS
value |
editor.component |
UI component |
http.request(url:string, [opts:http.request.options])→response:http.request.response
Perform an HTTP request
PARAMETERS
url |
string |
request URL |
[opts] |
http.request.options |
request options |
RETURNS
response |
http.request.response |
HTTP response |
http.server.external_file_response(path:string, [status:integer], [headers:table<string, string>])→response:http.response
Create HTTP response that will stream the content of a file defined by the path
PARAMETERS
path |
string |
External file path, resolved against project root if relative |
[status] |
integer |
HTTP status code, an integer, default 200 |
[headers] |
table<string, string> |
HTTP response headers, a table from lower-case header names to header values |
RETURNS
response |
http.response |
HTTP response value, userdata |
http.server.json_response(value:any, [status:integer], [headers:table<string, string>])→response:http.response
Create HTTP response with a JSON value
PARAMETERS
value |
any |
Any Lua value that may be represented as JSON |
[status] |
integer |
HTTP status code, an integer, default 200 |
[headers] |
table<string, string> |
HTTP response headers, a table from lower-case header names to header values |
RETURNS
response |
http.response |
HTTP response value, userdata |
http.server.resource_response(resource_path:string, [status:integer], [headers:table<string, string>])→response:http.response
Create HTTP response that will stream the content of a resource defined by the resource path
PARAMETERS
resource_path |
string |
Resource path (starting with /)
|
[status] |
integer |
HTTP status code, an integer, default 200 |
[headers] |
table<string, string> |
HTTP response headers, a table from lower-case header names to header values |
RETURNS
response |
http.response |
HTTP response value, userdata |
http.server.response([status:integer], [headers:table<string, string>], [body:string])→response:http.response
Create HTTP response
PARAMETERS
[status] |
integer |
HTTP status code, an integer, default 200 |
[headers] |
table<string, string> |
HTTP response headers, a table from lower-case header names to header values |
[body] |
string |
HTTP response body |
RETURNS
response |
http.response |
HTTP response value, userdata |
http.server.route(path:string, [method:string], [as:"string"|"json"], [openapi:table<string, any>], handler:http.server.handler)→route:http.route
Create route definition for the editor's HTTP server
PARAMETERS
path |
string |
HTTP URI path, starts with /; may include path patterns ({name} for a single segment and {*name} for the rest of the request path) that will be extracted from the path and provided to the handler as a part of the request
|
[method] |
string |
HTTP request method, default "GET"
|
[as] |
"string""json" |
Request body converter, either "string" or "json"; the body will be discarded if not specified
|
[openapi] |
table<string, any> |
Optional OpenAPI Operation Object for this route method, exposed from /openapi.json. Must follow https://spec.openapis.org/oas/v3.0.3.html#operation-object.
|
handler |
http.server.handler |
Request handler. Return either a single response value or arguments accepted by http.server.response().
|
RETURNS
route |
http.route |
HTTP server route |
EXAMPLES
Receive JSON and respond with JSON:http.server.route(
"/json", "POST", "json",
function(request)
pprint(request.body)
return 200
end
)
http.server.route(
"/users/{user}/orders",
function(request)
print(request.user)
end
)
http.server.route(
"/files/{*file}",
function(request)
local attrs = editor.external_file_attributes(request.file)
if attrs.is_file then
return http.server.external_file_response(request.file)
elseif attrs.is_directory then
return 400
else
return 404
end
end
)
image.load_file(path:string)→image:editor.image
Load an image file for reading
PARAMETERS
path |
string |
External file path, resolved against project root if relative |
RETURNS
image |
editor.image |
image userdata |
image.pixel(image:editor.image, x:integer, y:integer)→(r:integer, g:integer, b:integer, a:integer)
Return the color of a pixel from a loaded image.
Coordinates are 1-based, with 1, 1 at the top-left corner.
PARAMETERS
image |
editor.image |
image userdata returned by image.load_file()
|
x |
integer |
1-based horizontal pixel coordinate |
y |
integer |
1-based vertical pixel coordinate |
RETURNS
r |
integer |
red channel, 0-255 |
g |
integer |
green channel, 0-255 |
b |
integer |
blue channel, 0-255 |
a |
integer |
alpha channel, 0-255 |
image.pixels(image:editor.image)→iterator:function
Iterate over pixels in a loaded image. The iterator returns pixels row by row from top-left to bottom-right. Coordinates are 1-based.
PARAMETERS
image |
editor.image |
image userdata returned by image.load_file()
|
RETURNS
iterator |
function |
iterator function returning x, y, r, g, b, a for each pixel
|
EXAMPLES
local img = image.load_file("assets/source.png")
local width, height = image.size(img)
for x, y, r, g, b, a in image.pixels(img) do
print(x, y, r, g, b, a)
end
image.size(image:editor.image)→(width:integer, height:integer)
Return the width and height of a loaded image.
PARAMETERS
image |
editor.image |
image userdata returned by image.load_file()
|
RETURNS
width |
integer |
image width in pixels |
height |
integer |
image height in pixels |
json.decode(json:string, [options:json.decode.options])
Decode JSON string to Lua value
PARAMETERS
json |
string |
json data |
[options] |
json.decode.options |
decoding options |
json.encode(value:any)
Encode Lua value to JSON string
PARAMETERS
value |
any |
any Lua value that may be represented as JSON |
localization.and_list(items:(nil|boolean|number|string|editor.message)[])→message:editor.message
Create a message pattern that renders a list with the "and" conjunction (for example: a, b, and c) once it is stringified
PARAMETERS
items |
(nil|boolean|number|string|editor.message)[] |
array of values; each value may be nil, boolean, number, string, or another message instance
|
RETURNS
message |
editor.message |
a userdata value that, when stringified with tostring(), will produce a localized text according to the currently selected language in the editor
|
localization.concat(items:(nil|boolean|number|string|editor.message)[], [separator:nil|boolean|number|string|editor.message])→message:editor.message
Create a message pattern that concatenates values (similar to table.concat) and performs the actual concatenation when stringified
PARAMETERS
items |
(nil|boolean|number|string|editor.message)[] |
array of values; each value may be nil, boolean, number, string, or another message instance
|
[separator] |
nilbooleannumberstringeditor.message |
optional separator inserted between values; defaults to an empty string |
RETURNS
message |
editor.message |
a userdata value that, when stringified with tostring(), will produce a localized text according to the currently selected language in the editor
|
localization.message(key:string, [vars:table<string, nil|boolean|number|string|editor.message>])→message:editor.message
Create a message pattern for a localization key defined in an .editor_localization file; the actual localization happens when the returned value is stringified
PARAMETERS
key |
string |
localization key defined in an .editor_localization file
|
[vars] |
table<string, nil|boolean|number|string|editor.message> |
optional table with variables to be substituted in the localized string that uses ICU Message Format syntax; keys must be strings; values must be either nil, boolean, number, string, or another message instance
|
RETURNS
message |
editor.message |
a userdata value that, when stringified with tostring(), will produce a localized text according to the currently selected language in the editor
|
localization.or_list(items:(nil|boolean|number|string|editor.message)[])→message:editor.message
Create a message pattern that renders a list with the "or" conjunction (for example: a, b, or c) once it is stringified
PARAMETERS
items |
(nil|boolean|number|string|editor.message)[] |
array of values; each value may be nil, boolean, number, string, or another message instance
|
RETURNS
message |
editor.message |
a userdata value that, when stringified with tostring(), will produce a localized text according to the currently selected language in the editor
|
tilemap.tiles.clear(tiles:editor.tiles)→tiles:editor.tiles
Remove all tiles
PARAMETERS
tiles |
editor.tiles |
unbounded 2d grid of tiles |
RETURNS
tiles |
editor.tiles |
unbounded 2d grid of tiles |
tilemap.tiles.get_info(tiles:editor.tiles, x:integer, y:integer)→info:tilemap.tiles.get_info.result|nil
Get full information from a tile at a particular coordinate
PARAMETERS
tiles |
editor.tiles |
unbounded 2d grid of tiles |
x |
integer |
x coordinate of a tile |
y |
integer |
y coordinate of a tile |
RETURNS
info |
tilemap.tiles.get_info.resultnil |
full tile information, or nil if no tile is set at the coordinate |
tilemap.tiles.get_tile(tiles:editor.tiles, x:integer, y:integer)→tile_index:integer
Get a tile index at a particular coordinate
PARAMETERS
tiles |
editor.tiles |
unbounded 2d grid of tiles |
x |
integer |
x coordinate of a tile |
y |
integer |
y coordinate of a tile |
RETURNS
tile_index |
integer |
1-indexed tile index of a tilemap's tilesource |
tilemap.tiles.iterator(tiles:editor.tiles)→iter:function
Create an iterator over all tiles in a tiles data structure When iterating using for loop, each iteration returns x, y and tile index of a tile in a tile map
PARAMETERS
tiles |
editor.tiles |
unbounded 2d grid of tiles |
RETURNS
iter |
function |
iterator |
EXAMPLES
Iterate over all tiles in a tile map:local layers = editor.get("/level.tilemap", "layers")
for i = 1, #layers do
local tiles = editor.get(layers[i], "tiles")
for x, y, i in tilemap.tiles.iterator(tiles) do
print(x, y, i)
end
end
tilemap.tiles.new()→tiles:editor.tiles
Create a new unbounded 2d grid data structure for storing tilemap layer tiles
PARAMETERS
None
RETURNS
tiles |
editor.tiles |
unbounded 2d grid of tiles |
tilemap.tiles.remove(tiles:editor.tiles, x:integer, y:integer)→tiles:editor.tiles
Remove a tile at a particular coordinate
PARAMETERS
tiles |
editor.tiles |
unbounded 2d grid of tiles |
x |
integer |
x coordinate of a tile |
y |
integer |
y coordinate of a tile |
RETURNS
tiles |
editor.tiles |
unbounded 2d grid of tiles |
tilemap.tiles.set(tiles:editor.tiles, x:integer, y:integer, tile_or_info:integer|tilemap.tiles.set.info)→tiles:editor.tiles
Set a tile at a particular coordinate
PARAMETERS
tiles |
editor.tiles |
unbounded 2d grid of tiles |
x |
integer |
x coordinate of a tile |
y |
integer |
y coordinate of a tile |
tile_or_info |
integertilemap.tiles.set.info |
Either 1-indexed tile index of a tilemap's tilesource or full tile information |
RETURNS
tiles |
editor.tiles |
unbounded 2d grid of tiles |
zip.pack(output_path:string, [opts:zip.pack.options], entries:zip.pack.entries)
Create a ZIP archive
PARAMETERS
output_path |
string |
output zip file path, resolved against project root if relative |
[opts] |
zip.pack.options |
compression options |
entries |
zip.pack.entries |
files and folders to include in the archive |
EXAMPLES
Archive a file and a folder:zip.pack("build.zip", {"build", "game.project"})
zip.pack("build.zip", {
{"build/wasm-web", "."},
{"configs/prod.json", "config.json"}
})
zip.pack("build.zip", {method = zip.METHOD.STORED}, {
"build",
"resources"
})
zip.pack("build.zip", {
{"assets", method = zip.METHOD.STORED},
"build/wasm-web"
})
zip.pack("build.zip", {
"build",
{"../secrets/auth-key.txt", "auth-key.txt"}
})
zip.unpack(archive_path:string, [target_path:string], [opts:zip.unpack.options], [paths:string[]])
Extract a ZIP archive
PARAMETERS
archive_path |
string |
zip file path, resolved against project root if relative |
[target_path] |
string |
target path for extraction, defaults to parent of archive_path if omitted
|
[opts] |
zip.unpack.options |
extraction options; conflict handling defaults to zip.ON_CONFLICT.ERROR
|
[paths] |
string[] |
entries to extract, relative string paths |
EXAMPLES
Extract everything to a build dir:zip.unpack("build/dev/resources.zip")
zip.unpack(
"build/dev/resources.zip",
"build/dev/tmp",
)
zip.unpack(
"build/dev/resources.zip",
{on_conflict = zip.ON_CONFLICT.OVERWRITE}
)
zip.unpack(
"build/dev/resources.zip",
{"config.json"}
)
zlib.deflate(buf:string)→buf:string
Deflate (compress) a buffer
PARAMETERS
buf |
string |
buffer to deflate |
RETURNS
buf |
string |
deflated buffer |
zlib.inflate(buf:string)→buf:string
Inflate (decompress) a buffer
PARAMETERS
buf |
string |
buffer to inflate |
RETURNS
buf |
string |
inflated buffer |
Editor platform id.
A string, either:
- "x86_64-win32"
- "x86_64-macos"
- "arm64-macos"
- "x86_64-linux"