Debian Codegraph @

doc/scripts/editor.html

raw
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <html><head>
3 <!--
4 ---- (c) Copyright 2002-2005 by Lutz Sammer, Russell Smith, Francois Beerten
5
6 ---- This program is free software; you can redistribute it and/or modify
7 ---- it under the terms of the GNU General Public License as published by
8 ---- the Free Software Foundation; only version 2 of the License.
9 ----
10 ---- This program is distributed in the hope that it will be useful,
11 ---- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ---- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ---- GNU General Public License for more details.
14 ----
15 ---- You should have received a copy of the GNU General Public License
16 ---- along with this program; if not, write to the Free Software
17 ---- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18 ---- 02111-1307, USA.
19 -->
20 <title>Bos Wars Scripting API: Editor</title>
21 <meta http-equiv="Content-Type" content="text/html; CHARSET=iso-8859-1">
22 <link rel="stylesheet" type="text/css" href="scripts.css">
23 </head>
24 <body>
25 <h1>Bos Wars Scripting API: Editor</h1>
26 <hr>
27 <a href="../index.html">Bos Wars</a>
28 <a href="../faq.html">FAQ</a>
29 <a href="config.html">PREV</a>
30 <a href="game.html">NEXT</a>
31 <a href="index.html">LUA Index</a>
32 <hr>
33 <a href="#Editor">Editor</a>
34 <a href="#EditorCommandLine">EditorCommandLine</a>
35 <a href="#EditorEditing">EditorEditing</a>
36 <a href="#EditorNotRunning">EditorNotRunning</a>
37 <a href="#EditorSaveMap">EditorSaveMap</a>
38 <a href="#EditorStarted">EditorStarted</a>
39 <a href="#SetEditorPatchIcon">SetEditorPatchIcon</a>
40 <a href="#SetEditorSelectIcon">SetEditorSelectIcon</a>
41 <a href="#SetEditorStartUnit">SetEditorStartUnit</a>
42 <a href="#SetEditorUnitsIcon">SetEditorUnitsIcon</a>
43 <a href="#StartEditor">StartEditor</a>
44 <a href="#StartPatchEditor">StartPatchEditor</a>
45 <hr>
46 <h2>Intro - Introduction to editor functions and variables</h2>
47
48 <p>These affect only the map editor or the patch editor, not the game
49 itself.</p>
50
51 <h2>Functions</h2>
52
53 <a name="EditorSaveMap"></a>
54 <h3>EditorSaveMap("name.map")</h3>
55
56 <p>Saves the map being edited in the map editor.</p>
57
58 <dl>
59 <dt>"name.map"</dt>
60 <dd>The name of the directory to which this function will save the
61 map files. This name must end with ".map".</dd>
62 <dt><i>RETURNS</i></dt>
63 <dd>0 on success, or -1 on error.</dd>
64 </dl>
65
66 <a name="SetEditorPatchIcon"></a>
67 <h3>SetEditorPatchIcon("icon-name")</h3>
68
69 <p>Set the icon of the button that activates patch-placement mode in
70 the map editor. In this mode, the map editor shows a list of patch
71 types, and the user can insert, move, and remove patches on the
72 map.</p>
73
74 <dl>
75 <dt>"icon-name"</dt>
76 <dd>The name of the icon.</dd>
77 <dt><i>RETURNS</i></dt>
78 <dd>Nothing</dd>
79 </dl>
80
81 <h4>Example</h4>
82
83 <pre class="lua">
84 -- Use "icon-editor-patch" for the map editor's patches icon.
85 SetEditorPatchIcon("unit-editor-patch")
86 </pre>
87
88 <a name="SetEditorSelectIcon"></a>
89 <h3>SetEditorSelectIcon("icon-name")</h3>
90
91 <p>Set the icon that is used in the editor to indicate selection.</p>
92
93 <dl>
94 <dt>"icon-name"</dt>
95 <dd>The name of the icon.</dd>
96 <dt><i>RETURNS</i></dt>
97 <dd>Nothing</dd>
98 </dl>
99
100 <h4>Example</h4>
101
102 <pre class="lua">
103 -- Use "icon-human-patrol-land" for the editor's select icon.
104 SetEditorSelectIcon("icon-human-patrol-land")
105 </pre>
106
107 <a name="SetEditorUnitsIcon"></a>
108 <h3>SetEditorUnitsIcon("icon-name")</h3>
109
110 <p>Set the icon of the button that activates unit-placement mode in
111 the map editor. In this mode, the map editor shows a list of unit
112 types, and the user can insert, move, and remove units on the
113 map.</p>
114
115 <dl>
116 <dt>"icon-name"</dt>
117 <dd>The name of the icon.</dd>
118 <dt><i>RETURNS</i></dt>
119 <dd>Nothing</dd>
120 </dl>
121
122 <h4>Example</h4>
123
124 <pre class="lua">
125 -- Use "icon-footman" for the map editor's units icon.
126 SetEditorUnitsIcon("unit-footman")
127 </pre>
128
129 <a name="SetEditorStartUnit"></a>
130 <h3>SetEditorStartUnit("unit-start")</h3>
131
132 <p>Set the unit used in the map editor to show the start location.</p>
133
134 <dl>
135 <dt>unit</dt>
136 <dd>The name of the unit.</dd>
137 <dt><i>RETURNS</i></dt>
138 <dd>Nothing</dd>
139 </dl>
140
141 <p>See also <a href="#Editor.StartUnit">Editor.StartUnit</a>.</p>
142
143 <h4>Example</h4>
144
145 <pre class="lua">
146 SetEditorStartUnit("unit-start-location")
147 </pre>
148
149 <a name="StartEditor"></a>
150 <h3>StartEditor("presentation.smp")</h3>
151
152 <p>Starts the map editor.</p>
153
154 <dl>
155 <dt>"presentation.smp"</dt>
156 <dd>The name of the presentation file of the map that the map editor
157 will load, or an empty string to create a new map from
158 scratch.</dd>
159 <dt><i>RETURNS</i></dt>
160 <dd>Nothing</dd>
161 </dl>
162
163 <a name="StartPatchEditor"></a>
164 <h3>StartPatchEditor("patch-name")</h3>
165
166 <p>Starts the patch editor.</p>
167
168 <dl>
169 <dt>"patch-name"</dt>
170 <dd>The name of patch type you want to edit.</dd>
171 <dt><i>RETURNS</i></dt>
172 <dd>Nothing</dd>
173 </dl>
174
175 <h2>Variables</h2>
176
177 <a name="Editor"></a>
178 <h3>Editor</h3>
179
180 <p>This variable refers to an object that has at least the following
181 properties and methods:
182 <a href="#Editor.Running">Running</a>
183 <a href="#Editor.ShowTerrainFlags">ShowTerrainFlags</a>
184 <a href="#Editor.StartUnit">StartUnit</a>
185 <a href="#Editor.TileSelectedPatch">TileSelectedPatch</a>
186 <a href="#Editor.UnitTypes">UnitTypes</a>
187 </p>
188
189 <a name="Editor.Running"></a>
190 <h4>Editor.Running = integer</h4>
191
192 <p>Whether the map editor is running. When the user starts the map
193 editor, the engine sets Editor.Running = EditorEditing. When a Lua
194 script sets Editor.Running = EditorNotRunning, the map editor exits.
195 The value of this property also affects what the engine shows on the
196 screen: for example, patches may get borders around them when the
197 editor is running.</p>
198
199 <p>The value of the Editor.Running property should be one of the
200 following constants defined by the engine:</p>
201
202 <dl>
203 <dt><a name="EditorNotRunning">EditorNotRunning</a></dt>
204 <dd>The editor is not running.</dd>
205 <dt><a name="EditorStarted">EditorStarted</a></dt>
206 <dd>This constant is not used.</dd>
207 <dt><a name="EditorCommandLine">EditorCommandLine</a></dt>
208 <dd>This constant is not used.</dd>
209 <dt><a name="EditorEditing">EditorEditing</a></dt>
210 <dd>The editor is running; the user can edit the map.
211 A Lua script can tell the editor to exit,
212 by setting Editor.Running = EditorNotRunning.</dd>
213 </dl>
214
215 <a name="Editor.ShowTerrainFlags"></a>
216 <h4>Editor.ShowTerrainFlags = boolean</h4>
217
218 <p>If true, the editor shows the terrain flags of map tiles as colored
219 rectangles. This makes it easier to check that the terrain flags
220 have been correctly and consistently defined in patch types, and
221 that there is enough space for large units to move between
222 obstacles.</p>
223
224 <a name="Editor.StartUnit"></a>
225 <h4>Editor.StartUnit = const CUnitType*</h4>
226
227 <p>The value of this read-only property is the CUnitType object
228 that the editor will use to show the start location of each player.
229 Lua scripts can change it by calling
230 <a href="#SetEditorStartUnit">SetEditorStartUnit</a>.</p>
231
232 <a name="Editor.UnitTypes"></a>
233 <h4>Editor.UnitTypes = vector</h4>
234
235 <p>A sorted list of unit-types for the editor.
236 This is only a temporary hack for better sorted units.
237 Because this is a C++ vector rather than a Lua table,
238 the key numbers start from 0 rather than 1.</p>
239
240 <h5>Example</h5>
241
242 <pre class="lua">
243 Editor.UnitTypes.clear()
244 Editor.UnitTypes.push_back("unit-vault")
245 Editor.UnitTypes.push_back("unit-apcs")
246 Editor.UnitTypes.push_back("unit-medic")
247 Editor.UnitTypes.push_back("unit-bazoo")
248 Editor.UnitTypes.push_back("unit-assault")
249 Editor.UnitTypes.push_back("unit-grenadier")
250 Editor.UnitTypes.push_back("unit-camp")
251 Editor.UnitTypes.push_back("unit-hosp")
252 </pre>
253
254 <a name="Editor.TileSelectedPatch"></a>
255 <h4>Editor:TileSelectedPatch()</h4>
256
257 <p>Fills the map with patches of the selected type,
258 removing all other patches.</p>
259
260 <dl>
261 <dt><i>RETURNS</i></dt>
262 <dd>Nothing</dd>
263 </dl>
264
265 <hr>
266 All trademarks and copyrights on this page are owned by their respective owners.
267 <address>(c) 2002-2007 by <a href="http://boswars.org">
268 The Bos Wars Project</a></address></body></html>