Available actions for tiled.trigger().
Currently selected asset, or null
if no file is open.
Can be assigned any open asset in order to change the active asset, or
a newly created asset to open it in the editor.
The activeAsset has changed.
The directory containing the Tiled executable.
Processor architecture. One of x64
, x86
or unknown
.
An asset is about to be closed.
An asset is about to be saved. Can be used to make last-minute changes.
A new asset has been created.
An asset has been opened.
An asset has been reloaded.
An asset has been saved.
The system- and user-specific path where global extensions are installed.
Note that normally it is not necessary to use this path, since the "ext:"
prefix can be used to refer to files shipping with extensions. Also, there
is a __filename
property containing the full file path of the currently
evaluated file.
Also note that a Tiled project can have its own additional extensions directory, to make it easier to share extensions with a team or keep them under version control.
Access the editor used when editing maps.
List of supported map format names. Use mapFormat to get the corresponding format object to read and write files.
Available menus for tiled.extendMenu().
List of currently opened assets.
Operating system. One of windows
, macos
, linux
or
unix
(for any other UNIX-like system).
Currently opened project. If no project is open, the properties of the project will be blank.
The file path of the currently loaded project, or empty if no project is currently loaded.
The version of Qt which Tiled is running against.
A list of arguments passed to a script that is evaluated from the command-line.
Scripts can be executed on the command-line using
tiled --evaluate <script-file> [args]
.
Access the editor used when editing tilesets.
List of supported tileset format names. Use tilesetFormat to get the corresponding format object to read and write files.
Currently used version of Tiled.
A list of all currently loaded worlds.
Signal emitted when any world is loaded, unloaded, reloaded or changed.
Shows a modal warning dialog to the user with the given text and optional title.
Closes the given asset without checking for unsaved changes (to confirm the loss of any unsaved changes, set activeAsset and trigger the "Close" action instead).
Creates a color based on the given color name (i.e. red or #ff0000).
See QColor::fromString for the accepted color names.
Creates a color with the RGB value r, g, b, and the alpha-channel (transparency) value of a (which defaults to 1.0).
Compresses the given data using the given compression method and compression level.
When no compression method is given, defaults to Zlib compression. The compression level defaults to the default for the respective method.
Shows a yes/no dialog to the user with the given text and optional
title. Returns true
or false
.
Creates a cursor with the given shape.
Creates a cursor with the given image and the optional hotspot.
Decompresses the given data using the given compression method.
When no compression method is given, defaults to Zlib compression.
Outputs the given text in the Console window as error message and creates an issue in the Issues window.
When the issue is activated (with double-click or Enter key) the given callback function is invoked.
Executes the first custom command with the given name, as if it was triggered manually. Works also with commands that are not currently enabled.
Raises a script error if the command is not found.
For more control over the executed binary, use Process instead.
Extends the menu with the given ID. Supports both a list of items or a single item. Available menu IDs can be obtained using the tiled.menus property.
If a menu item does not include a before
property, the value is
inherited from the previous item. When this property is not set at
all, the items are appended to the end of the menu.
Example that adds a custom action to the "Edit" menu, before the "Select All" action and separated by a separator:
tiled.extendMenu("Edit", [
{ action: "CustomAction", before: "SelectAll" },
{ separator: true }
]);
The "CustomAction" will need to have been registered before using tiled.registerAction().
Creates a FilePath object with the given URL.
Load a world contained in a .world file in the path fileName.
Outputs the given text in the Console window as regular text.
Returns the map format object with the given name, or
undefined
if no object was found. See the
mapFormats property for more info.
Returns the map format object that can read the given file, or
undefined
if no object was found.
Creates an ObjectRef object with the given ID.
Requests to open the asset with the given file name. Returns a
reference to the opened asset, or null
in case there was a
problem.
Shows a dialog that asks the user to enter some text, along with the
given label and optional title. The optional text
parameter
provides the initial value of the text. Returns the entered text.
For more complex input requirements, consider creating a custom Dialog.
Shows a dialog which asks the user to choose an existing directory. Optionally override the starting directory of the dialog or its title.
Returns the absolute path of the chosen directory, or an empty string if the user cancels the dialog.
Shows a dialog which asks the user to choose an existing file. Optionally override the starting directory of the dialog or its title. You can also restrict to only certain file types by specifying filters.
Returns the absolute path of the chosen file, or an empty string if the user cancels the dialog.
Shows a dialog which asks the user to choose one or more existing files. Optionally override the starting directory of the dialog or its title. You can also restrict to only certain file types by specifying filters.
Returns an array of the absolute paths of the chosen files, or an empty array if the user cancels the dialog.
Shows a dialog which asks the user to choose a destination for saving a file. If the user chooses a file path which already exists, they will be asked to confirm that they want to overwrite the file. Optionally override the starting directory of the dialog or its title. You can also restrict to only certain file types by specifying filters.
Returns the absolute path of the chosen file, or an empty string if the user cancels the dialog.
Creates a PropertyValue object with the given type and value.
When creating an enum value, the name of the value can be used (or string with comma-separated names, in case of using flags). However, the created PropertyValue object will always use numbers for enum values.
Registers a new action with the given id
and callback
(which is
called when the action is triggered). The returned action object can
be used to set (and update) various properties of the action.
The shortcut will currently only work when the action is added to a menu using tiled.extendMenu().
Registers a new map format that can then be used to open and/or save maps in that format.
If a map format is already registered with the same shortName
, the
existing format is replaced. The short name can also be used to
specify the format when using --export-map
on the command-line, in
case the file extension is ambiguous or a different one should be
used.
Like registerMapFormat, but registers a custom tileset format instead.
Registers a custom tool that will become available on the Tools tool bar of the Map Editor.
If a tool is already registered with the same shortName
the
existing tool is replaced.
Reloads the given asset from disk, without checking for unsaved
changes. This invalidates the previous script reference to the
asset, hence the new reference is returned for convenience. Returns
null
if reloading failed.
Returns the tileset format object with the given name, or
undefined
if no object was found. See the
tilesetFormats property for more info.
Returns the tileset format object that can read the given file, or
undefined
if no object was found.
This function can be used to trigger any registered action. This includes most actions you would normally trigger through the menu or by using their shortcut.
Use the tiled.actions property to get a list of all available actions.
Actions that are checkable will toggle when triggered.
Unload all currently loaded worlds.
Unload a world contained in a .world file in the path fileName.
When given two versions, returns whether the first version comes before the second version. When given one version, it returns whether Tiled's current version comes before the given version.
Outputs the given text in the Console window as warning message and creates an issue in the Issues window.
When the issue is activated (with double-click or Enter key) the given callback function is invoked.
Generated using TypeDoc
The
tiled
module is the main entry point and provides properties, functions and signals which are documented below.