Studio › Manual › Editor plugins

Plugin API reference

A plugin's scripts run once when it loads. Register what it adds there; the functions you give run later. Every function is listed with examples in docs/PLUGINS.md.

  • Adding: editor_add_command(id, title, shortcut, function) (shortcut like "ctrl+shift+cmd+7" or ""), editor_add_panel(id, title, controls, function(control, values)) (controls: structs with kind button, text, number, checkbox or list, and id, label, value, items, help), editor_add_importer(extension, title, function(file_name, text)), editor_on(event, function(arg)) for project_opened, asset_saved, before_build, after_build.
  • Output: editor_log(...), show_debug_message(...).
  • The project: editor_project_name(), editor_assets([kind]), editor_selected_assets(), editor_asset_kind(name), editor_asset_get(name) (the asset's file as a struct), editor_asset_create(kind, name), editor_asset_rename(name, new_name), editor_asset_set(name, key, value).
  • Text files: editor_file_read(path), editor_file_write(path, text), editor_file_exists(path), editor_file_list([folder]); the plugin's own data: editor_data_read(path), editor_data_write(path, text).
  • The open room: editor_room() (name, size, layers, instances with selected), editor_room_add_instance(layer, object, x, y, [values]), editor_room_set_instance(name, values), editor_room_delete_instance(name), editor_room_add_layer(kind, name, [tileset]), editor_room_set_layer(name, values), editor_room_set_tiles(layer, [[column, row, tile], …]), editor_room_select(names). Room changes are made when the function returns.
  • Panels: editor_panel_get(panel, control), editor_panel_set(panel, control, value) (a list's items with an array).
  • Shell (when allowed): editor_shell(command) returns { status, output }.

Keys are shown as on the Mac: ⌘ Command, ⌥ Option, ⌃ Control, ⇧ Shift. Studio for Windows shows its own keys beside each menu item.