1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
Using Commands
==============
The Command Button allows you to create and run shell commands (other
programs) from Tiled.
You may setup as many commands as you like. This is useful if you edit
maps for multiple games and you want to set up a command for each game.
Or you could setup multiple commands for the same game that load
different checkpoints or configurations.
The Command Button
------------------
It is located on the main toolbar to the right of the redo button.
Clicking on it will run the default command (the first command in the
command list). Clicking the arrow next to it will bring down a menu that
allows you to run any command you have set up, as well as an option to
open the Edit Commands dialog. You can also find all the commands in the
File menu.
Apart from this, you can set up custom keyboard shortcuts for each
command.
Editing Commands
----------------
The 'Edit Commands' dialog contains a list of commands. Each command has
several properties:
Name
The name of the command as it will be shown in the drop
down list, so you can easily identify it.
Executable
The executable to run. It should either be a full
path or the name of an executable in the system PATH.
Arguments
The arguments for running the executable.
Working directory
The path to the working directory.
Shortcut
A custom key sequence to trigger the command. You can use 'Clear'
to reset the shortcut.
Show output in Console view
If this is enabled, then the output (stdout and stderr) of this
command will be displayed in the Console. You can find the
Console in *View > Views and Toolbars > Console*.
Save map before executing
If this is enabled, then the current map will be saved before
executing the command.
Enabled
A quick way to disable commands and remove them from the drop down list.
The default command is the first enabled command.
Note that if the executable or any of its arguments contain spaces,
these parts need to be quoted.
Substituted Variables
~~~~~~~~~~~~~~~~~~~~~
In the executable, arguments and working directory fields, you can use
the following variables:
``%mapfile``
the full path of the current file (either map or tileset).
``%mappath``
the path in which the current file is located.
.. raw:: html
<div class="new new-prev">Since Tiled 1.4</div>
``%projectpath``
the path in which the current project is located.
``%objectclass``
the class of the currently selected object, if any (also available as
``%objecttype`` for compatibility with Tiled < 1.9).
``%objectid``
the ID of the currently selected object, if any.
``%layername``
the name of the currently selected layer.
.. raw:: html
<div class="new new-prev">Since Tiled 1.6</div>
``%tileid``
a comma-separated list with the IDs of the selected tiles, if any.
.. raw:: html
<div class="new">New in Tiled 1.9</div>
``%worldfile``
the full path of the world the current map is part of, if any.
For the working directory field, you can additionally use the following
variable:
``%executablepath``
the path to the executable.
Example Commands
----------------
Launching a custom game called "mygame" with a -loadmap parameter and
the mapfile:
::
mygame -loadmap %mapfile
On Mac, remember that Apps are folders, so you need to run the actual
executable from within the ``Contents/MacOS`` folder:
::
/Applications/TextEdit.app/Contents/MacOS/TextEdit %mapfile
Or use ``open`` (and note the quotes since one of the arguments contains
spaces):
::
open -a "/Applications/CoronaSDK/Corona Simulator.app" /Users/user/Desktop/project/main.lua
Some systems also have a command to open files in the appropriate
program:
- OSX: ``open %mapfile``
- GNOME systems like Ubuntu: ``gnome-open %mapfile``
- FreeDesktop.org standard: ``xdg-open %mapfile``
|