4 |
4 |
5 == Introduction == |
5 == Introduction == |
6 |
6 |
7 Version 0.9.13 of Hedgewars introduced the ability to use Lua scripts to modify Hedgewars behaviour for different maps without having to recompile the whole game. The till then used triggers (only appeared in training maps) were removed. |
7 Version 0.9.13 of Hedgewars introduced the ability to use Lua scripts to modify Hedgewars behaviour for different maps without having to recompile the whole game. The till then used triggers (only appeared in training maps) were removed. |
8 |
8 |
9 Lua is an easy to learn scripting language that's implemented using open/v source libraries. If you'd like to learn more about Lua, have a look at [http://www.lua.org Lua's official homepage]. Even though its easy to learn syntax this wiki page won't explain all basics of using Lua, e.g. declaring variables or using control structures. There are tons of step-by-step tutorials and documentation available on the internet. Just throw "Lua" into your favourite search engine and give it a try. |
9 Lua is an easy to learn scripting language that’s implemented using open source libraries. If you’d like to learn more about Lua, have a look at [http://www.lua.org Lua's official homepage]. Even though its easy to learn syntax this wiki page won't explain all basics of using Lua, e.g. declaring variables or using control structures. There are tons of step-by-step tutorials and documentation available on the internet. Just throw “Lua” into your favourite search engine and give it a try. |
10 |
10 |
11 |
11 |
12 How Hedgewars handles Lua scripts As of Version 0.9.13 Hedgewars supports Lua scripts for two similar tasks: Define tutorial missions or provide special map behaviour for precreated maps. |
12 === How Hedgewars handles Lua scripts === |
13 |
13 As of Version 0.9.20, Hedgewars supports Lua scripts for two similar tasks: Define tutorial missions, campaign missions or provide special map behaviour for precreated maps. It is also used for multiplayer scripts to create new game styles. |
14 |
14 |
15 === About this wiki page === |
15 === About this wiki page === |
16 This page tends to become outdated. For a list of undocumented functions, see [http://hw.ercatec.net/docs/lua_wiki_check.php]. |
16 This page tends to become outdated. For a list of undocumented functions, see [http://hw.ercatec.net/docs/lua_wiki_check.php]. |
17 |
17 |
18 |
18 |
19 === Tutorial missions === |
19 === Tutorial missions === |
20 Tutorial missions are located within text files inside "share/hedgewars/Data/Missions/Training". The game will list all files with the lua extension inside this directory in the Training selection screen. You'll find some premade example scripts within this directory that contain several comments on the script lines and what they do./ |
20 Tutorial missions are located within text files inside `share/hedgewars/Data/Missions/Training`. The game will list all files with the lua extension inside this directory in the Training selection screen. You’ll find some premade example scripts within this directory that contain several comments on the script lines and what they do. |
21 |
21 |
22 |
22 |
23 === Special maps === |
23 === Special maps === |
24 In addition to tutorial missions predrawn maps (maps not created using the random map creator) may contain a single lua script file named "map.lua". If it's there it will be used once the map is played. This way it's possible to play maps alone or over the internet using custom goals. Maps containing lua scripts will be listed with a "Mission:" prefix in map selection. |
24 In addition to tutorial missions predrawn maps (maps not created using the random map creator) may contain a single lua script file named `map.lua`. If it’s there, it will be used once the map is played. This way it’s possible to play maps alone or over the internet using custom goals. Mission maps can be found in singleplayer mode under the “training” button and in multiplayer mode, it is selectable as a map type. |
|
25 |
|
26 See also [PresetMaps] for more information about such maps. |
25 |
27 |
26 |
28 |
27 === How Lua scripts are used === |
29 === How Lua scripts are used === |
28 Several parts of script files are executed multiple times. In general, the whole script file is read while loading the map. Declarations as well as function calls outside functions are executed at once. Later on the game will call special predefined function names at special occassions such as the creation of new game objects (called gears). |
30 Several parts of script files are executed multiple times. In general, the whole script file is read while loading the map. Declarations as well as function calls outside functions are executed at once. Later on the game will call special predefined function names at special occassions such as the creation of new game objects (called “gears”). |
29 |
31 |
30 |
32 |
31 === Important things to know === |
33 === Important things to know === |
32 It is possible to play missions in multiplayer. However this requires all participating players to have the exact same version of the map files, including the "map.lua" script file. If this isn't the case the game will probably desync and kick at least the one player using a different version of the map files. To avoid problems when running prepackaged maps, you should never modify any maps provided with the Hedgewars default package. Instead, create a copy of the existing map and modify this one. Feel free to share your work on the forums. |
34 It is possible to play missions in multiplayer. However this requires all participating players to have the exact same version of the map files, including the `map.lua` script file. If this isn’t the case the game will probably desync and “kick” at least the one player using a different version of the map files. To avoid problems when running prepackaged maps, you should never modify any maps provided with the Hedgewars default package. Instead, create a copy of the existing map and modify this one. Feel free to share your work on the forums. |
33 Another thing to note is the current status of our scripting implementation. Similar to the whole game, this is still work in progress and we can't guarantee that scripts working in this version will run in future revisions of the game as we might extend, change or rename parts of the scripting engine. |
35 |
|
36 Another thing to note is the current status of our scripting implementation. Similar to the whole game, this is still work in progress and we can’t guarantee that scripts working in this version will run in future revisions of the game as we might extend, change or rename parts of the scripting engine. |
34 |
37 |
35 === Global variables/constants === |
38 === Global variables/constants === |
36 Global variables are used by the game to interact with the scripts by passing and retrieving their values. While some of the variables are never read by the engine some allow you to modify the engine's behaviour, e.g. the theme to be used for the current map. |
39 Global variables are used by the game to interact with the scripts by passing and retrieving their values. While some of the variables are never read by the engine some allow you to modify the engine’s behaviour, e.g. the theme to be used for the current map. |
37 |
40 |
38 |
41 |
39 === Functions called by the game: Event Handlers === |
42 === Functions called by the game: Event handlers === |
40 After successfully loading the Lua script the game will call the following functions on different occasions. To be used, they have to use the exact same name as defined below. |
43 After successfully loading the Lua script the game will call the following functions on different occasions. To be used, they have to use the exact same name as defined below. |
41 |
44 |
42 == Data types == |
45 == Data types == |
|
46 This section defines some commonly used non-primitive parameter types which are used in multiple functions. This section is a bit incomplete at the moment. |
|
47 |
43 === Color === |
48 === Color === |
44 Some functions take a `color` parameter. |
49 Some functions take a `color` parameter. |
45 |
50 |
46 Colors are stored in RGB and are always specified as a three-byte number, where each byte defines a component. The value 0 means no intensity and 255 is largest intensity of the component. |
51 Colors are stored in RGB and are always specified as a three-byte number, where each byte defines a component. The value 0 means no intensity and 255 is largest intensity of the component. |
47 The first byte is for the red component, the second byte for the green component and the third byte for the blue component. |
52 The first byte is for the red component, the second byte for the green component and the third byte for the blue component. |
163 *Tip*: If you use the Params library (`/Scripts/Params.lua`), you can make the task of dissecting the string into useful values a bit easier, but it’s not required. (The Params library is not documented yet, however). |
166 *Tip*: If you use the Params library (`/Scripts/Params.lua`), you can make the task of dissecting the string into useful values a bit easier, but it’s not required. (The Params library is not documented yet, however). |
164 |
167 |
165 *Tip*: If you use this callback, make sure to document the interpretation of the parameters so others know how to set the parameters properly. |
168 *Tip*: If you use this callback, make sure to document the interpretation of the parameters so others know how to set the parameters properly. |
166 |
169 |
167 === <tt>onGameTick()</tt> === |
170 === <tt>onGameTick()</tt> === |
168 |
171 This function is called on every game tick, i.e. 1000 times a second. If you just need to check on something periodically, consider `onGameTick20`. |
169 <blockquote>This function is called on every game tick, i.e. 1000 times a second. If you just need to check on something periodically, consider... |
|
170 </blockquote> |
|
171 |
172 |
172 === <tt>onGameTick20()</tt> === |
173 === <tt>onGameTick20()</tt> === |
173 |
174 This function is called every 20 game ticks, which equals 50 times a second. It reduces Lua overhead for simple monitoring that doesn’t need to happen every single tick. |
174 <blockquote>This function is called every 20 game ticks, i.e. 50 times a second. It reduces lua overhead for simple monitoring that doesn't need to happen every single tick. |
|
175 </blockquote> |
|
176 |
175 |
177 === <tt>onNewTurn()</tt> === |
176 === <tt>onNewTurn()</tt> === |
178 |
177 This function calls at the start of every turn. |
179 <blockquote>This function calls at the start of every turn. |
178 |
180 </blockquote> |
|
181 === <tt>onGearAdd(gearUid)</tt> === |
179 === <tt>onGearAdd(gearUid)</tt> === |
182 |
180 This function is called when a new gear is added. Useful in combination with `GetGearType(gearUid)`. |
183 <blockquote>This function is called when a new gear is added. Useful in |
181 |
184 combination with <tt>!GetGearType(gearUid)</tt>. |
|
185 </blockquote> |
|
186 === <tt>onGearDelete(gearUid)</tt> === |
182 === <tt>onGearDelete(gearUid)</tt> === |
187 |
183 This function is called when a new gear is deleted. Useful in combination with `GetGearType(gearUid)`. |
188 <blockquote>This function is called when a new gear is deleted. Useful in |
184 |
189 combination with <tt>!GetGearType(gearUid)</tt>. |
|
190 </blockquote> |
|
191 === <tt>onGearDamage(gearUid, damage)</tt> === |
185 === <tt>onGearDamage(gearUid, damage)</tt> === |
192 |
186 This function is called when a gear is damaged. |
193 <blockquote>This function is called when a gear is damaged. |
|
194 </blockquote> |
|
195 |
187 |
196 Example: |
188 Example: |
197 |
189 |
198 <code language="lua"> function onGearDamage(gear, damage) |
190 <code language="lua"> function onGearDamage(gear, damage) |
199 if (GetGearType(gear) == gtHedgehog) then |
191 if (GetGearType(gear) == gtHedgehog) then |
200 -- adds a message saying, e.g. "Hoggy H took 25 points of damage" |
192 -- adds a message saying, e.g. "Hoggy H took 25 points of damage" |
201 AddCaption(GetHogName(gear) .. ' took ' .. damage .. ' points of damage') |
193 AddCaption(GetHogName(gear) .. ' took ' .. damage .. ' points of damage') |
202 end |
194 end |
203 end</code> |
195 end</code> |
204 === <tt>onGearResurrect(gearUid) </tt> === |
196 === <tt>onGearResurrect(gearUid) </tt> === |
205 |
197 This function is called when a gear is resurrected. CPU Hogs will resurrect if the !GameFlag `gfAISurvival` is enabled. Alternatively, specific gears can have `heResurrectable` set to true via `SetEffect`. |
206 <blockquote>This function is called when a gear is resurrected. CPU Hogs will resurrect if the !GameFlag gfAISurvival is enabled. Alternatively, specific gears can have heResurrectable set to true via !SetEffect. |
198 |
207 </blockquote> |
|
208 === <tt>onAmmoStoreInit()</tt> === |
199 === <tt>onAmmoStoreInit()</tt> === |
209 |
200 This function is called when the game is initialized to request the available ammo and ammo probabilities. Use `SetAmmo` here. |
210 <blockquote>This function is called when the game is initialized to request the available ammo and ammo probabilities. Use !SetAmmo here. |
|
211 </blockquote> |
|
212 |
201 |
213 === <tt>onNewAmmoStore(team/clan index, hog index)</tt> === |
202 === <tt>onNewAmmoStore(team/clan index, hog index)</tt> === |
214 |
203 This function is identical to `onAmmoStoreInit` in function, but is called once per ammo store. This allows different ammo sets for each clan, team or hedgehog depending on the mode. |
215 <blockquote>This function is identical to onAmmoStoreInit in function, but is called once per ammo store. This allows different ammo sets for each clan, team or hedgehog depending on the mode.</blockquote> |
204 If `gfSharedAmmo` is set, the parameters passed are the clan index, and `-1`, and the function will be called once for each clan. |
216 If gfSharedAmmo is set, the parameters passed are the clan index, and -1, and the function will be called once for each clan. |
205 If `gfPerHogAmmo` is set, the parameters passed are the team index and the hog index in that team, and the function will be called once for each hedgehog. |
217 If gfPerHogAmmo is set, the parameters passed are the team index and the hog index in that team, and the function will be called once for each hedgehog. |
206 If neither is set, the parameters passed are the team index and `-1`, and the function will be called once for each team. |
218 If neither is set, the parameters passed are the team index and -1, and the function will be called once for each team. |
207 |
219 |
208 These indexes can be used to look up details of the clan/team/hedgehog prior to gear creation. Routines to do these lookups will be created as needed. |
220 These indexes can be used to look up details of the clan/team/hedgehog prior to gear creation. Routines to do these lookups will be created as needed. |
209 If you add this hook, the expectation is that you will call SetAmmo appropriately. Any values from `onAmmoStoreInit` are ignored. |
221 If you add this hook, the expectation is that you will call SetAmmo appropriately. Any values from onAmmoStoreInit are ignored. |
|
222 |
210 |
223 === <tt>onGearWaterSkip(gear)</tt> (0.9.21) === |
211 === <tt>onGearWaterSkip(gear)</tt> (0.9.21) === |
224 This function is called when the gear `gear` skips over water. |
212 This function is called when the gear `gear` skips over water. |
225 |
213 |
226 === <tt>onScreenResize()</tt> (0.9.16) === |
214 === <tt>onScreenResize()</tt> (0.9.16) === |
227 |
215 This function is called when you resize the screen. Useful place to put a redraw function for any `vgtHealthTags` you're using. |
228 <blockquote>This function is called when you resize the screen. Useful place to put a redraw function for any vgtHealthTags you're using. |
|
229 </blockquote> |
|
230 |
216 |
231 === <tt>onAttack()</tt> === |
217 === <tt>onAttack()</tt> === |
232 |
218 This function is called when your Hedgehog attacks. |
233 <blockquote>This function is called when your Hedgehog attacks. |
|
234 </blockquote> |
|
235 |
219 |
236 === <tt>onHJump()</tt> === |
220 === <tt>onHJump()</tt> === |
237 |
221 This function is called when you press the high jump key. |
238 <blockquote>This function is called when you press the high jump key. |
|
239 </blockquote> |
|
240 |
222 |
241 === <tt>onLJump()</tt> === |
223 === <tt>onLJump()</tt> === |
242 |
224 This function is called when you press the long jump key. |
243 <blockquote>This function is called when you press the long jump key. |
|
244 </blockquote> |
|
245 |
225 |
246 === <tt>onPrecise()</tt> === |
226 === <tt>onPrecise()</tt> === |
247 |
227 This function is called when you press the precise key. |
248 <blockquote>This function is called when you press the precise key. |
|
249 </blockquote> |
|
250 |
228 |
251 === <tt>onLeft()</tt> === |
229 === <tt>onLeft()</tt> === |
252 |
230 This function is called when you press the left key. |
253 <blockquote>This function is called when you press the left key. |
|
254 </blockquote> |
|
255 |
231 |
256 === <tt>onRight()</tt> === |
232 === <tt>onRight()</tt> === |
257 |
233 This function is called when you press the right key. |
258 <blockquote>This function is called when you press the right key. |
|
259 </blockquote> |
|
260 |
234 |
261 === <tt>onUp()</tt> === |
235 === <tt>onUp()</tt> === |
262 |
236 This function is called when you press the up key. |
263 <blockquote>This function is called when you press the up key. |
|
264 </blockquote> |
|
265 |
237 |
266 === <tt>onDown()</tt> === |
238 === <tt>onDown()</tt> === |
267 |
239 This function is called when you press the down key. |
268 <blockquote>This function is called when you press the down key. |
|
269 </blockquote> |
|
270 |
240 |
271 === <tt>onAttackUp()</tt> === |
241 === <tt>onAttackUp()</tt> === |
272 |
242 This function is called when you release the attack key. |
273 <blockquote>This function is called when you release the attack key.</blockquote> |
|
274 |
243 |
275 === <tt>onDownUp()</tt> === |
244 === <tt>onDownUp()</tt> === |
276 |
245 This function is called when you release the down key. |
277 <blockquote>This function is called when you release the down key.</blockquote> |
|
278 |
246 |
279 === <tt>onHogAttack()</tt> === |
247 === <tt>onHogAttack()</tt> === |
280 |
248 This function is called when you press the attack key. |
281 <blockquote>This function is called when you press the attack key.</blockquote> |
|
282 |
249 |
283 === <tt>onLeftUp()</tt> === |
250 === <tt>onLeftUp()</tt> === |
284 |
251 This function is called when you release the left key. |
285 <blockquote>This function is called when you release the left key.</blockquote> |
|
286 |
252 |
287 === <tt>onPreciseUp()</tt> === |
253 === <tt>onPreciseUp()</tt> === |
288 |
254 This function is called when you release the precise key. |
289 <blockquote>This function is called when you release the precise key.</blockquote> |
|
290 |
255 |
291 === <tt>onRightUp()</tt> === |
256 === <tt>onRightUp()</tt> === |
292 |
257 This function is called when you release the right key. |
293 <blockquote>This function is called when you release the right key.</blockquote> |
|
294 |
258 |
295 === <tt>onSetWeapon()</tt> === |
259 === <tt>onSetWeapon()</tt> === |
296 |
260 It is get called when a weapon is selected or switched. |
297 <blockquote>It is get called when a weapon is selected or switched.</blockquote> |
|
298 |
261 |
299 === <tt>onSlot()</tt> === |
262 === <tt>onSlot()</tt> === |
300 |
263 This function is called when a weapon slot (row in the weapon menu) is selected. |
301 <blockquote>This function is called when a weapon slot (row in the weapon menu) is selected.</blockquote> |
|
302 |
264 |
303 === <tt>onSwitch()</tt> === |
265 === <tt>onSwitch()</tt> === |
304 |
266 This function is called when a hog is switched to another. |
305 <blockquote>This function is called when a hog is switched to another.</blockquote> |
|
306 |
267 |
307 === <tt>onTaunt()</tt> === |
268 === <tt>onTaunt()</tt> === |
308 |
269 This function is called when the player uses an animated emote for example by using the chat commands `/wave`, `/juggle`, etc. |
309 <blockquote>This function is called when the player uses an animated emote for example "/wave, /juggle and etc.</blockquote> |
|
310 |
270 |
311 === <tt>onTimer()</tt> === |
271 === <tt>onTimer()</tt> === |
312 |
272 This function is called when one of the timer keys is pressed. |
313 <blockquote>This function is called when one of the timer keys is pressed.</blockquote> |
|
314 |
273 |
315 === <tt>onUpUp()</tt> === |
274 === <tt>onUpUp()</tt> === |
316 |
275 This function is called when you release the up key. |
317 <blockquote>This function is called when you release the up |
|
318 key.</blockquote> |
|
319 |
276 |
320 === <tt>onHogHide()</tt> (0.9.16) === |
277 === <tt>onHogHide()</tt> (0.9.16) === |
321 |
278 This function is called when a hedgehog is hidden (removed from the map). |
322 <blockquote>This function is called when a hedgehog is hidden(removed from the map).</blockquote> |
|
323 |
279 |
324 === <tt>onHogRestore()</tt> (0.9.16) === |
280 === <tt>onHogRestore()</tt> (0.9.16) === |
325 |
281 This function is called when a hedgehog is restored (unhidden). |
326 <blockquote>This function is called when a hedgehog is restored (unhidden).</blockquote> |
|
327 |
282 |
328 === <tt>onSpritePlacement(spriteId, centerX, centerY)</tt> (0.9.21) === |
283 === <tt>onSpritePlacement(spriteId, centerX, centerY)</tt> (0.9.21) === |
329 This function is called when a [Sprites Sprite] has been placed. |
284 This function is called when a [Sprites Sprite] has been placed. |
330 |
285 |
331 `spriteID` is the type of the sprite, you find a list at [Sprites Sprites]. `centerX` and `centerY` are the coordinates of the center of the sprite. |
286 `spriteID` is the type of the sprite, you find a list at [Sprites Sprites]. `centerX` and `centerY` are the coordinates of the center of the sprite. |
332 |
287 |
333 === <tt>onGirderPlacement(frameIdx, centerX, centerY)</tt> (0.9.21) === |
288 === <tt>onGirderPlacement(frameIdx, centerX, centerY)</tt> (0.9.21) === |
334 This function is called when a girder has been placed. |
289 This function is called when a girder has been placed. |
335 |
290 |
336 `frameIdx` is an integer and declares the length and orientation of the girder: |
291 `frameIdx` is an integer and declares the length and orientation of the girder: |
337 || `frameIdx` || length || orientation || |
292 || *`frameIdx`* || *Length* || *Orientation* || |
338 || 0 || short || horizontal || |
293 || 0 || short || horizontal || |
339 || 1 || short || decreasing right || |
294 || 1 || short || decreasing right || |
340 || 2 || short || vertical || |
295 || 2 || short || vertical || |
341 || 3 || short || increasing right || |
296 || 3 || short || increasing right || |
342 || 4 || long || horizontal || |
297 || 4 || long || horizontal || |
349 === <tt>onRubberPlacement(frameIdx, centerX, centerY)</tt> (0.9.21) === |
304 === <tt>onRubberPlacement(frameIdx, centerX, centerY)</tt> (0.9.21) === |
350 This function is called when a rubber has been placed. |
305 This function is called when a rubber has been placed. |
351 |
306 |
352 `frameIdx` is an integer which stands for the orientation of the rubber. |
307 `frameIdx` is an integer which stands for the orientation of the rubber. |
353 |
308 |
354 || `frameIdx` || orientation || |
309 || *`frameIdx`* || *Orientation* || |
355 || 0 || horizontal || |
310 || 0 || horizontal || |
356 || 1 || decreasing right || |
311 || 1 || decreasing right || |
357 || 2 || vertical || |
312 || 2 || vertical || |
358 || 3 || increasing right || |
313 || 3 || increasing right || |
359 |
314 |
360 `centerX` and `centerY` are the coordinates of the rubber’s center. |
315 `centerX` and `centerY` are the coordinates of the rubber’s center. |
361 |
316 |
362 == Functions for creating gears == |
317 == Functions for creating gears == |
363 |
318 |
364 === <tt>!AddGear(x, y, gearType, state, dx, dy, timer)</tt> === |
319 === <tt>!AddGear(x, y, gearType, state, dx, dy, timer)</tt> === |
365 |
320 This creates a new gear at position x,y (measured from top left) of kind `gearType` (see [GearTypes Gear Types]). The initial velocities are `dx` and `dy`. All arguments are numbers. The function returns the `uid` of the gear created. Gears can have multple states at once: `state` is a bitmask, the flag variables can be found in [States]. |
366 <blockquote>This creates a new gear at position x,y (measured from top left) of kind gearType (see [GearTypes Gear Types]). The initial velocities are dx and dy. All arguments are numbers. The function returns the uid of the gear created. Gears can have multple states at once: `state` is a bitmask, the flag variables can be found in [States]. |
321 |
367 </blockquote> |
|
368 Example: |
322 Example: |
369 |
323 |
370 <code language="lua"> local gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0) |
324 <code language="lua"> local gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0) |
371 FindPlace(gear, true, 0, LAND_WIDTH)</code> |
325 FindPlace(gear, true, 0, LAND_WIDTH)</code> |
372 |
326 |
373 === <tt>!AddVisualGear(x, y, visualGearType, state, critical)</tt> === |
327 === <tt>!AddVisualGear(x, y, visualGearType, state, critical)</tt> === |
374 |
328 This creates a new visual gear at position x,y (measured from top left) of kind `visualGearType` (see [VisualGearTypes Visual Gear Types]). The function returns the `uid` of the visual gear created. Set `critical` to `true` if the visual gear is crucial to game play. Use `false` if it is just an effect, and can be skipped when in fast-forward mode (such as when joining a room). A critical visual gear will always be created, a non-critical one may fail. Most visual gears delete themselves. |
375 <blockquote>This creates a new visual gear at position x,y (measured from top left) of kind visualGearType (see [VisualGearTypes Visual Gear Types]). The function returns the uid of the visual gear created. Set critical to true if the visual gear is crucial to game play. False if it is just an effect, and can be skipped when in fastforward (such as when joining a room). A critical visual gear will always be created, a non-critical one may fail. Most visual gears delete themselves. |
329 |
376 </blockquote> |
|
377 Example: |
330 Example: |
378 |
331 |
379 <code language="lua"> -- adds an non-critical explosion at position 1000,1000. Returns 0 if it was not created. |
332 <code language="lua"> -- adds an non-critical explosion at position 1000,1000. Returns 0 if it was not created. |
380 vgear = AddVisualGear(1000, 1000, vgtExplosion, 0, false) |
333 vgear = AddVisualGear(1000, 1000, vgtExplosion, 0, false) |
381 </code> |
334 </code> |
382 |
335 |
383 === <tt>!SpawnHealthCrate(x, y)</tt> === |
336 === <tt>!SpawnHealthCrate(x, y)</tt> === |
384 |
|
385 Spawns a health crate at the specified position. If `x` and `y` are set to 0, the crate will spawn on a random position (but always on land). |
337 Spawns a health crate at the specified position. If `x` and `y` are set to 0, the crate will spawn on a random position (but always on land). |
386 |
338 |
387 === <tt>!SpawnAmmoCrate(x, y, ammoType)</tt> === |
339 === <tt>!SpawnAmmoCrate(x, y, ammoType)</tt> === |
388 |
|
389 Spawns an ammo crate at the specified position with content of ammoType (see [AmmoTypes Ammo Types]). If `x` and `y` are set to 0, the crate will spawn on a random position (but always on land). |
340 Spawns an ammo crate at the specified position with content of ammoType (see [AmmoTypes Ammo Types]). If `x` and `y` are set to 0, the crate will spawn on a random position (but always on land). |
390 Because by default settings the number of ammo in crates is zero it has to be increased to at least one with SetAmmo first, see the example: |
341 Because by default settings the number of ammo in crates is zero it has to be increased to at least one with SetAmmo first, see the example: |
391 |
342 |
392 Example: |
343 Example: |
393 |
344 |
394 <code language="lua"> SetAmmo(amGrenade, 0, 0, 0, 1) -- see below |
345 <code language="lua"> SetAmmo(amGrenade, 0, 0, 0, 1) -- see below |
395 SpawnAmmoCrate(0, 0, amGrenade) -- x=y=0 means random position on map</code> |
346 SpawnAmmoCrate(0, 0, amGrenade) -- x=y=0 means random position on map</code> |
396 |
347 |
397 === <tt>!SpawnUtilityCrate(x, y, ammoType)</tt> === |
348 === <tt>!SpawnUtilityCrate(x, y, ammoType)</tt> === |
398 |
|
399 Spawns an utility crate at specified position with content of ammoType. If `x` and `y` are set to 0, the crate will spawn on a random position (but always on land). |
349 Spawns an utility crate at specified position with content of ammoType. If `x` and `y` are set to 0, the crate will spawn on a random position (but always on land). |
400 |
350 |
401 Example: |
351 Example: |
402 |
352 |
403 <code language="lua"> SetAmmo(amLaserSight, 0, 0, 0, 1) |
353 <code language="lua"> SetAmmo(amLaserSight, 0, 0, 0, 1) |
404 SpawnUtilityCrate(0, 0, amLaserSight)</code> |
354 SpawnUtilityCrate(0, 0, amLaserSight)</code> |
405 |
355 |
406 === <tt>!SpawnFakeAmmoCrate(x, y, explode, poison) </tt> === |
356 === <tt>!SpawnFakeAmmoCrate(x, y, explode, poison) </tt> === |
407 |
|
408 Spawns a crate at the specified coordinates which looks exactly like a real ammo crate but contains not any ammo. It can be use useful for scripted events or to create a trap. If `x` and `y` are set to 0, the crate will spawn on a random position (but always on land). |
357 Spawns a crate at the specified coordinates which looks exactly like a real ammo crate but contains not any ammo. It can be use useful for scripted events or to create a trap. If `x` and `y` are set to 0, the crate will spawn on a random position (but always on land). |
409 `explode` and `poison` are booleans. |
358 `explode` and `poison` are booleans. |
410 If `explode` is `true`, the crate will explode when collected. |
359 If `explode` is `true`, the crate will explode when collected. |
411 If `poison` is `true`, the collector will be poisoned. |
360 If `poison` is `true`, the collector will be poisoned. |
412 |
361 |
414 |
363 |
415 <code language="lua">SpawnFakeAmmoCrate(500, 432, false, false) -- Spawns a fake ammo crate at the coordinates (500, 434) without explosion and poison. |
364 <code language="lua">SpawnFakeAmmoCrate(500, 432, false, false) -- Spawns a fake ammo crate at the coordinates (500, 434) without explosion and poison. |
416 </code> |
365 </code> |
417 |
366 |
418 === <tt>!SpawnFakeHealthCrate(x, y, explode, poison) </tt> === |
367 === <tt>!SpawnFakeHealthCrate(x, y, explode, poison) </tt> === |
419 |
|
420 Spawns a crate at the specified coordinates which looks exactly like a real health crate but it will not heal the player. It can be use useful for scripted events or to create a trap. If `x` and `y` are set to 0, the crate will spawn on a random position (but always on land). |
368 Spawns a crate at the specified coordinates which looks exactly like a real health crate but it will not heal the player. It can be use useful for scripted events or to create a trap. If `x` and `y` are set to 0, the crate will spawn on a random position (but always on land). |
421 `explode` and `poison` are booleans. |
369 `explode` and `poison` are booleans. |
422 If `explode` is `true`, the crate will explode when collected. |
370 If `explode` is `true`, the crate will explode when collected. |
423 If `poison` is `true`, the collector will be poisoned. |
371 If `poison` is `true`, the collector will be poisoned. |
424 |
372 |
425 === <tt>!SpawnFakeUtilityCrate(x, y, explode, poison) </tt> === |
373 === <tt>!SpawnFakeUtilityCrate(x, y, explode, poison) </tt> === |
426 |
|
427 Spawns a crate at the specified coordinates which looks exactly like a real utility crate but contains not any ammo. It can be use useful for scripted events or to create a trap. If `x` and `y` are set to 0, the crate will spawn on a random position (but always on land). |
374 Spawns a crate at the specified coordinates which looks exactly like a real utility crate but contains not any ammo. It can be use useful for scripted events or to create a trap. If `x` and `y` are set to 0, the crate will spawn on a random position (but always on land). |
428 `explode` and `poison` are booleans. |
375 `explode` and `poison` are booleans. |
429 If `explode` is `true`, the crate will explode when collected. |
376 If `explode` is `true`, the crate will explode when collected. |
430 If `poison` is `true`, the collector will be poisoned. |
377 If `poison` is `true`, the collector will be poisoned. |
431 |
378 |
432 === <tt>!AddHog(hogname, botlevel, health, hat)</tt> === |
379 === <tt>!AddHog(hogname, botlevel, health, hat)</tt> === |
433 |
|
434 Adds a new hedgehog for current team (last created one with the `AddTeam` function), with bot level and specified health, also hat. |
380 Adds a new hedgehog for current team (last created one with the `AddTeam` function), with bot level and specified health, also hat. |
435 `botlevel` ranges from `0` to `5`, where `0` denotes a human player and `1` to `5` denote the skill level of a bot. |
381 `botlevel` ranges from `0` to `5`, where `0` denotes a human player and `1` to `5` denote the skill level of a bot. |
436 |
382 |
437 Notice: This works only for singleplayers training missions for now and will desync multiplayer games. |
383 Notice: This works only for singleplayers training missions for now and will desync multiplayer games. |
438 |
384 |
441 <code language="lua"> local player = AddHog("HH 1", 0, 100, "NoHat") -- botlevel 0 means human player |
387 <code language="lua"> local player = AddHog("HH 1", 0, 100, "NoHat") -- botlevel 0 means human player |
442 SetGearPosition(player, 1500, 1000)</code> |
388 SetGearPosition(player, 1500, 1000)</code> |
443 == Functions to get gear properties == |
389 == Functions to get gear properties == |
444 |
390 |
445 === <tt>!GetGearType(gearUid)</tt> === |
391 === <tt>!GetGearType(gearUid)</tt> === |
446 |
392 This function returns one of [GearTypes Gear Types] for the specified gear. |
447 <blockquote>returns one of [GearTypes Gear Types] for the specified gear |
393 |
448 </blockquote> |
|
449 === <tt>!GetGearPosition(gearUid)</tt> === |
394 === <tt>!GetGearPosition(gearUid)</tt> === |
450 |
395 Returns x,y coordinates for the specified gear. |
451 <blockquote>returns x,y coordinates for the specified gear |
396 |
452 </blockquote> |
|
453 === <tt>!GetGearRadius(gearUid)</tt> === |
397 === <tt>!GetGearRadius(gearUid)</tt> === |
454 |
398 Returns radius for the specified gear. |
455 <blockquote>Returns radius for the specified gear |
399 |
456 </blockquote> |
|
457 === <tt>!GetGearVelocity(gearUid)</tt> === |
400 === <tt>!GetGearVelocity(gearUid)</tt> === |
458 |
401 Returns a tuple of dx,dy values for the specified gear |
459 <blockquote>returns tuple of dx,dy values for the specified gear |
402 |
460 </blockquote> |
|
461 === <tt>!GetGearElasticity(gearUid) </tt> === |
403 === <tt>!GetGearElasticity(gearUid) </tt> === |
462 |
404 Returns the elasticity of the specified gear. Useful for determining if a hog is on a rope or not. If a hog is attached to a rope, or is busy firing one, the elasticity of the rope will be non-zero. |
463 <blockquote>Returns the elasticity of the specified gear. Useful for determining if a hog is on a rope or not. If a hog is attached to a rope, or is busy firing one, the elasticity of the rope will be non-zero. |
405 |
464 </blockquote> |
|
465 === <tt>!GetHogClan(gearUid)</tt> === |
406 === <tt>!GetHogClan(gearUid)</tt> === |
466 |
407 Returns the clan ID of the specified hedgehog gear. |
467 <blockquote>returns the clan id of the specified hedgehog gear |
408 |
468 </blockquote> |
|
469 === <tt>!GetHogTeamName(gearUid)</tt> === |
409 === <tt>!GetHogTeamName(gearUid)</tt> === |
470 |
410 Returns the name of the specified hedgehog gear’s team. |
471 <blockquote>returns the name of the specified hedgehog gear's team |
411 |
472 </blockquote> |
|
473 === <tt>!GetHogName(gearUid)</tt> === |
412 === <tt>!GetHogName(gearUid)</tt> === |
474 |
413 Returns the name of the specified hedgehog gear. |
475 <blockquote>returns the name of the specified hedgehog gear |
414 |
476 </blockquote> |
|
477 === <tt>!GetEffect(gearUid, effect)</tt> === |
415 === <tt>!GetEffect(gearUid, effect)</tt> === |
478 |
416 Returns the state of given effect for the given hedgehog gear. |
479 <blockquote>Returns the state of given effect for the given hedgehog gear. |
417 |
480 </blockquote> |
418 See `SetEffect` for further details. |
481 |
419 |
482 see !SetEffect for further details |
|
483 === <tt>!GetHogHat(gearUid)</tt> === |
420 === <tt>!GetHogHat(gearUid)</tt> === |
484 |
421 Returns the hat of the specified hedgehog gear. |
485 <blockquote>Returns the hat of the specified hedgehog gear |
422 |
486 </blockquote> |
|
487 === <tt>!GetAmmoCount(gearUid, ammoType) (0.9.16)</tt> === |
423 === <tt>!GetAmmoCount(gearUid, ammoType) (0.9.16)</tt> === |
488 |
424 Returns the ammo count of the specified ammo type for the specified hedgehog gear. |
489 <blockquote>Returns the ammo count of the specified ammo type for the specified hedgehog gear. |
425 |
490 </blockquote> |
|
491 === <tt>!GetGearTarget(gearUid, x, y) (0.9.16)</tt> === |
426 === <tt>!GetGearTarget(gearUid, x, y) (0.9.16)</tt> === |
492 |
427 Returns the x and y coordinate of target-based weapons/utilities. |
493 <blockquote>Returns the x and y coordinate of target-based weapons/utilities. <b> Note: </b>: This can't be used in onGearAdd() but must be called after gear creation. |
428 <b>Note:</b>: This can’t be used in `onGearAdd()` but must be called after gear creation. |
494 </blockquote> |
429 |
495 === <tt>GetX(gearUid)</tt> === |
430 === <tt>GetX(gearUid)</tt> === |
496 |
431 Returns x coordinate of the gear. |
497 <blockquote>returns x coordinate of the gear |
432 |
498 </blockquote> |
|
499 === <tt>GetY(gearUid)</tt> === |
433 === <tt>GetY(gearUid)</tt> === |
500 |
434 Returns y coordinate of the gear. |
501 <blockquote>returns y coordinate of the gear |
435 |
502 </blockquote> |
|
503 === <tt>!GetState(gearUid)</tt> === |
436 === <tt>!GetState(gearUid)</tt> === |
504 |
|
505 Returns the state of the gear. The gear state is a bitmask which is built out of the variables as shown in [States]. |
437 Returns the state of the gear. The gear state is a bitmask which is built out of the variables as shown in [States]. |
506 |
438 |
507 This function is usually used in combination with `band` to extract the truth value of a single flag. It is also used together with `SetState` and `bor` in order to activate a single flag. |
439 This function is usually used in combination with `band` to extract the truth value of a single flag. It is also used together with `SetState` and `bor` in order to activate a single flag. |
508 |
440 |
509 Examples: |
441 Examples: |
552 </code> |
481 </code> |
553 |
482 |
554 The meaning of tags are described in [GearTypes]. |
483 The meaning of tags are described in [GearTypes]. |
555 |
484 |
556 === <tt>!GetFollowGear()</tt> === |
485 === <tt>!GetFollowGear()</tt> === |
557 |
486 Returns the uid of the gear that is currently being followed. |
558 <blockquote>Returns the uid of the gear that is currently being followed. |
487 |
559 </blockquote> |
|
560 === <tt>!GetTimer(gearUid)</tt> === |
488 === <tt>!GetTimer(gearUid)</tt> === |
561 |
489 Returns the timer of the gear. This is for example the time it takes for watermelon, mine, etc. to explode. This is also the time used to specify the blowtorch or rcplane time. |
562 <blockquote>returns the timer of the gear. This is for example the time it takes for watermelon, mine, etc. to explode. This is also the time used to specify the blowtorch or rcplane time. |
490 |
563 </blockquote> |
|
564 === <tt>!GetHealth(gearUid)</tt> === |
491 === <tt>!GetHealth(gearUid)</tt> === |
565 |
492 Returns the health of the gear. |
566 <blockquote>returns the health of the gear |
493 |
567 </blockquote> |
|
568 === <tt>!GetHogLevel(gearUid)</tt> === |
494 === <tt>!GetHogLevel(gearUid)</tt> === |
569 |
495 Returns the bot level ranging from 0 to 5. `0` means human player. |
570 <blockquote>returns the bot level from 0 to 5. 0 means human player. |
|
571 </blockquote> |
|
572 |
496 |
573 === <tt>!GetGearPos(gearUid)</tt> === |
497 === <tt>!GetGearPos(gearUid)</tt> === |
574 Get pos of specified gear. |
498 Get pos of specified gear. |
575 |
499 |
576 === <tt>!GetVisualGearValues(vgUid)</tt> === |
500 === <tt>!GetVisualGearValues(vgUid)</tt> === |
577 |
501 This returns the typically set visual gear values, useful if manipulating things like smoke or bubbles or circles. It returns the following values: |
578 <blockquote>This returns the typically set visual gear values, useful if manipulating things like smoke or bubbles or circles. It returns the following values: |
|
579 X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint |
502 X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint |
580 X, Y typically position, dX, dY typically speed, Angle is usually the rotation angle, Frame is typically the animation frame, FrameTicks is usually an animation counter. State can have a variety of values, but is typically bit packed, Timer is usually the gear lifetime and Tint is the colour. |
503 X, Y typically position, dX, dY typically speed, Angle is usually the rotation angle, Frame is typically the animation frame, FrameTicks is usually an animation counter. State can have a variety of values, but is typically bit packed, Timer is usually the gear lifetime and Tint is the colour. |
581 Most visual gears require little to no modification of parameters. |
504 Most visual gears require little to no modification of parameters. |
582 </blockquote> |
505 |
583 Example: |
506 Example: |
584 |
507 |
585 <code language="lua"> GetVisualGearValues(vgUid) -- return visual gear values |
508 <code language="lua"> GetVisualGearValues(vgUid) -- return visual gear values |
586 </code> |
509 </code> |
587 |
510 |
588 == Functions to modify gears == |
511 == Functions to modify gears == |
589 |
512 |
590 === <tt>!HideHog(gearUid)</tt> === |
513 === <tt>!HideHog(gearUid)</tt> === |
591 |
514 Removes a hedgehog from the map. The hidden hedgehog can be restored with `RestoreHog(gearUid)`. The current hedgehog cannot be hidden! |
592 <blockquote>Removes a hedgehog from the map. The hidden hedgehog can be restored with !RestoreHog(gearUid). The current hedgehog cannot be hidden!</blockquote> |
515 |
593 Example: |
516 Example: |
594 |
517 |
595 <code language="lua"> gear = AddGear(...) |
518 <code language="lua"> gear = AddGear(...) |
596 HideHog(gear) -- Hide the newly created gear.</code> |
519 HideHog(gear) -- Hide the newly created gear.</code> |
597 |
520 |
598 === <tt>!RestoreHog(gearUid)</tt> === |
521 === <tt>!RestoreHog(gearUid)</tt> === |
599 |
522 Restores a previously hidden hedgehog. |
600 <blockquote>Restores a previously hidden hedgehog.</blockquote> |
523 |
601 Example: |
524 Example: |
602 |
525 |
603 <code language="lua"> gear = AddGear(...) |
526 <code language="lua"> gear = AddGear(...) |
604 HideHog(gear) -- Hide the newly created gear. |
527 HideHog(gear) -- Hide the newly created gear. |
605 RestoreHog(gear) -- Restore the newly hidden gear.</code> |
528 RestoreHog(gear) -- Restore the newly hidden gear.</code> |
606 |
529 |
607 === <tt>!DeleteGear(gearUid)</tt> === |
530 === <tt>!DeleteGear(gearUid)</tt> === |
608 |
531 Deletes a gear. |
609 <blockquote>Deletes a Gear</blockquote> |
532 |
610 Example: |
533 Example: |
611 |
534 |
612 <code language="lua"> gear = AddGear(...) |
535 <code language="lua"> gear = AddGear(...) |
613 DeleteGear(gear) -- Delete the newly created gear.</code> |
536 DeleteGear(gear) -- Delete the newly created gear.</code> |
614 |
537 |
615 === <tt>!DeleteVisualGear(vgUid)</tt> === |
538 === <tt>!DeleteVisualGear(vgUid)</tt> === |
616 |
539 Deletes a visual gear. Note, most visual gears delete themselves. |
617 <blockquote>Deletes a Visual Gear. Note, most visual gears delete themselves.</blockquote> |
540 |
618 Example: |
541 Example: |
619 |
542 |
620 <code language="lua"> vgear = AddVisualGear(...) |
543 <code language="lua"> vgear = AddVisualGear(...) |
621 DeleteVisualGear(vgear) -- Delete the newly created visual gear.</code> |
544 DeleteVisualGear(vgear) -- Delete the newly created visual gear.</code> |
622 |
545 |
623 |
546 |
624 === <tt>!SetVisualGearValues(vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint)</tt> === |
547 === <tt>!SetVisualGearValues(vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint)</tt> === |
625 |
548 This allows manipulation of many of the visual gear values. Calling `GetVisualGearValues` first is recommended on most visual gears unless you are controlling all the key values. In the case of `vgtCircle`, the visual gear values are mapped as follows. X, Y: position. State: radius. Timer: Thickness. FrameTicks: pulsation speed (0 to disable). dX, dY: min/max pulsation opacity (0-255). Tint: colour, RGBA. |
626 <blockquote>This allows manipulation of many of the visual gear values. Calling GetVisualGearValues first is recommended on most visual gears unless you are controlling all the key values. In the case of vgtCircle, the visual gear values are mapped as follows. X, Y: position. State: radius. Timer: Thickness. FrameTicks: pulsation speed (0 to disable). dX, dY: min/max pulsation opacity (0-255). Tint: colour, RGBA. |
|
627 Most visual gears require little to no modification of parameters. |
549 Most visual gears require little to no modification of parameters. |
628 </blockquote> |
550 |
629 Example: |
551 Example: |
630 |
552 |
631 <code language="lua"> -- set a circle to position 1000,1000 pulsing from opacity 20 to 200 (8%-78%), radius of 50, 3px thickness, bright red. |
553 <code language="lua"> -- set a circle to position 1000,1000 pulsing from opacity 20 to 200 (8%-78%), radius of 50, 3px thickness, bright red. |
632 SetVisualGearValues(circleUid, 1000,1000, 20, 200, 0, 0, 100, 50, 3, 0xff0000ff) |
554 SetVisualGearValues(circleUid, 1000,1000, 20, 200, 0, 0, 100, 50, 3, 0xff0000ff) |
633 </code> |
555 </code> |
634 |
556 |
635 === <tt>!FindPlace(gearUid, fall, left, right, tryHarder) (0.9.16)</tt> === |
557 === <tt>!FindPlace(gearUid, fall, left, right, tryHarder) (0.9.16)</tt> === |
636 |
558 Finds a place for the specified gear between x=`left` and x=`right` and places it there. 0.9.16 adds an optional fifth parameter, `tryHarder`. Setting to `true`/`false` will determine whether the engine attempts to make additional passes, even attempting to place gears on top of each other. |
637 <blockquote>Finds a place for the specified gear between x=left and x=right and places it there. 0.9.16 adds an optional fifth parameter, tryHarder. Setting to true/false will determine whether the engine attempts to make additional passes, even attempting to place gears on top of each other. |
559 |
638 </blockquote> |
|
639 Example: |
560 Example: |
640 |
561 |
641 <code language="lua"> gear = AddGear(...) |
562 <code language="lua"> gear = AddGear(...) |
642 FindPlace(gear, true, 0, LAND_WIDTH) -- places the gear randomly between 0 and LAND_WIDTH</code> |
563 FindPlace(gear, true, 0, LAND_WIDTH) -- places the gear randomly between 0 and LAND_WIDTH</code> |
643 === <tt>!HogSay(gearUid, text, manner)</tt> === |
564 === <tt>!HogSay(gearUid, text, manner)</tt> === |
644 |
565 Makes the specified gear say, think, or shout some text in a bubble. |
645 <blockquote>Makes the specified gear say, think, or shout some text in a bubble. |
566 |
646 </blockquote> |
|
647 Example: |
567 Example: |
648 |
568 |
649 <code language="lua"> HogSay(CurrentHedgehog, "I wonder what to do...", SAY_THINK) -- thought bubble with text |
569 <code language="lua"> HogSay(CurrentHedgehog, "I wonder what to do...", SAY_THINK) -- thought bubble with text |
650 HogSay(CurrentHedgehog, "I'm hungry...", SAY_SAY) -- speech bubble with text |
570 HogSay(CurrentHedgehog, "I'm hungry...", SAY_SAY) -- speech bubble with text |
651 HogSay(CurrentHedgehog, "I smell CAKE!", SAY_SHOUT) -- exclamatory bubble with text |
571 HogSay(CurrentHedgehog, "I smell CAKE!", SAY_SHOUT) -- exclamatory bubble with text |
652 </code> |
572 </code> |
653 === <tt>!HogTurnLeft(gearUid, boolean)</tt> === |
573 === <tt>!HogTurnLeft(gearUid, boolean)</tt> === |
654 |
574 Faces the specified hog left or right. |
655 <blockquote>Faces the specified hog left or right. |
575 |
656 </blockquote> |
|
657 Example: |
576 Example: |
658 |
577 |
659 <code language="lua"> HogTurnLeft(CurrentHedgehog, true) -- turns CurrentHedgehog left |
578 <code language="lua"> HogTurnLeft(CurrentHedgehog, true) -- turns CurrentHedgehog left |
660 HogTurnLeft(CurrentHedgehog, false) -- turns CurrentHedgehog right</code> |
579 HogTurnLeft(CurrentHedgehog, false) -- turns CurrentHedgehog right</code> |
661 === <tt>!SetGearPosition(gearUid, x, y)</tt> === |
580 === <tt>!SetGearPosition(gearUid, x, y)</tt> === |
662 |
581 Places the specified gear exactly at the position (`x`,`y`). |
663 <blockquote>Places the specified gear exactly at the position (x,y). |
582 |
664 </blockquote> |
|
665 === <tt>!SetGearVelocity(gearUid, dx, dy)</tt> === |
583 === <tt>!SetGearVelocity(gearUid, dx, dy)</tt> === |
666 |
584 Gives the specified gear the velocity of `dx`, `dy`. |
667 <blockquote>Gives the specified gear the velocity of dx, dy. |
585 |
668 </blockquote> |
|
669 === <tt>!SetAmmo(ammoType, count, probability, delay, numberInCrate)</tt> === |
586 === <tt>!SetAmmo(ammoType, count, probability, delay, numberInCrate)</tt> === |
670 |
587 This updates the settings for a specified [AmmoTypes Ammo Type] as of count available for players, spawn probability, availability delay in turns, and the number available in crates. This is supposed to be used in the `onAmmoStoreInit()` event handler. |
671 <blockquote>This updates the settings for a specified [AmmoTypes Ammo Type] as of count available for players, spawn probability, availability delay in turns, and the number available in crates. This is supposed to be used in the onAmmoStoreInit() event handler. |
588 |
672 </blockquote> |
|
673 Example: |
589 Example: |
674 |
590 |
675 <code language="lua"> SetAmmo(amShotgun, 9, 0, 0, 0) -- unlimited amount of shotgun ammo for players |
591 <code language="lua"> SetAmmo(amShotgun, 9, 0, 0, 0) -- unlimited amount of shotgun ammo for players |
676 SetAmmo(amGrenade, 0, 0, 0, 3) -- crates should contain always three grenade</code> |
592 SetAmmo(amGrenade, 0, 0, 0, 3) -- crates should contain always three grenade</code> |
|
593 |
677 === <tt>!AddAmmo(gearUid, ammoType, ammoCount) (0.9.16) </tt> === |
594 === <tt>!AddAmmo(gearUid, ammoType, ammoCount) (0.9.16) </tt> === |
678 |
595 Adds `ammoType` to the specified gear. The amount added is determined by the arguments passed via `SetAmmo()` in the `onAmmoStoreInit()` event handler. In 0.9.16 ammo can be set directly via the optional third parameter, `ammoCount`. A value of 0 will remove the weapon, a value of 100 will give infinite ammo. |
679 <blockquote>Adds ammoType to the specified gear. The amount added is determined by the arguments passed via !SetAmmo() in the onAmmoStoreInit() event handler. In 0.9.16 ammo can be set directly via the optional third parameter, ammoCount. A value of 0 will remove the weapon, a value of 100 will give infinite ammo. |
596 |
680 |
597 *Note:* The effectiveness of this function may be limited due to problems with `gfPerHogAmmo` in Lua scripting. |
681 *Note:* The effectiveness of this function may be limited due to problems with gfPerHogAmmo in lua scripting. |
598 |
682 |
599 |
683 </blockquote> |
|
684 === <tt>!SetHealth(gearUid, health)</tt> === |
600 === <tt>!SetHealth(gearUid, health)</tt> === |
685 |
601 Sets the health of the specified gear. |
686 <blockquote>Sets the health of the specified gear. |
|
687 This can be used for purposes other than killing hedgehogs. |
602 This can be used for purposes other than killing hedgehogs. |
688 |
603 |
689 For example: |
604 For example: |
690 |
605 |
691 * Starting the RC Plane 10 shots |
606 * Starting the RC Plane 10 shots |
692 * Starting Flying Saucer (gtJetpack) with only 50% fuel. |
607 * Starting Flying Saucer (`gtJetpack`) with only 50% fuel. |
693 * Setting all the mines to duds. |
608 * Setting all the mines to duds. |
694 * (And more!) |
609 * (And more!) |
695 |
610 |
696 <code language="lua"> function onGearAdd(gear) |
611 <code language="lua"> function onGearAdd(gear) |
697 if (GetGearType(gear) == gtRCPlaane) then |
612 if (GetGearType(gear) == gtRCPlaane) then |
705 end |
620 end |
706 end</code> |
621 end</code> |
707 |
622 |
708 |
623 |
709 |
624 |
710 </blockquote> |
|
711 === <tt>!SetEffect(gearUid, effect, effectState)</tt> === |
625 === <tt>!SetEffect(gearUid, effect, effectState)</tt> === |
712 |
626 Sets the state for one of the effects <tt>heInvulnerable, heResurrectable, hePoisoned, heResurrected, heFrozen</tt> for the specified hedgehog gear. |
713 <blockquote>Sets the state for one of the effects <tt>heInvulnerable, heResurrectable, hePoisoned, heResurrected, heFrozen</tt> for the specified hedgehog gear. |
|
714 A value of 0 usually means the effect is disabled, values other than that indicate that it is enabled and in some cases specify e.g. the remaining time of that effect. |
627 A value of 0 usually means the effect is disabled, values other than that indicate that it is enabled and in some cases specify e.g. the remaining time of that effect. |
715 </blockquote> |
628 |
716 Example: (sets all bots poisoned) |
629 Example (sets all bots poisoned): |
717 |
630 |
718 <code language="lua"> function onGearAdd(gear) |
631 <code language="lua"> function onGearAdd(gear) |
719 if (GetGearType(gear) == gtHedgehog) and (GetBotLevel(gear) > 0) then |
632 if (GetGearType(gear) == gtHedgehog) and (GetBotLevel(gear) > 0) then |
720 SetEffect(gear, hePoisoned, 1) |
633 SetEffect(gear, hePoisoned, 1) |
721 end |
634 end |
722 end</code> |
635 end</code> |
723 |
636 |
724 Note: prior to the ice-gun release, 0.9.19 (commit 10a0a31804f3 ) effectState was of boolean type (true = effect enabled, false = effect disabled) |
637 *Note*: prior to the ice-gun release, 0.9.19 (commit r10a0a31804f3) `effectState` was of boolean type (`true` = effect enabled, `false` = effect disabled) |
725 |
638 |
726 === <tt>CopyPV(gearUid, gearUid)</tt> === |
639 === <tt>CopyPV(gearUid, gearUid)</tt> === |
727 |
640 This sets the position and velocity of the second gear to the first one. |
728 <blockquote>This sets the position and velocity of the second gear to the first one. |
641 |
729 </blockquote> |
|
730 === <tt>CopyPV2(gearUid, gearUid)</tt> (deprecated) === |
642 === <tt>CopyPV2(gearUid, gearUid)</tt> (deprecated) === |
731 |
643 This sets the position of the second gear to that of the first one, but makes its velocity twice the one of the first. |
732 <blockquote>This sets the position of the second gear to that of the first one, but makes its velocity twice the one of the first. |
644 |
733 </blockquote> |
645 *Notice*: This function is no longer used, use `GetGearVelocity` and `SetGearVelocity` instead. |
734 Notice: This function is no longer used, use GetGearVelocity and SetGearVelocity instead. |
|
735 === <tt>!FollowGear(gearUid)</tt> === |
646 === <tt>!FollowGear(gearUid)</tt> === |
736 |
647 Makes the game client follow the specifiec gear. |
737 <blockquote>Makes the gameclient follow the specifiec gear. |
648 |
738 </blockquote> |
|
739 === <tt>!SetHogName(gearUid, name)</tt> === |
649 === <tt>!SetHogName(gearUid, name)</tt> === |
740 |
650 Sets the name of the specified hedgehog gear. |
741 <blockquote>Sets the name of the specified hedgehog gear |
651 |
742 </blockquote> |
|
743 === <tt>!SetHogTeamName(gearUid, name)</tt> === |
652 === <tt>!SetHogTeamName(gearUid, name)</tt> === |
744 |
653 Sets the team name of the specified hedgehog gear. |
745 <blockquote>Sets the team name of the specified hedgehog gear |
654 |
746 </blockquote> |
|
747 === <tt>!SetWeapon(ammoType)</tt> === |
655 === <tt>!SetWeapon(ammoType)</tt> === |
748 |
656 Sets the selected weapon of `CurrentHedgehog` to one of the [AmmoTypes Ammo Type]. |
749 <blockquote>Sets the selected weapon of CurrentHedgehog to one of the [AmmoTypes Ammo Type]. |
657 |
750 |
658 Example: |
751 <b>Example:</b> |
|
752 |
659 |
753 <code language="lua"> |
660 <code language="lua"> |
754 AddAmmo(CurrentHedgehog, amBazooka, 1) -- give the CurrentHedgehog a bazooka |
661 AddAmmo(CurrentHedgehog, amBazooka, 1) -- give the CurrentHedgehog a bazooka |
755 SetWeapon(amBazooka) -- select the Bazooka.</code> |
662 SetWeapon(amBazooka) -- select the Bazooka.</code> |
756 </blockquote> |
663 |
757 |
664 |
758 === <tt>!SetNextWeapon()</tt> (0.9.21) === |
665 === <tt>!SetNextWeapon()</tt> (0.9.21) === |
759 This function makes the current hedgehog switch to the next weapon in list of available weapons. It can be used for example in trainings to pre-select a weapon. |
666 This function makes the current hedgehog switch to the next weapon in list of available weapons. It can be used for example in trainings to pre-select a weapon. |
760 |
667 |
761 |
668 |
762 === <tt>!SetHogHat(gearUid, hat)</tt> === |
669 === <tt>!SetHogHat(gearUid, hat)</tt> === |
763 |
670 Sets the hat of the specified hedgehog gear. |
764 <blockquote>Sets the hat of the specified hedgehog gear |
671 |
765 </blockquote> |
|
766 === <tt>!SetGearTarget(gearUid, x, y) (0.9.16)</tt> === |
672 === <tt>!SetGearTarget(gearUid, x, y) (0.9.16)</tt> === |
767 |
673 Sets the x and y coordinate of target-based weapons/utilities. |
768 <blockquote>Sets the x and y coordinate of target-based weapons/utilities. <b> Note: </b>: This can't be used in onGearAdd() but must be called after gear creation. |
674 *Note*: This can’t be used in onGearAdd() but must be called after gear creation. |
769 </blockquote> |
675 |
770 === <tt>!SetState(gearUid, state)</tt> === |
676 === <tt>!SetState(gearUid, state)</tt> === |
771 |
|
772 Sets the state of the specified gear to the specified `state`. This is a bitmask made out of the variables as seen in [States]. |
677 Sets the state of the specified gear to the specified `state`. This is a bitmask made out of the variables as seen in [States]. |
773 |
678 |
774 This function is often used together with `GetState` and the bitmask utility functions `band` and `bnot` in order to manipulate a single flag. |
679 This function is often used together with `GetState` and the bitmask utility functions `band` and `bnot` in order to manipulate a single flag. |
775 |
680 |
776 Examples: |
681 Examples: |
807 </code> |
709 </code> |
808 |
710 |
809 The meaning of tags are described in [GearTypes]. |
711 The meaning of tags are described in [GearTypes]. |
810 |
712 |
811 === <tt>!SetTimer(gearUid, timer)</tt> === |
713 === <tt>!SetTimer(gearUid, timer)</tt> === |
812 |
714 Sets the timer of the specified gear. Also see `GetTimer` |
813 <blockquote>Sets the timer of the specified gear. Also see !GetTimer. |
|
814 </blockquote> |
|
815 |
715 |
816 === <tt>!SetHogLevel(gearUid, level)</tt> === |
716 === <tt>!SetHogLevel(gearUid, level)</tt> === |
817 |
717 Sets the bot level from 0 to 5. `0` means human player. |
818 <blockquote>Sets the bot level from 0 to 5. 0 means human player. |
|
819 </blockquote> |
|
820 |
718 |
821 === <tt>!SetGearPos(gearUid, value) (0.9.18-dev)</tt> === |
719 === <tt>!SetGearPos(gearUid, value) (0.9.18-dev)</tt> === |
822 |
720 Set pos of specified gear to specified value. |
823 <blockquote>Set pos of specified gear to specified value.</blockquote> |
|
824 |
721 |
825 |
722 |
826 == Gameplay functions == |
723 == Gameplay functions == |
827 |
724 |
828 === `GameFlags` === |
725 === `GameFlags` === |
829 |
726 |
830 ==== <tt>!ClearGameFlags()</tt> ==== |
727 ==== <tt>!ClearGameFlags()</tt> ==== |
831 |
728 Disables *all* !GameFlags. |
832 <blockquote>Disables *all* !GameFlags |
|
833 </blockquote> |
|
834 |
729 |
835 ==== <tt>!DisableGameFlags(gameflag, ...)</tt> ==== |
730 ==== <tt>!DisableGameFlags(gameflag, ...)</tt> ==== |
836 |
731 Disables the listed !GameFlags, without changing the status of other !GameFlags. |
837 <blockquote>Disables the listed !GameFlags, without changing the status of other !GameFlags |
|
838 </blockquote> |
|
839 |
732 |
840 ==== <tt>!EnableGameFlags(gameflag, ...)</tt> ==== |
733 ==== <tt>!EnableGameFlags(gameflag, ...)</tt> ==== |
841 |
734 Enables the listed !GameFlags, without changing the status of other !GameFlags. |
842 <blockquote>Enables the listed !GameFlags, without changing the status of other !GameFlags |
|
843 </blockquote> |
|
844 |
735 |
845 ==== <tt>!GetGameFlag(gameflag)</tt> ==== |
736 ==== <tt>!GetGameFlag(gameflag)</tt> ==== |
846 |
737 Returns `true` if the specified gameflag is enabled, otherwise `false`. |
847 <blockquote>Returns true if the specified gameflag is enabled, otherwise false |
|
848 </blockquote> |
|
849 |
738 |
850 === Environment === |
739 === Environment === |
851 |
740 |
852 ==== <tt>!SetGravity(percent)</tt> ==== |
741 ==== <tt>!SetGravity(percent)</tt> ==== |
853 |
742 Changes the current gravity of the game in percent (relative to default, integer value). |
854 <blockquote>Changes the current gravity of the game in percent (relative to default, integer value). |
|
855 Setting it to 100 will set gravity to default gravity of hedgewars, 200 will double it, etc. |
743 Setting it to 100 will set gravity to default gravity of hedgewars, 200 will double it, etc. |
856 </blockquote> |
|
857 |
744 |
858 ==== <tt>!GetGravity()</tt> ==== |
745 ==== <tt>!GetGravity()</tt> ==== |
859 |
746 Returns the current gravity in percent. |
860 <blockquote>Returns the current gravity in percent |
|
861 </blockquote> |
|
862 |
747 |
863 ==== <tt>!SetWaterLine(waterline)</tt> ==== |
748 ==== <tt>!SetWaterLine(waterline)</tt> ==== |
864 |
749 Sets the water level (`WaterLine`) to the specified y-coordinate. |
865 <blockquote>Sets the water level to the specified y-coordinate |
|
866 </blockquote> |
|
867 |
750 |
868 ==== <tt>!SetWind(windSpeed)</tt> ==== |
751 ==== <tt>!SetWind(windSpeed)</tt> ==== |
869 |
752 Sets the current wind in the range of -100 to 100. Use together with `gfDisableWind` for full control. |
870 <blockquote>Sets the current wind in the range of -100 to 100. Use together with gfDisableWind for full control. |
|
871 </blockquote> |
|
872 |
753 |
873 ==== <tt>!EndGame()</tt> ==== |
754 ==== <tt>!EndGame()</tt> ==== |
874 |
755 Makes the game end. |
875 <blockquote>Makes the game end. |
|
876 </blockquote> |
|
877 |
756 |
878 === Map === |
757 === Map === |
879 ==== <tt>!MapHasBorder()</tt> ==== |
758 ==== <tt>!MapHasBorder()</tt> ==== |
880 |
759 Returns `true`/`false` if the map has a border or not. |
881 <blockquote>Returns true/false if the map has a border or not. |
|
882 </blockquote> |
|
883 |
760 |
884 ==== <tt>!TestRectForObstacle(x1, y1, x2, y2, landOnly) (0.9.16) </tt> ==== |
761 ==== <tt>!TestRectForObstacle(x1, y1, x2, y2, landOnly) (0.9.16) </tt> ==== |
885 <blockquote>Checks the rectangle between the given coordinates for possible collisions. set landOnly to true if you don't want to check for collisions with gears (hedgehogs, etc.) |
762 Checks the rectangle between the given coordinates for possible collisions. Set `landOnly` to `true` if you don’t want to check for collisions with gears (hedgehogs, etc.). |
886 </blockquote> |
|
887 |
763 |
888 ==== <tt>!PlaceGirder(x, y, state)</tt> (0.9.16) ==== |
764 ==== <tt>!PlaceGirder(x, y, state)</tt> (0.9.16) ==== |
889 |
765 Places a girder with centre points `x`, `y` and a certain length and orientation, specified by `state`. |
890 <blockquote>Places a girder with centre points x, y and the chosen state. |
766 |
891 These are the accepted states: |
767 These are the accepted states: |
892 * 0: short, horizontal |
768 |
893 * 1: short, decreasing right |
769 || *`state`* || *Length* || *Orientation* || |
894 * 2: short, vertical |
770 || 0 || short || horizontal || |
895 * 3: short, increasing right |
771 || 1 || short || decreasing right || |
896 * 4: long, horizontal |
772 || 2 || short || vertical || |
897 * 5: long, decreasing right |
773 || 3 || short || increasing right || |
898 * 6: long, vertical |
774 || 4 || long || horizontal || |
899 * 7: long, increasing right |
775 || 5 || long || decreasing right || |
900 </blockquote> |
776 || 6 || long || vertical || |
901 |
777 || 7 || long || increasing right || |
902 |
778 |
903 ==== <tt>!AddPoint(x, y [, width [, erase] ])</tt> (0.9.21) ==== |
779 ==== <tt>!AddPoint(x, y [, width [, erase] ])</tt> (0.9.21) ==== |
904 This function is used to draw your own maps using Lua. The maps drawn with this are of type “hand-drawn”. |
780 This function is used to draw your own maps using Lua. The maps drawn with this are of type “hand-drawn”. |
905 |
781 |
906 The function takes a `x`,`y` location, a `width` (means start of a new line) and `erase` (if `false`, this function will draw normally, if `true`, this function will erase drawn stuff). |
782 The function takes a `x`,`y` location, a `width` (means start of a new line) and `erase` (if `false`, this function will draw normally, if `true`, this function will erase drawn stuff). |
911 Makes sure that all the points/lines specified using `AddPoint` are actually applied to the map. This function must be called within `onGameInit`. |
787 Makes sure that all the points/lines specified using `AddPoint` are actually applied to the map. This function must be called within `onGameInit`. |
912 |
788 |
913 === Current hedgehog === |
789 === Current hedgehog === |
914 |
790 |
915 ==== <tt>!GetCurAmmoType()</tt> (0.9.16) ==== |
791 ==== <tt>!GetCurAmmoType()</tt> (0.9.16) ==== |
916 |
792 Returns the currently selected [AmmoTypes Ammo Type]. |
917 <blockquote>Returns the currently selected [AmmoTypes Ammo Type]. |
|
918 </blockquote> |
|
919 |
793 |
920 ==== <tt>!SwitchHog(gearUid)</tt> (0.9.16) ==== |
794 ==== <tt>!SwitchHog(gearUid)</tt> (0.9.16) ==== |
921 |
795 This function will switch to the hedgehog with the specifiedd `gearUid`. |
922 <blockquote>This function will switch to the hedgehog with the specified Uid.</blockquote> |
|
923 |
796 |
924 ==== <tt>!SetInputMask(mask)</tt> ==== |
797 ==== <tt>!SetInputMask(mask)</tt> ==== |
925 |
798 Masks specified player input. This means that Hedgewars ignores certain player inputs, such as walking or jumping. |
926 <blockquote>Masks specified player input. |
799 |
927 </blockquote> |
|
928 Example: |
800 Example: |
929 <code language="lua"> -- masks the long and high jump commands |
801 <code language="lua"> -- masks the long and high jump commands |
930 SetInputMask(band(0xFFFFFFFF, bnot(gmLJump + gmHJump))) |
802 SetInputMask(band(0xFFFFFFFF, bnot(gmLJump + gmHJump))) |
931 -- clears input mask, allowing player to take actions |
803 -- clears input mask, allowing player to take actions |
932 SetInputMask(0xFFFFFFFF) |
804 SetInputMask(0xFFFFFFFF) |
933 </code> |
805 </code> |
934 Note: Using the input mask is an effective way to script uninterrupted cinematics, or create modes such as No Jumping. |
806 *Note*: Using the input mask is an effective way to script uninterrupted cinematics, or create modes such as No Jumping. |
|
807 |
|
808 See also [GearMessages]. |
935 |
809 |
936 ==== <tt>!GetInputMask()</tt> ==== |
810 ==== <tt>!GetInputMask()</tt> ==== |
937 |
|
938 Returns the current input mask of the player. |
811 Returns the current input mask of the player. |
939 |
812 |
940 === Randomness === |
813 === Randomness === |
941 ==== <tt>!GetRandom(number)</tt> ==== |
814 ==== <tt>!GetRandom(number)</tt> ==== |
942 |
815 Returns a randomly generated number in the range of 0 to number - 1. This random number uses the game seed, so is synchronised, and thus safe for multiplayer and saved games. Use `GetRandom` for anything that could impact the engine state. For example, a visual gear could simply use Lua’s `math.random`, but adding a regular gear should use `GetRandom`. |
943 <blockquote>Returns a randomly generated number in the range of 0 to number - 1. This random number uses the game seed, so is synchronised, and thus safe for multiplayer and saved games. Use GetRandom for anything that could impact the engine state. For example, a visual gear can use the Lua random, but adding a regular gear should use GetRandom. |
|
944 </blockquote> |
|
945 |
816 |
946 === Clans and teams === |
817 === Clans and teams === |
947 ==== <tt>!AddTeam(teamname, color, grave, fort, voicepack, flag)</tt> ==== |
818 ==== <tt>!AddTeam(teamname, color, grave, fort, voicepack, flag)</tt> ==== |
948 |
819 |
949 Adds a new team. Note that this can only be done in `onGameInit`, not at a later time. |
820 Adds a new team. Note that this can only be done in `onGameInit`, not at a later time. |
968 |
839 |
969 ==== <tt>!DismissTeam(teamname)</tt> ==== |
840 ==== <tt>!DismissTeam(teamname)</tt> ==== |
970 Removes the team with the given team name from the game. |
841 Removes the team with the given team name from the game. |
971 |
842 |
972 ==== <tt>!GetClanColor(clan)</tt> ==== |
843 ==== <tt>!GetClanColor(clan)</tt> ==== |
973 Returns the color of the chosen clan by its number. The color data type is described in [LuaAPI#Color] |
844 Returns the color of the chosen clan by its number. The color data type is described in [LuaAPI#Color]. |
974 |
845 |
975 ==== <tt>!SetClanColor(clan, color)</tt> ==== |
846 ==== <tt>!SetClanColor(clan, color)</tt> ==== |
976 Sets the color of the chosen clan by its number. The color data type is described in [LuaAPI#Color] |
847 Sets the color of the chosen clan by its number. The color data type is described in [LuaAPI#Color]. |
977 |
848 |
978 |
849 |
979 |
850 |
980 |
851 |
981 |
852 |
982 == Functions affecting the GUI == |
853 == Functions affecting the GUI == |
983 |
854 |
984 === <tt>!AddCaption(text)</tt> === |
855 === <tt>!AddCaption(text)</tt> === |
985 |
856 Display event text in the upper part of the screen. |
986 <blockquote>Display event text in the upper part of the screen. |
|
987 </blockquote> |
|
988 |
857 |
989 === <tt>!ShowMission(caption, subcaption, text, icon, time)</tt> === |
858 === <tt>!ShowMission(caption, subcaption, text, icon, time)</tt> === |
990 |
859 Use to tell the player what he is supposed to do. |
991 <blockquote>Use to tell the player what he is supposed to do. |
860 |
992 |
861 As of version 0.9.15, `icon` currently accepts the following values: |
993 As of (0.9.15), icon currently accepts: |
862 |
994 * -amBazooka, -amShotgun etc. (and other ammo types) |
863 || *`icon`* || *What is shown* || |
995 * 0 (Gold Crown icon) |
864 || _negative number_ || Icon of an ammo type. It is specified as the negative of an ammo type constant (see [AmmoTypes]), i.e. `-amBazooka` for the bazooka icon. || |
996 * 1 (Target icon) |
865 || `0` || Golden crown || |
997 * 2 (Exclamation mark) |
866 || `1` || Target || |
998 * 3 (Question mark) |
867 || `2` || Exclamation mark || |
999 * 4 (Gold star) |
868 || `3` || Question mark || |
1000 </blockquote> |
869 || `4` || Golden star || |
1001 |
870 |
1002 === <tt>!HideMission()</tt> === |
871 === <tt>!HideMission()</tt> === |
1003 |
872 Hides the mission. This function is currently bugged somehow and will completely ruin your life, and your script should you happen to use it. |
1004 <blockquote>Hides the mission. This function is currently bugged somehow and will completely ruin your life, and your script should you happen to use it. |
|
1005 </blockquote> |
|
1006 |
873 |
1007 === <tt>!SetZoom(zoomLevel)</tt> === |
874 === <tt>!SetZoom(zoomLevel)</tt> === |
1008 |
875 Sets the zoom level. The value for maximum zoom is currently 1.0 and for minimum 3.0 The default zoom level is 2.0 |
1009 <blockquote>Sets the zoom level. The value for maximum zoom is currently 1.0 and for minimum 3.0 The default zoom level is 2.0 |
|
1010 </blockquote> |
|
1011 |
876 |
1012 === <tt>!GetZoom()</tt> === |
877 === <tt>!GetZoom()</tt> === |
1013 |
878 Returns the current zoom level. |
1014 <blockquote>Returns the current zoom level |
|
1015 </blockquote> |
|
1016 |
879 |
1017 == Sound functions == |
880 == Sound functions == |
1018 === <tt>!PlaySound(soundId)</tt> === |
881 === <tt>!PlaySound(soundId)</tt> === |
1019 |
882 Plays the specified sound. Possible values for `soundId` are listed on the [Sounds] page. |
1020 <blockquote>Plays the specified sound. |
|
1021 </blockquote> |
|
1022 |
883 |
1023 === <tt>!PlaySound(soundId, gearUid)</tt> === |
884 === <tt>!PlaySound(soundId, gearUid)</tt> === |
1024 / |
885 Plays the specified sound for the chosen hedgehog gear. This can be used to play a taunt with the voicepack of the hedgehog’s team. |
1025 <blockquote>Plays the specified sound for the chosen hedgehog's team. |
886 |
1026 </blockquote> |
887 Possible values for `soundId` are listed on the [Sounds] page. See also [Taunts]. |
1027 |
|
1028 |
888 |
1029 == File system functions == |
889 == File system functions == |
1030 === <tt>!HedgewarsScriptLoad(scriptPath)</tt> === |
890 === <tt>!HedgewarsScriptLoad(scriptPath)</tt> === |
1031 Loads a script (i.e. a [LuaLibraries library]) from the specified `scriptPath`. The root directory is here Hedgewars’ data directory. |
891 Loads a script (i.e. a [LuaLibraries library]) from the specified `scriptPath`. The root directory is here Hedgewars’ data directory. |
1032 |
892 |