author | Wuzzy |
Sun, 20 Nov 2016 00:09:55 +0000 | |
changeset 925 | 06e23f367b3b |
parent 920 | 657f3042209d |
child 926 | fcea3f1877b0 |
permissions | -rw-r--r-- |
67
eecbb1c261bb
Edited wiki page LuaAPI through web user interface.
henrik.rostedt
parents:
66
diff
changeset
|
1 |
#summary API for writing Lua scripts in Hedgewars. |
284
365362b51148
This is cool stuff, let's put it on the project frontpage (adding "featured" tag)
sheepyluva@gmail.com
parents:
244
diff
changeset
|
2 |
#labels Featured |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
3 |
|
741 | 4 |
= Core Lua API documentation = |
5 |
||
312
6c0397400a9b
Add Smaxx' nice lua API introduction from the hedgewars.org wiki
sheepyluva@gmail.com
parents:
295
diff
changeset
|
6 |
== Introduction == |
6c0397400a9b
Add Smaxx' nice lua API introduction from the hedgewars.org wiki
sheepyluva@gmail.com
parents:
295
diff
changeset
|
7 |
|
6c0397400a9b
Add Smaxx' nice lua API introduction from the hedgewars.org wiki
sheepyluva@gmail.com
parents:
295
diff
changeset
|
8 |
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. |
6c0397400a9b
Add Smaxx' nice lua API introduction from the hedgewars.org wiki
sheepyluva@gmail.com
parents:
295
diff
changeset
|
9 |
|
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
10 |
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. |
312
6c0397400a9b
Add Smaxx' nice lua API introduction from the hedgewars.org wiki
sheepyluva@gmail.com
parents:
295
diff
changeset
|
11 |
|
519 | 12 |
=== About this wiki page === |
13 |
This page tends to become outdated. For a list of undocumented functions, see [http://hw.ercatec.net/docs/lua_wiki_check.php]. |
|
312
6c0397400a9b
Add Smaxx' nice lua API introduction from the hedgewars.org wiki
sheepyluva@gmail.com
parents:
295
diff
changeset
|
14 |
|
519 | 15 |
<wiki:toc max_depth="4" /> |
16 |
||
859 | 17 |
== Overview == |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
18 |
=== How Hedgewars handles Lua scripts === |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
19 |
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. |
312
6c0397400a9b
Add Smaxx' nice lua API introduction from the hedgewars.org wiki
sheepyluva@gmail.com
parents:
295
diff
changeset
|
20 |
|
6c0397400a9b
Add Smaxx' nice lua API introduction from the hedgewars.org wiki
sheepyluva@gmail.com
parents:
295
diff
changeset
|
21 |
=== Tutorial missions === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
22 |
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. |
312
6c0397400a9b
Add Smaxx' nice lua API introduction from the hedgewars.org wiki
sheepyluva@gmail.com
parents:
295
diff
changeset
|
23 |
|
567 | 24 |
See [Missions] for details. |
25 |
||
312
6c0397400a9b
Add Smaxx' nice lua API introduction from the hedgewars.org wiki
sheepyluva@gmail.com
parents:
295
diff
changeset
|
26 |
=== Special maps === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
27 |
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. |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
28 |
|
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
29 |
See also [PresetMaps] for more information about such maps. |
312
6c0397400a9b
Add Smaxx' nice lua API introduction from the hedgewars.org wiki
sheepyluva@gmail.com
parents:
295
diff
changeset
|
30 |
|
6c0397400a9b
Add Smaxx' nice lua API introduction from the hedgewars.org wiki
sheepyluva@gmail.com
parents:
295
diff
changeset
|
31 |
=== How Lua scripts are used === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
32 |
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”). |
312
6c0397400a9b
Add Smaxx' nice lua API introduction from the hedgewars.org wiki
sheepyluva@gmail.com
parents:
295
diff
changeset
|
33 |
|
6c0397400a9b
Add Smaxx' nice lua API introduction from the hedgewars.org wiki
sheepyluva@gmail.com
parents:
295
diff
changeset
|
34 |
|
6c0397400a9b
Add Smaxx' nice lua API introduction from the hedgewars.org wiki
sheepyluva@gmail.com
parents:
295
diff
changeset
|
35 |
=== Important things to know === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
36 |
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. |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
37 |
|
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
38 |
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. |
312
6c0397400a9b
Add Smaxx' nice lua API introduction from the hedgewars.org wiki
sheepyluva@gmail.com
parents:
295
diff
changeset
|
39 |
|
6c0397400a9b
Add Smaxx' nice lua API introduction from the hedgewars.org wiki
sheepyluva@gmail.com
parents:
295
diff
changeset
|
40 |
=== Global variables/constants === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
41 |
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. |
312
6c0397400a9b
Add Smaxx' nice lua API introduction from the hedgewars.org wiki
sheepyluva@gmail.com
parents:
295
diff
changeset
|
42 |
|
6c0397400a9b
Add Smaxx' nice lua API introduction from the hedgewars.org wiki
sheepyluva@gmail.com
parents:
295
diff
changeset
|
43 |
|
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
44 |
=== Functions called by the game: Event handlers === |
312
6c0397400a9b
Add Smaxx' nice lua API introduction from the hedgewars.org wiki
sheepyluva@gmail.com
parents:
295
diff
changeset
|
45 |
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. |
6c0397400a9b
Add Smaxx' nice lua API introduction from the hedgewars.org wiki
sheepyluva@gmail.com
parents:
295
diff
changeset
|
46 |
|
478 | 47 |
== Data types == |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
48 |
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. |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
49 |
|
478 | 50 |
=== Color === |
477
8c326a00ead3
Add information about the “color” parameter found in some functions.
almikes@aol.com
parents:
476
diff
changeset
|
51 |
Some functions take a `color` parameter. |
8c326a00ead3
Add information about the “color” parameter found in some functions.
almikes@aol.com
parents:
476
diff
changeset
|
52 |
|
583
0818d57c392f
Clarifications on differences of RGB vs RGBA.
almikes@aol.com
parents:
579
diff
changeset
|
53 |
Colors are stored in RGB or RGBA format and are specified as a three- or four-byte number, respecively. |
0818d57c392f
Clarifications on differences of RGB vs RGBA.
almikes@aol.com
parents:
579
diff
changeset
|
54 |
In 3-byte (RGB) colors, each byte represents a color component. The value 0 means no intensity and 255 is largest intensity of the component. |
477
8c326a00ead3
Add information about the “color” parameter found in some functions.
almikes@aol.com
parents:
476
diff
changeset
|
55 |
The first byte is for the red component, the second byte for the green component and the third byte for the blue component. |
583
0818d57c392f
Clarifications on differences of RGB vs RGBA.
almikes@aol.com
parents:
579
diff
changeset
|
56 |
Four-byte (RGBA) colors use the first 3 bytes for the color components (like for the 3-byte colors) and the fourth byte is used for opacity, where 255 means maximum opacity and 0 means fully transparent (also called the “alpha channel”). |
477
8c326a00ead3
Add information about the “color” parameter found in some functions.
almikes@aol.com
parents:
476
diff
changeset
|
57 |
|
8c326a00ead3
Add information about the “color” parameter found in some functions.
almikes@aol.com
parents:
476
diff
changeset
|
58 |
Specifying the color number becomes much easier if you write it in hexadecimal notation. |
8c326a00ead3
Add information about the “color” parameter found in some functions.
almikes@aol.com
parents:
476
diff
changeset
|
59 |
|
583
0818d57c392f
Clarifications on differences of RGB vs RGBA.
almikes@aol.com
parents:
579
diff
changeset
|
60 |
Examples for RGB (3-byte) colors: |
477
8c326a00ead3
Add information about the “color” parameter found in some functions.
almikes@aol.com
parents:
476
diff
changeset
|
61 |
<code language="lua"> |
8c326a00ead3
Add information about the “color” parameter found in some functions.
almikes@aol.com
parents:
476
diff
changeset
|
62 |
c = 0x000000 -- black (R, G, B are all 0) |
8c326a00ead3
Add information about the “color” parameter found in some functions.
almikes@aol.com
parents:
476
diff
changeset
|
63 |
c = 0xFF0000 -- red |
8c326a00ead3
Add information about the “color” parameter found in some functions.
almikes@aol.com
parents:
476
diff
changeset
|
64 |
c = 0x00FF00 -- green |
8c326a00ead3
Add information about the “color” parameter found in some functions.
almikes@aol.com
parents:
476
diff
changeset
|
65 |
c = 0x0000FF -- blue |
8c326a00ead3
Add information about the “color” parameter found in some functions.
almikes@aol.com
parents:
476
diff
changeset
|
66 |
c = 0xFFFFFF -- white |
8c326a00ead3
Add information about the “color” parameter found in some functions.
almikes@aol.com
parents:
476
diff
changeset
|
67 |
c = 0x808080 -- gray (50%)</code> |
8c326a00ead3
Add information about the “color” parameter found in some functions.
almikes@aol.com
parents:
476
diff
changeset
|
68 |
|
885 | 69 |
Hint: On [http://www.colorpicker.com/] you find a color-picking tool for getting RGB colors easily. |
70 |
||
312
6c0397400a9b
Add Smaxx' nice lua API introduction from the hedgewars.org wiki
sheepyluva@gmail.com
parents:
295
diff
changeset
|
71 |
|
491
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
72 |
== Globally available variables and constants == |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
73 |
The following variables are made available by Hedgewars in Lua and can be used to quickly query a value. Lua scripts schould normally *not* write to these variables, only read from them. |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
74 |
|
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
75 |
=== General variables and constants === |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
76 |
Here are some unsorted variables or constants which are available in Lua. You shouldn’t write to most of them. |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
77 |
|
491
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
78 |
|| *Identifier* || *Description* || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
79 |
|| `LAND_WIDTH` || The width of the landscape in pixels || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
80 |
|| `LAND_HEIGHT` || The height of the landscape in pixels || |
818 | 81 |
|| `LeftX` || X coordinate of the leftmost point of the landsacpe || |
82 |
|| `RightX` || X coordinate of the rightmost point of the landsacpe || |
|
83 |
|| `TopY` || Y coordinate of the topmost point of the landsacpe || |
|
819 | 84 |
|| `CursorX` || The X position of the cursor if the player is choosing a target. Otherwise, this is `-2147483648` || |
85 |
|| `CursorY` || The Y position of the cursor if the player is choosing a target. Otherwise, this is `-2147483648` || |
|
491
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
86 |
|| `WaterLine` || The y position of the water, used to determine at which position stuff drowns. Use `SetWaterLine` to change. || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
87 |
|| `ClansCount` || Number of clans in the game (teams with the same color belong to one clan) || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
88 |
|| `TeamsCount` || Number of teams in the game || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
89 |
|| `TurnTimeLeft` || Number of game ticks (milliseconds) left until the current turn ends. You can change this variable directly. || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
90 |
|| `GameTime` || Number of total game ticks || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
91 |
|| `TotalRounds` || Number of rounds that have passed || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
92 |
|| `CurrentHedgehog` || The hedgehog gear that is currently in play || |
125
b0b7654c6de6
Edited wiki page LuaAPI through web user interface.
RedGrinner@gmail.com
parents:
123
diff
changeset
|
93 |
|
491
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
94 |
=== !GameFlags === |
557 | 95 |
The !GameFlags are used to store simple boolean settings of the game. |
96 |
You can read/modify them using the [LuaAPI#GameFlags_functions GameFlags-Functions]. |
|
102
86cf695636c6
Added gfResetHealth to Gameflags section along with a note.
RedGrinner@gmail.com
parents:
101
diff
changeset
|
97 |
|
491
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
98 |
|| *Identifier* || *Description (active state)* || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
99 |
|| `gfOneClanMode` || Used when only one clan is in the game. This game flag is primarily used for training missions. || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
100 |
|| `gfMultiWeapon` || TODO (Used in training missions.) || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
101 |
|| `gfForts` || Fort Mode || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
102 |
|| `gfDivideTeams` || The teams will start at opposite sites of the terrain. Two clans maximum. || |
626 | 103 |
|| `gfBorder` || An indestructible border is active around the map. || |
491
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
104 |
|| `gfBottomBorder` || There is an indestructable border at the bottom of the map. || |
626 | 105 |
|| `gfShoppaBorder` || The terrain edge will be replaced by a decorative black/yellow “danger stripe”. This has no gameplay effect. || |
491
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
106 |
|| `gfSolidLand` || The terrain is indestructible. || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
107 |
|| `gfLowGravity` || The gravity is low. || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
108 |
|| `gfLaserSight` || A laser sight is almost always active. || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
109 |
|| `gfInvulnerable` || All hedgehogs are invulnerable. || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
110 |
|| `gfVampiric` || All hedgehogs become vampires and get 80% of the damage they deal as health. || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
111 |
|| `gfKarma` || Attackers share the damage they deal to enemies. || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
112 |
|| `gfArtillery` || Hedgehogs can’t walk. || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
113 |
|| `gfRandomOrder` || The game is played in random order. || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
114 |
|| `gfPlaceHog` || Placement mode: At the beginning of the round, all hedgehogs are placed manually first. || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
115 |
|| `gfKing` || King Mode: One hedgehog per team becomes their king, if the king dies, the team loses. || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
116 |
|| `gfSharedAmmo` || Teams in the same clan share their ammo. || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
117 |
|| `gfDisableGirders` || No girders will be created in random maps || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
118 |
|| `gfDisableLandObjects` || No land objects will be created in random maps || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
119 |
|| `gfAISurvival` || Computer-controlled hedgehogs will be revived after they die. || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
120 |
|| `gfInfAttack` || Attacks don’t end the turn. || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
121 |
|| `gfResetWeps` || The weapons will be reset to the initial state each turn. || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
122 |
|| `gfPerHogAmmo` || Each hedgehog has its own weapon stash. || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
123 |
|| `gfDisableWind` || There is no wind. || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
124 |
|| `gfMoreWind` || There is always strong wind. || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
125 |
|| `gfTagTeam` || Tag Team: Teams in the same clan share their turn time. || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
126 |
|| `gfResetHealth` || The health of all living hedgehogs is reset at the end of each turn. || |
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
127 |
|
540 | 128 |
=== Land flags === |
129 |
The land flags denote several types of terrain. Like all flags, they can be combined at will. |
|
130 |
||
131 |
|| *Identifier* || *Meaning* || |
|
132 |
|| `lfIce` || Slippery terrain, hogs will slide on it. || |
|
133 |
|| `lfBouncy` || Bouncy terrain, hogs and some other gears will bounce off when they collide with it. || |
|
134 |
|| `lfIndestructible` || Almost indestructible terrain, most weapons will not destroy it. || |
|
135 |
|| `lfNormal` || Normal destroyable terrain. Note that this is only actually the case when no other land flag is set. || |
|
136 |
||
491
9079444264ae
Update section “Global available constants”: Use tables, fix gameflags section (was outdated, some gameflags were missing).
almikes@aol.com
parents:
478
diff
changeset
|
137 |
=== More constants === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
138 |
More constants are at at [GearTypes Gear Types] , [AmmoTypes Ammo Types], [Sounds], [States], [Sprites], [VisualGearTypes Visual Gear Types]. |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
139 |
|
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
140 |
== Event handlers == |
890 | 141 |
Lua scripts are supposed to _define_ these functions to do something. The functions are then _called_ by Hedgewars when a certain event has occoured. |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
142 |
|
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
143 |
=== <tt>onGameInit()</tt> === |
860 | 144 |
This function is called before the game loads its resources. One can read and modify various game variables here. These variables will become globally available after `onGameInit` has been invoked, but changing them has only an effect in `onGameInit`. |
145 |
Most variables are optional, but for missions, `Theme` must be set by the scripter if you want to use a random map, rather than an image map. All other variables do not need to be set by the scripter and have default values. |
|
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
146 |
|
860 | 147 |
List of game variables: |
863 | 148 |
|| *Identifier* || *Default* || *Description* || |
860 | 149 |
|| `Theme` || _depends_ || The theme to be used. When `Map` is set, a default value is used. For missions which don't use an image map, `Theme` *must* be set explicitly || |
150 |
|| `Map` || `""` || The image map being played or `""` if no image map is used || |
|
151 |
|| `Seed` || `0` || Seed of the random number generator || |
|
152 |
|| `MapGen` || `mgRandom` || Type of map generator. One of `mgRandom`, `mgMaze`, `mgPerlin`, `mgDrawn`. || |
|
153 |
|| `TemplateFilter` || `0` || _unknown meaning_ || |
|
154 |
|| `TemplateNumber` || `0` || _unknown meaning_ || |
|
864 | 155 |
|| `MapFeatureSize` || `50` || Used by random maps to determine its “curvyness” or complexity. This value can be set by the user with the slider under the random map preview in the game setup screen. The user-set value ranges from 1 (leftmost position) to 25 (rightmost position). A good starting value is `12`. || |
860 | 156 |
|| `GameFlags` || `0` || All `GameFlags` combined as a bitmask. See [LuaAPI#GameFlags_functions] for easier manipulation of `GameFlags` || |
157 |
|| `Ready` || `5000` || Ready timer at the start of the turn (in milliseconds) || |
|
158 |
|| `Delay` || `100` || Delay between each turn in milliseconds || |
|
159 |
|| `TurnTime` || `45000` || Turn time in milliseconds || |
|
160 |
|| `GetAwayTime` || `100` || Retreat time in percent || |
|
161 |
|| `CaseFreq` || `5` || Probability that a crate drops in a turn. 0: never, >0: probability = `1/CaseFreq` || |
|
162 |
|| `HealthCaseProb` || `35` || Chance that a crate drop is a health crate, in percent (other crates are ammo or utility crates) || |
|
163 |
|| `HealthCaseAmount` || `25` || Amount of health in a health crate || |
|
164 |
|| `DamagePercent` || `100` || Global damage in percent, affects damage and knockback || |
|
165 |
|| `RopePercent` || `100` || Rope length in percent || |
|
166 |
|| `MinesNum` || `4` || Number of mines being placed on a medium-sized map || |
|
167 |
|| `MinesTime` || `3000` || Time for a mine to explode from activated (in milliseconds), `-1000` for random || |
|
168 |
|| `MineDudPercent` || `0` || Chance of mine being a dud, in percent || |
|
169 |
|| `Explosives` || `2` || Number of barrels being placed on a medium-sized map || |
|
170 |
|| `SuddenDeathTurns` || `15` || Turns until Sudden Death begins || |
|
862 | 171 |
|| `WaterRise` || `47` || Height of water rise in pixels for each Sudden Death turn || |
861 | 172 |
|| `HealthDecrease` || `5` || Amount of health decreased on each turn in Sudden Death || |
860 | 173 |
|| `Goals` || `""` || Use this to add additional text to the goal text popup shown at the beginning and when using the quit or pause keys. The text is added to the default text which usually explains the game modifiers and does not replace it. Use `|` for line breaks. Also, all text before and including a `:` in a line will be highlighted. See also `ShowMission`. || |
917 | 174 |
|| `WorldEdge` || `weNone` || Type edges being used at the left and right sides of the terrain (see below). Available since 0.9.23. || |
860 | 175 |
|| `ScreenWidth` || _N/A_ || Width of the Hedgewars window or screen || |
890 | 176 |
|| `ScreenHeight` || _N/A_ || Height of the Hedgewars window or screen || |
860 | 177 |
|
862 | 178 |
The proper way to disable Sudden Death is by setting both `WaterRise` and `HealthDecrease` to `0`. |
179 |
||
860 | 180 |
If you want to add teams or hogs manually, you have to do it here. If you want to draw your own map using `AddPoint` and `FlushPoints`, you have to do this within this function as well. |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
181 |
|
917 | 182 |
==== `WorldEdge` ==== |
183 |
The value of `WorldEdge` can have the following values: |
|
184 |
||
185 |
|| *Identifier* || *Meaning* || |
|
186 |
|| `weNone` || No world edges || |
|
187 |
|| `weBounce` || Bouncy world edges || |
|
188 |
|| `weWrap` || World wraps around at the edges || |
|
189 |
|| `weSea` || Ocean world edges || |
|
190 |
||
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
191 |
=== <tt>onGameStart()</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
192 |
This function is called when the first round starts. |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
193 |
|
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
194 |
Can be used to show the mission and for more setup, for example initial target spawning. |
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
195 |
|
505 | 196 |
=== <tt>onPreviewInit()</tt> (0.9.21) === |
461 | 197 |
This function is called when the map preview in the frontend is initialized. This happens when the script is selected or you change a map generator parameter. |
198 |
||
199 |
It is useful for scripts which create their own maps (see `AddPoint` and `FlushPoints`). If you create a map in this function, a preview will be generated from this map and is exposed to the frontend. |
|
200 |
||
505 | 201 |
=== <tt>onParameters()</tt> (0.9.21) === |
202 |
This function is called when the script parameters (as specified in the game scheme) become available. The script parameter string is stored in the global variable `ScriptParam`. |
|
203 |
||
204 |
Please note that it is normally not safe to call many of the other functions inside this function, this function is called very early in the game, only use this to initialize variables and other internal stuff like that. |
|
205 |
||
206 |
*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). |
|
207 |
||
208 |
*Tip*: If you use this callback, make sure to document the interpretation of the parameters so others know how to set the parameters properly. |
|
209 |
||
64
a651a8ab85d5
Edited wiki page LuaAPI through web user interface.
RedGrinner
parents:
63
diff
changeset
|
210 |
=== <tt>onGameTick()</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
211 |
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`. |
346
5f322c85c0e0
toss in onGameTick20 - this page needs more updating tho
kyberneticist@gmail.com
parents:
328
diff
changeset
|
212 |
|
5f322c85c0e0
toss in onGameTick20 - this page needs more updating tho
kyberneticist@gmail.com
parents:
328
diff
changeset
|
213 |
=== <tt>onGameTick20()</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
214 |
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. |
64
a651a8ab85d5
Edited wiki page LuaAPI through web user interface.
RedGrinner
parents:
63
diff
changeset
|
215 |
|
181 | 216 |
=== <tt>onNewTurn()</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
217 |
This function calls at the start of every turn. |
63
24004a9003ec
Edited wiki page LuaAPI through web user interface.
RedGrinner
parents:
62
diff
changeset
|
218 |
|
650 | 219 |
=== <tt>onSuddenDeath()</tt> (0.9.22) === |
649 | 220 |
This function is called on the start of Sudden Death. |
221 |
||
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
222 |
=== <tt>onGearAdd(gearUid)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
223 |
This function is called when a new gear is added. Useful in combination with `GetGearType(gearUid)`. |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
224 |
|
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
225 |
=== <tt>onGearDelete(gearUid)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
226 |
This function is called when a new gear is deleted. Useful in combination with `GetGearType(gearUid)`. |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
227 |
|
916
a01743eb08f1
LuaAPI: onVisualGearAdd, onVisualGearDelete, GetVisualGearType
Wuzzy
parents:
913
diff
changeset
|
228 |
=== <tt>onVisualGearAdd(vgUid)</tt> (0.9.23) === |
a01743eb08f1
LuaAPI: onVisualGearAdd, onVisualGearDelete, GetVisualGearType
Wuzzy
parents:
913
diff
changeset
|
229 |
This function is called when a new visual gear is added. Useful in combination with `GetVisualGearType(vgUid)`. |
a01743eb08f1
LuaAPI: onVisualGearAdd, onVisualGearDelete, GetVisualGearType
Wuzzy
parents:
913
diff
changeset
|
230 |
|
a01743eb08f1
LuaAPI: onVisualGearAdd, onVisualGearDelete, GetVisualGearType
Wuzzy
parents:
913
diff
changeset
|
231 |
=== <tt>onVisualGearDelete(vgUid)</tt> (0.9.23) === |
a01743eb08f1
LuaAPI: onVisualGearAdd, onVisualGearDelete, GetVisualGearType
Wuzzy
parents:
913
diff
changeset
|
232 |
This function is called when a new visual gear is deleted. Useful in combination with `GetVisualGearType(vgUid)`. |
a01743eb08f1
LuaAPI: onVisualGearAdd, onVisualGearDelete, GetVisualGearType
Wuzzy
parents:
913
diff
changeset
|
233 |
|
181 | 234 |
=== <tt>onGearDamage(gearUid, damage)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
235 |
This function is called when a gear is damaged. |
55
ef26ff619aea
Edited wiki page LuaAPI through web user interface.
RedGrinner
parents:
54
diff
changeset
|
236 |
|
ef26ff619aea
Edited wiki page LuaAPI through web user interface.
RedGrinner
parents:
54
diff
changeset
|
237 |
Example: |
ef26ff619aea
Edited wiki page LuaAPI through web user interface.
RedGrinner
parents:
54
diff
changeset
|
238 |
|
416
5aa55bbe4b73
Fixed faulty syntax highlighting in code block (was: “<code lang=…” instead of “<code language=…”)
almikes@aol.com
parents:
415
diff
changeset
|
239 |
<code language="lua"> function onGearDamage(gear, damage) |
361
315e9db1f458
no need to prevent linking of names in code blocks
sheepyluva@gmail.com
parents:
360
diff
changeset
|
240 |
if (GetGearType(gear) == gtHedgehog) then |
55
ef26ff619aea
Edited wiki page LuaAPI through web user interface.
RedGrinner
parents:
54
diff
changeset
|
241 |
-- adds a message saying, e.g. "Hoggy H took 25 points of damage" |
361
315e9db1f458
no need to prevent linking of names in code blocks
sheepyluva@gmail.com
parents:
360
diff
changeset
|
242 |
AddCaption(GetHogName(gear) .. ' took ' .. damage .. ' points of damage') |
55
ef26ff619aea
Edited wiki page LuaAPI through web user interface.
RedGrinner
parents:
54
diff
changeset
|
243 |
end |
ef26ff619aea
Edited wiki page LuaAPI through web user interface.
RedGrinner
parents:
54
diff
changeset
|
244 |
end</code> |
181 | 245 |
=== <tt>onGearResurrect(gearUid) </tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
246 |
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`. |
44
bf53e635a2ac
Edited wiki page LuaAPI through web user interface.
RedGrinner
parents:
43
diff
changeset
|
247 |
|
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
248 |
=== <tt>onAmmoStoreInit()</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
249 |
This function is called when the game is initialized to request the available ammo and ammo probabilities. Use `SetAmmo` here. |
98
54e178bb6986
Added basic (not entirely accurate) entries for the event handlers relating to actions taken by Hedgehogs / user input.
RedGrinner@gmail.com
parents:
95
diff
changeset
|
250 |
|
203
08cc35ba4d34
Edited wiki page LuaAPI through web user interface.
kyberneticist@gmail.com
parents:
202
diff
changeset
|
251 |
=== <tt>onNewAmmoStore(team/clan index, hog index)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
252 |
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. |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
253 |
If `gfSharedAmmo` is set, the parameters passed are the clan index, and `-1`, and the function will be called once for each clan. |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
254 |
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. |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
255 |
If neither is set, the parameters passed are the team index and `-1`, and the function will be called once for each team. |
202
47363108b6b6
Edited wiki page LuaAPI through web user interface.
kyberneticist@gmail.com
parents:
184
diff
changeset
|
256 |
|
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
257 |
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. |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
258 |
If you add this hook, the expectation is that you will call SetAmmo appropriately. Any values from `onAmmoStoreInit` are ignored. |
202
47363108b6b6
Edited wiki page LuaAPI through web user interface.
kyberneticist@gmail.com
parents:
184
diff
changeset
|
259 |
|
502 | 260 |
=== <tt>onGearWaterSkip(gear)</tt> (0.9.21) === |
261 |
This function is called when the gear `gear` skips over water. |
|
262 |
||
263 |
=== <tt>onScreenResize()</tt> (0.9.16) === |
|
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
264 |
This function is called when you resize the screen. Useful place to put a redraw function for any `vgtHealthTags` you're using. |
145
547ac6a1d14e
Edited wiki page LuaAPI through web user interface.
RedGrinner@gmail.com
parents:
144
diff
changeset
|
265 |
|
98
54e178bb6986
Added basic (not entirely accurate) entries for the event handlers relating to actions taken by Hedgehogs / user input.
RedGrinner@gmail.com
parents:
95
diff
changeset
|
266 |
=== <tt>onAttack()</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
267 |
This function is called when your Hedgehog attacks. |
98
54e178bb6986
Added basic (not entirely accurate) entries for the event handlers relating to actions taken by Hedgehogs / user input.
RedGrinner@gmail.com
parents:
95
diff
changeset
|
268 |
|
107 | 269 |
=== <tt>onHJump()</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
270 |
This function is called when you press the high jump key. |
98
54e178bb6986
Added basic (not entirely accurate) entries for the event handlers relating to actions taken by Hedgehogs / user input.
RedGrinner@gmail.com
parents:
95
diff
changeset
|
271 |
|
107 | 272 |
=== <tt>onLJump()</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
273 |
This function is called when you press the long jump key. |
98
54e178bb6986
Added basic (not entirely accurate) entries for the event handlers relating to actions taken by Hedgehogs / user input.
RedGrinner@gmail.com
parents:
95
diff
changeset
|
274 |
|
54e178bb6986
Added basic (not entirely accurate) entries for the event handlers relating to actions taken by Hedgehogs / user input.
RedGrinner@gmail.com
parents:
95
diff
changeset
|
275 |
=== <tt>onPrecise()</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
276 |
This function is called when you press the precise key. |
98
54e178bb6986
Added basic (not entirely accurate) entries for the event handlers relating to actions taken by Hedgehogs / user input.
RedGrinner@gmail.com
parents:
95
diff
changeset
|
277 |
|
54e178bb6986
Added basic (not entirely accurate) entries for the event handlers relating to actions taken by Hedgehogs / user input.
RedGrinner@gmail.com
parents:
95
diff
changeset
|
278 |
=== <tt>onLeft()</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
279 |
This function is called when you press the left key. |
98
54e178bb6986
Added basic (not entirely accurate) entries for the event handlers relating to actions taken by Hedgehogs / user input.
RedGrinner@gmail.com
parents:
95
diff
changeset
|
280 |
|
54e178bb6986
Added basic (not entirely accurate) entries for the event handlers relating to actions taken by Hedgehogs / user input.
RedGrinner@gmail.com
parents:
95
diff
changeset
|
281 |
=== <tt>onRight()</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
282 |
This function is called when you press the right key. |
98
54e178bb6986
Added basic (not entirely accurate) entries for the event handlers relating to actions taken by Hedgehogs / user input.
RedGrinner@gmail.com
parents:
95
diff
changeset
|
283 |
|
54e178bb6986
Added basic (not entirely accurate) entries for the event handlers relating to actions taken by Hedgehogs / user input.
RedGrinner@gmail.com
parents:
95
diff
changeset
|
284 |
=== <tt>onUp()</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
285 |
This function is called when you press the up key. |
98
54e178bb6986
Added basic (not entirely accurate) entries for the event handlers relating to actions taken by Hedgehogs / user input.
RedGrinner@gmail.com
parents:
95
diff
changeset
|
286 |
|
54e178bb6986
Added basic (not entirely accurate) entries for the event handlers relating to actions taken by Hedgehogs / user input.
RedGrinner@gmail.com
parents:
95
diff
changeset
|
287 |
=== <tt>onDown()</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
288 |
This function is called when you press the down key. |
98
54e178bb6986
Added basic (not entirely accurate) entries for the event handlers relating to actions taken by Hedgehogs / user input.
RedGrinner@gmail.com
parents:
95
diff
changeset
|
289 |
|
181 | 290 |
=== <tt>onAttackUp()</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
291 |
This function is called when you release the attack key. |
175
2455fbbab5e8
Edited wiki page LuaAPI through web user interface.
azizi.054@gmail.com
parents:
174
diff
changeset
|
292 |
|
181 | 293 |
=== <tt>onDownUp()</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
294 |
This function is called when you release the down key. |
175
2455fbbab5e8
Edited wiki page LuaAPI through web user interface.
azizi.054@gmail.com
parents:
174
diff
changeset
|
295 |
|
535 | 296 |
=== <tt>onHogAttack(ammoType)</tt> === |
297 |
This function is called when you press the attack key. Beginning with 0.9.21, the parameter `ammoType` is provided. It contains the ammo type of the weapon used for the attack. |
|
175
2455fbbab5e8
Edited wiki page LuaAPI through web user interface.
azizi.054@gmail.com
parents:
174
diff
changeset
|
298 |
|
181 | 299 |
=== <tt>onLeftUp()</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
300 |
This function is called when you release the left key. |
175
2455fbbab5e8
Edited wiki page LuaAPI through web user interface.
azizi.054@gmail.com
parents:
174
diff
changeset
|
301 |
|
181 | 302 |
=== <tt>onPreciseUp()</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
303 |
This function is called when you release the precise key. |
175
2455fbbab5e8
Edited wiki page LuaAPI through web user interface.
azizi.054@gmail.com
parents:
174
diff
changeset
|
304 |
|
181 | 305 |
=== <tt>onRightUp()</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
306 |
This function is called when you release the right key. |
175
2455fbbab5e8
Edited wiki page LuaAPI through web user interface.
azizi.054@gmail.com
parents:
174
diff
changeset
|
307 |
|
622
d7c2a5db19a4
Add msgParam for onSlot, onTaunt, onTimer and onSetWeapon
Wuzzy
parents:
616
diff
changeset
|
308 |
=== <tt>onSetWeapon(msgParam)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
309 |
It is get called when a weapon is selected or switched. |
175
2455fbbab5e8
Edited wiki page LuaAPI through web user interface.
azizi.054@gmail.com
parents:
174
diff
changeset
|
310 |
|
622
d7c2a5db19a4
Add msgParam for onSlot, onTaunt, onTimer and onSetWeapon
Wuzzy
parents:
616
diff
changeset
|
311 |
`msgParam` tells you which ammo type was selected. |
d7c2a5db19a4
Add msgParam for onSlot, onTaunt, onTimer and onSetWeapon
Wuzzy
parents:
616
diff
changeset
|
312 |
|
d7c2a5db19a4
Add msgParam for onSlot, onTaunt, onTimer and onSetWeapon
Wuzzy
parents:
616
diff
changeset
|
313 |
=== <tt>onSlot(msgParam)</tt> === |
d7c2a5db19a4
Add msgParam for onSlot, onTaunt, onTimer and onSetWeapon
Wuzzy
parents:
616
diff
changeset
|
314 |
This function is called when one of the weapon slot keys has been pressed. |
d7c2a5db19a4
Add msgParam for onSlot, onTaunt, onTimer and onSetWeapon
Wuzzy
parents:
616
diff
changeset
|
315 |
|
d7c2a5db19a4
Add msgParam for onSlot, onTaunt, onTimer and onSetWeapon
Wuzzy
parents:
616
diff
changeset
|
316 |
`msgParam` tells the slot number minus 1 (i.e. `0` is for slot number 1, `1` is for slot number 2, etc.). |
175
2455fbbab5e8
Edited wiki page LuaAPI through web user interface.
azizi.054@gmail.com
parents:
174
diff
changeset
|
317 |
|
181 | 318 |
=== <tt>onSwitch()</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
319 |
This function is called when a hog is switched to another. |
175
2455fbbab5e8
Edited wiki page LuaAPI through web user interface.
azizi.054@gmail.com
parents:
174
diff
changeset
|
320 |
|
622
d7c2a5db19a4
Add msgParam for onSlot, onTaunt, onTimer and onSetWeapon
Wuzzy
parents:
616
diff
changeset
|
321 |
=== <tt>onTaunt(msgParam)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
322 |
This function is called when the player uses an animated emote for example by using the chat commands `/wave`, `/juggle`, etc. |
175
2455fbbab5e8
Edited wiki page LuaAPI through web user interface.
azizi.054@gmail.com
parents:
174
diff
changeset
|
323 |
|
622
d7c2a5db19a4
Add msgParam for onSlot, onTaunt, onTimer and onSetWeapon
Wuzzy
parents:
616
diff
changeset
|
324 |
`msgParam` tells you which animation was played: |
d7c2a5db19a4
Add msgParam for onSlot, onTaunt, onTimer and onSetWeapon
Wuzzy
parents:
616
diff
changeset
|
325 |
|
623 | 326 |
|| *`msgParam`* || *Animation* || *Associated chat command* || |
327 |
|| 0 || Rolling up || `/rollup` || |
|
328 |
|| 1 || Sad face || `/sad` || |
|
329 |
|| 2 || Waving hand || `/wave` || |
|
330 |
|| 3 || Stupid winner's grin / “Awesome” face || `/hurrah` || |
|
331 |
|| 4 || Peeing || `/ilovelotsoflemonade` || |
|
332 |
|| 5 || Shrug || `/shrug` || |
|
333 |
|| 6 || Juggling || `/juggle` || |
|
622
d7c2a5db19a4
Add msgParam for onSlot, onTaunt, onTimer and onSetWeapon
Wuzzy
parents:
616
diff
changeset
|
334 |
|
d7c2a5db19a4
Add msgParam for onSlot, onTaunt, onTimer and onSetWeapon
Wuzzy
parents:
616
diff
changeset
|
335 |
=== <tt>onTimer(msgParam)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
336 |
This function is called when one of the timer keys is pressed. |
175
2455fbbab5e8
Edited wiki page LuaAPI through web user interface.
azizi.054@gmail.com
parents:
174
diff
changeset
|
337 |
|
622
d7c2a5db19a4
Add msgParam for onSlot, onTaunt, onTimer and onSetWeapon
Wuzzy
parents:
616
diff
changeset
|
338 |
`msgParams` tells the set timer in seconds (i.e. `3` for the 3 seconds timer key). |
d7c2a5db19a4
Add msgParam for onSlot, onTaunt, onTimer and onSetWeapon
Wuzzy
parents:
616
diff
changeset
|
339 |
|
181 | 340 |
=== <tt>onUpUp()</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
341 |
This function is called when you release the up key. |
178
dde460404412
Edited wiki page LuaAPI through web user interface.
azizi.054@gmail.com
parents:
177
diff
changeset
|
342 |
|
689 | 343 |
=== <tt>onHogHide(gearUid)</tt> (0.9.16) === |
344 |
This function is called when a hedgehog with the gear ID `gearUid` is hidden (removed from the map). |
|
179
156e5fba2e2c
Edited wiki page LuaAPI through web user interface.
azizi.054@gmail.com
parents:
178
diff
changeset
|
345 |
|
689 | 346 |
=== <tt>onHogRestore(gearUid)</tt> (0.9.16) === |
347 |
This function is called when a hedgehog with the specified gear ID `gearUid` is restored (unhidden). |
|
173
ef246592a16e
Edited wiki page LuaAPI through web user interface.
azizi.054@gmail.com
parents:
172
diff
changeset
|
348 |
|
411 | 349 |
=== <tt>onSpritePlacement(spriteId, centerX, centerY)</tt> (0.9.21) === |
350 |
This function is called when a [Sprites Sprite] has been placed. |
|
351 |
||
352 |
`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. |
|
353 |
||
402
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
354 |
=== <tt>onGirderPlacement(frameIdx, centerX, centerY)</tt> (0.9.21) === |
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
355 |
This function is called when a girder has been placed. |
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
356 |
|
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
357 |
`frameIdx` is an integer and declares the length and orientation of the girder: |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
358 |
|| *`frameIdx`* || *Length* || *Orientation* || |
402
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
359 |
|| 0 || short || horizontal || |
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
360 |
|| 1 || short || decreasing right || |
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
361 |
|| 2 || short || vertical || |
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
362 |
|| 3 || short || increasing right || |
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
363 |
|| 4 || long || horizontal || |
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
364 |
|| 5 || long || decreasing right || |
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
365 |
|| 6 || long || vertical || |
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
366 |
|| 7 || long || increasing right || |
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
367 |
|
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
368 |
`centerX` and `centerY` are the coordinates of the girder’s center. |
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
369 |
|
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
370 |
=== <tt>onRubberPlacement(frameIdx, centerX, centerY)</tt> (0.9.21) === |
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
371 |
This function is called when a rubber has been placed. |
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
372 |
|
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
373 |
`frameIdx` is an integer which stands for the orientation of the rubber. |
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
374 |
|
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
375 |
|| *`frameIdx`* || *Orientation* || |
402
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
376 |
|| 0 || horizontal || |
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
377 |
|| 1 || decreasing right || |
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
378 |
|| 2 || vertical || |
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
379 |
|| 3 || increasing right || |
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
380 |
|
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
381 |
`centerX` and `centerY` are the coordinates of the rubber’s center. |
1e7586c110f6
Documented 0.9.21 functions onGirderPlacement and onRubberPlacement.
almikes@aol.com
parents:
401
diff
changeset
|
382 |
|
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
383 |
== Functions for creating gears == |
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
384 |
|
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
385 |
=== <tt>!AddGear(x, y, gearType, state, dx, dy, timer)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
386 |
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]. |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
387 |
|
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
388 |
Example: |
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
389 |
|
416
5aa55bbe4b73
Fixed faulty syntax highlighting in code block (was: “<code lang=…” instead of “<code language=…”)
almikes@aol.com
parents:
415
diff
changeset
|
390 |
<code language="lua"> local gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0) |
361
315e9db1f458
no need to prevent linking of names in code blocks
sheepyluva@gmail.com
parents:
360
diff
changeset
|
391 |
FindPlace(gear, true, 0, LAND_WIDTH)</code> |
39
45a576e56425
Updating with visual gear functions and delete gear
kyberneticist
parents:
38
diff
changeset
|
392 |
|
359 | 393 |
=== <tt>!AddVisualGear(x, y, visualGearType, state, critical)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
394 |
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. |
39
45a576e56425
Updating with visual gear functions and delete gear
kyberneticist
parents:
38
diff
changeset
|
395 |
|
45a576e56425
Updating with visual gear functions and delete gear
kyberneticist
parents:
38
diff
changeset
|
396 |
Example: |
45a576e56425
Updating with visual gear functions and delete gear
kyberneticist
parents:
38
diff
changeset
|
397 |
|
416
5aa55bbe4b73
Fixed faulty syntax highlighting in code block (was: “<code lang=…” instead of “<code language=…”)
almikes@aol.com
parents:
415
diff
changeset
|
398 |
<code language="lua"> -- adds an non-critical explosion at position 1000,1000. Returns 0 if it was not created. |
361
315e9db1f458
no need to prevent linking of names in code blocks
sheepyluva@gmail.com
parents:
360
diff
changeset
|
399 |
vgear = AddVisualGear(1000, 1000, vgtExplosion, 0, false) |
39
45a576e56425
Updating with visual gear functions and delete gear
kyberneticist
parents:
38
diff
changeset
|
400 |
</code> |
45a576e56425
Updating with visual gear functions and delete gear
kyberneticist
parents:
38
diff
changeset
|
401 |
|
871
3222b4cfef8a
LuaAPI: Additional parameter for SpawnHealthCrate, SpawnAmmoCrate, SpawnUtilityCrate
Wuzzy
parents:
869
diff
changeset
|
402 |
=== <tt>!SpawnHealthCrate(x, y, [, health])</tt> === |
3222b4cfef8a
LuaAPI: Additional parameter for SpawnHealthCrate, SpawnAmmoCrate, SpawnUtilityCrate
Wuzzy
parents:
869
diff
changeset
|
403 |
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). Set `health` for the initial health contained in the health crate. If not set, the default health (`HealthCaseAmount`) is used. |
417
f4b7962d39cd
Better documentation about the special coordinates x=0, y=0 for the crate spawn functions.
almikes@aol.com
parents:
416
diff
changeset
|
404 |
|
871
3222b4cfef8a
LuaAPI: Additional parameter for SpawnHealthCrate, SpawnAmmoCrate, SpawnUtilityCrate
Wuzzy
parents:
869
diff
changeset
|
405 |
=== <tt>!SpawnAmmoCrate(x, y, ammoType [, amount])</tt> === |
881
ab6bd4812ca4
LuaAPI: special amNothing for SpawnAmmoCrate / SpawnUtilityCrate
Wuzzy
parents:
871
diff
changeset
|
406 |
Spawns an ammo crate at the specified position with content of ammoType (see [AmmoTypes Ammo Types]). If `ammoType` is set to `amNothing`, a random weapon (out of the available weapons from the weapon scheme) will be selected. If `x` and `y` are set to 0, the crate will spawn on a random position (but always on land). The `amount` parameter specifies the amount of ammo contained in the crate. By default, the value set by `SetAmmo` is used. If `SetAmmo` has not been used for this ammo type, an ammo-type-dependent default value is used. |
564 | 407 |
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: |
417
f4b7962d39cd
Better documentation about the special coordinates x=0, y=0 for the crate spawn functions.
almikes@aol.com
parents:
416
diff
changeset
|
408 |
|
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
409 |
Example: |
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
410 |
|
416
5aa55bbe4b73
Fixed faulty syntax highlighting in code block (was: “<code lang=…” instead of “<code language=…”)
almikes@aol.com
parents:
415
diff
changeset
|
411 |
<code language="lua"> SetAmmo(amGrenade, 0, 0, 0, 1) -- see below |
361
315e9db1f458
no need to prevent linking of names in code blocks
sheepyluva@gmail.com
parents:
360
diff
changeset
|
412 |
SpawnAmmoCrate(0, 0, amGrenade) -- x=y=0 means random position on map</code> |
417
f4b7962d39cd
Better documentation about the special coordinates x=0, y=0 for the crate spawn functions.
almikes@aol.com
parents:
416
diff
changeset
|
413 |
|
871
3222b4cfef8a
LuaAPI: Additional parameter for SpawnHealthCrate, SpawnAmmoCrate, SpawnUtilityCrate
Wuzzy
parents:
869
diff
changeset
|
414 |
=== <tt>!SpawnUtilityCrate(x, y, ammoType [, amount])</tt> === |
881
ab6bd4812ca4
LuaAPI: special amNothing for SpawnAmmoCrate / SpawnUtilityCrate
Wuzzy
parents:
871
diff
changeset
|
415 |
Spawns an utility crate with some ammo at the specified position. The function behaves almost like `SpawnAmmoCrate`, the differences are 1) the crate looks different and 2) if `ammoType` is set to `amNothing`, a random utility out of the set of available utilities from the weapon scheme is chosen as content. |
417
f4b7962d39cd
Better documentation about the special coordinates x=0, y=0 for the crate spawn functions.
almikes@aol.com
parents:
416
diff
changeset
|
416 |
|
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
417 |
Example: |
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
418 |
|
416
5aa55bbe4b73
Fixed faulty syntax highlighting in code block (was: “<code lang=…” instead of “<code language=…”)
almikes@aol.com
parents:
415
diff
changeset
|
419 |
<code language="lua"> SetAmmo(amLaserSight, 0, 0, 0, 1) |
361
315e9db1f458
no need to prevent linking of names in code blocks
sheepyluva@gmail.com
parents:
360
diff
changeset
|
420 |
SpawnUtilityCrate(0, 0, amLaserSight)</code> |
400 | 421 |
|
422 |
=== <tt>!SpawnFakeAmmoCrate(x, y, explode, poison) </tt> === |
|
417
f4b7962d39cd
Better documentation about the special coordinates x=0, y=0 for the crate spawn functions.
almikes@aol.com
parents:
416
diff
changeset
|
423 |
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). |
400 | 424 |
`explode` and `poison` are booleans. |
425 |
If `explode` is `true`, the crate will explode when collected. |
|
426 |
If `poison` is `true`, the collector will be poisoned. |
|
427 |
||
428 |
Example: |
|
429 |
||
416
5aa55bbe4b73
Fixed faulty syntax highlighting in code block (was: “<code lang=…” instead of “<code language=…”)
almikes@aol.com
parents:
415
diff
changeset
|
430 |
<code language="lua">SpawnFakeAmmoCrate(500, 432, false, false) -- Spawns a fake ammo crate at the coordinates (500, 434) without explosion and poison. |
400 | 431 |
</code> |
432 |
||
433 |
=== <tt>!SpawnFakeHealthCrate(x, y, explode, poison) </tt> === |
|
417
f4b7962d39cd
Better documentation about the special coordinates x=0, y=0 for the crate spawn functions.
almikes@aol.com
parents:
416
diff
changeset
|
434 |
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). |
400 | 435 |
`explode` and `poison` are booleans. |
436 |
If `explode` is `true`, the crate will explode when collected. |
|
437 |
If `poison` is `true`, the collector will be poisoned. |
|
438 |
||
439 |
=== <tt>!SpawnFakeUtilityCrate(x, y, explode, poison) </tt> === |
|
417
f4b7962d39cd
Better documentation about the special coordinates x=0, y=0 for the crate spawn functions.
almikes@aol.com
parents:
416
diff
changeset
|
440 |
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). |
400 | 441 |
`explode` and `poison` are booleans. |
442 |
If `explode` is `true`, the crate will explode when collected. |
|
443 |
If `poison` is `true`, the collector will be poisoned. |
|
444 |
||
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
445 |
=== <tt>!AddHog(hogname, botlevel, health, hat)</tt> === |
413
6d90d6994e95
Add DismissTeam, move AddTeam to new “Clans and teams” section.
almikes@aol.com
parents:
412
diff
changeset
|
446 |
Adds a new hedgehog for current team (last created one with the `AddTeam` function), with bot level and specified health, also hat. |
556
e57188e7bc3b
Better explanation of botlevel (AddHog argument).
almikes@aol.com
parents:
555
diff
changeset
|
447 |
`botlevel` ranges from `0` to `5`, where `0` denotes a human player and `1` to `5` denote the skill level of a bot, where `1` is strongest and `5` is the weakest. Note that this is the reverse order of how the bot level is displayed in the game. |
413
6d90d6994e95
Add DismissTeam, move AddTeam to new “Clans and teams” section.
almikes@aol.com
parents:
412
diff
changeset
|
448 |
|
556
e57188e7bc3b
Better explanation of botlevel (AddHog argument).
almikes@aol.com
parents:
555
diff
changeset
|
449 |
*Warning*: This works only for singleplayers training missions for now and will desync multiplayer games. |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
450 |
|
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
451 |
Example: |
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
452 |
|
416
5aa55bbe4b73
Fixed faulty syntax highlighting in code block (was: “<code lang=…” instead of “<code language=…”)
almikes@aol.com
parents:
415
diff
changeset
|
453 |
<code language="lua"> local player = AddHog("HH 1", 0, 100, "NoHat") -- botlevel 0 means human player |
361
315e9db1f458
no need to prevent linking of names in code blocks
sheepyluva@gmail.com
parents:
360
diff
changeset
|
454 |
SetGearPosition(player, 1500, 1000)</code> |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
455 |
== Functions to get gear properties == |
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
456 |
|
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
457 |
=== <tt>!GetGearType(gearUid)</tt> === |
891 | 458 |
This function returns the [GearTypes gear type] for the specified gear. |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
459 |
|
916
a01743eb08f1
LuaAPI: onVisualGearAdd, onVisualGearDelete, GetVisualGearType
Wuzzy
parents:
913
diff
changeset
|
460 |
=== <tt>!GetVisualGearType(vgUid)</tt> (0.9.23) === |
a01743eb08f1
LuaAPI: onVisualGearAdd, onVisualGearDelete, GetVisualGearType
Wuzzy
parents:
913
diff
changeset
|
461 |
This function returns the [VisualGearTypes visual gear type] for the specified visual gear. |
a01743eb08f1
LuaAPI: onVisualGearAdd, onVisualGearDelete, GetVisualGearType
Wuzzy
parents:
913
diff
changeset
|
462 |
|
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
463 |
=== <tt>!GetGearPosition(gearUid)</tt> === |
891 | 464 |
Returns x,y coordinates for the specified gear. Not to be confused with `GetGearPos`. |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
465 |
|
181 | 466 |
=== <tt>!GetGearRadius(gearUid)</tt> === |
892 | 467 |
Returns the `Radius` value for the specified gear. For most [GearTypes gear types] for “projectile” gears (like `gtShell` or `gtGrenade`), the radius refers to the gear's collision radius. This is an invisible circle around the center of the gear which is used for the collision checks. For a few gear types, its radius means something different, see [Gear Types] for a full list. |
468 |
||
469 |
To set the `Radius` value, use `SetGearValues`. |
|
148
f343b50d5619
Edited wiki page LuaAPI through web user interface.
RedGrinner@gmail.com
parents:
147
diff
changeset
|
470 |
|
181 | 471 |
=== <tt>!GetGearVelocity(gearUid)</tt> === |
555 | 472 |
Returns a tuple of dx,dy values for the specified gear. |
473 |
||
474 |
=== <tt>!GetFlightTime(gearUid)</tt> === |
|
475 |
Returns the `FlightTime` of the specified gear. The `FlightTime` is a gear varialbe used to store a general time interval. The precise meaning of the `FlightTime` depends on the gear type. |
|
476 |
||
477 |
For example: The `FlightTime` of a hedgehog (`gtHedgehog`) is the time since they last have stood on solid ground. For most projectile gear types (i.e. `gtShell`), it stores the time after it has been launched. |
|
71
2dcbebb06088
Edited wiki page LuaAPI through web user interface.
henrik.rostedt
parents:
70
diff
changeset
|
478 |
|
181 | 479 |
=== <tt>!GetGearElasticity(gearUid) </tt> === |
611 | 480 |
Returns the elasticity of the specified gear. The elasticity normally determines how strong the gear will bounce after collisions, where higher elasticity is for stronger bounces. |
481 |
||
482 |
This is also 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. |
|
483 |
||
484 |
=== <tt>!GetGearFriction(gearUid) </tt> === |
|
485 |
Returns the friction of the specified gear. The friction normally determines how well the gear will slide on terrain. Higher values are for increased sliding properties. |
|
74 | 486 |
|
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
487 |
=== <tt>!GetHogClan(gearUid)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
488 |
Returns the clan ID of the specified hedgehog gear. |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
489 |
|
28
026591d95ac6
Edited wiki page LuaAPI through web user interface.
henrik.rostedt
parents:
24
diff
changeset
|
490 |
=== <tt>!GetHogTeamName(gearUid)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
491 |
Returns the name of the specified hedgehog gear’s team. |
28
026591d95ac6
Edited wiki page LuaAPI through web user interface.
henrik.rostedt
parents:
24
diff
changeset
|
492 |
|
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
493 |
=== <tt>!GetHogName(gearUid)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
494 |
Returns the name of the specified hedgehog gear. |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
495 |
|
140
04d82b673bc4
Edited wiki page LuaAPI through web user interface.
RedGrinner@gmail.com
parents:
139
diff
changeset
|
496 |
=== <tt>!GetEffect(gearUid, effect)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
497 |
Returns the state of given effect for the given hedgehog gear. |
140
04d82b673bc4
Edited wiki page LuaAPI through web user interface.
RedGrinner@gmail.com
parents:
139
diff
changeset
|
498 |
|
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
499 |
See `SetEffect` for further details. |
373 | 500 |
|
133
b737ccb5b49a
Edited wiki page LuaAPI through web user interface.
RedGrinner@gmail.com
parents:
132
diff
changeset
|
501 |
=== <tt>!GetHogHat(gearUid)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
502 |
Returns the hat of the specified hedgehog gear. |
133
b737ccb5b49a
Edited wiki page LuaAPI through web user interface.
RedGrinner@gmail.com
parents:
132
diff
changeset
|
503 |
|
610 | 504 |
=== <tt>!GetHogFlag(gearUid)</tt> (0.9.22) === |
505 |
Returns the name of the flag of the team of the specified hedgehog gear. |
|
506 |
||
507 |
=== <tt>!GetHogGrave(gearUid)</tt> (0.9.22) === |
|
508 |
Returns the name of the grave of the team of the specified hedgehog gear. |
|
509 |
||
510 |
=== <tt>!GetHogVoicepack(gearUid)</tt> (0.9.22) === |
|
511 |
Returns the name of the voicepack of the team of the specified hedgehog gear. |
|
512 |
||
913 | 513 |
=== <tt>!GetAmmoCount(gearUid, ammoType)</tt> (0.9.16) === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
514 |
Returns the ammo count of the specified ammo type for the specified hedgehog gear. |
133
b737ccb5b49a
Edited wiki page LuaAPI through web user interface.
RedGrinner@gmail.com
parents:
132
diff
changeset
|
515 |
|
913 | 516 |
=== <tt>!IsHogLocal(gearUid)</tt> (0.9.23) === |
517 |
Returns `true` if the specified hedgehog gear is controlled by a human player on the computer on which Hedgewars runs on (i.e. not over a computer over the network). Returns `false` otherwise. Returns `nil` if `gearUid` is invalid. |
|
518 |
||
138
9ca80a93aae0
Edited wiki page LuaAPI through web user interface.
RedGrinner@gmail.com
parents:
137
diff
changeset
|
519 |
=== <tt>!GetGearTarget(gearUid, x, y) (0.9.16)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
520 |
Returns the x and y coordinate of target-based weapons/utilities. |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
521 |
<b>Note:</b>: This can’t be used in `onGearAdd()` but must be called after gear creation. |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
522 |
|
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
523 |
=== <tt>GetX(gearUid)</tt> === |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
524 |
Returns x coordinate of the gear. |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
525 |
|
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
526 |
=== <tt>GetY(gearUid)</tt> === |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
527 |
Returns y coordinate of the gear. |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
528 |
|
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
529 |
=== <tt>!GetState(gearUid)</tt> === |
415
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
530 |
Returns the state of the gear. The gear state is a bitmask which is built out of the variables as shown in [States]. |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
531 |
|
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
532 |
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. |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
533 |
|
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
534 |
Examples: |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
535 |
<code language="lua"> |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
536 |
local state = GetState(gear) |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
537 |
--[[ Stores the full raw bitmask of gear in state. Usually |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
538 |
useless on its own. ]] |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
539 |
</code> |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
540 |
|
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
541 |
<code language="lua"> |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
542 |
isDrowning = band(GetState(CurrentHedgehog),gstDrowning) ~= 0 |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
543 |
--[[ GetState(CurrentHedgehog) returns the state bitmask of |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
544 |
CurrentHedgehog, gstDrowning is a bitmask where only the |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
545 |
“drowning” bit is set. band does a bitwise AND on both, if |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
546 |
it returns a non-zero value, the hedgehog is drowning.]] |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
547 |
</code> |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
548 |
|
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
549 |
<code language="lua"> |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
550 |
SetState(CurrentHedgehog, bor(GetState(CurrentHedgehog), gstInvisible)) |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
551 |
--[[ first the state bitmask of CurrentHedgehog is bitwise ORed with |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
552 |
the gstInvisible flag, thus making the bit responsible for |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
553 |
invisiblity to become 1. Then the new bitmask is applied to |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
554 |
CurrentHedgehog, thus making it invisible.]] |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
555 |
</code> |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
556 |
|
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
557 |
|
114
e311af715b57
Edited wiki page LuaAPI through web user interface.
henrik.rostedt@gmail.com
parents:
107
diff
changeset
|
558 |
=== <tt>!GetGearMessage(gearUid)</tt> === |
625 | 559 |
Returns the message of the gear. This is a bitmask built out of flags seen in [GearMessages]. |
419 | 560 |
|
561 |
=== <tt>!GetTag(gearUid)</tt> === |
|
562 |
Returns the tag of the specified gear (by `gearUid`). |
|
563 |
||
891 | 564 |
The `Tag` of a gear is just another arbitrary variable to hold the gear's state. The meaning of a tag depends on the gear type. For example, for `gtBall` gears, it specifies the ball color, for `gtAirAttack` gears (airplane) it specifies the direction of the plane, etc. See [GearTypes] for a full list. The returned value will be an integer. |
419 | 565 |
|
566 |
Note that the word “tag” here does _not_ refer to the name and health tags you see above hedgehogs, this is something different. |
|
567 |
||
568 |
<code language="lua"> |
|
569 |
-- This adds a ball (the one from the ballgun) at (123, 456): |
|
570 |
ball = AddGear(123, 456, gtBall, 0, 0, 0, 0) |
|
571 |
-- The tag of a ball defines its color. It will automatically chosen at random when created. |
|
572 |
colorTag = GetTag(ball) |
|
573 |
-- Now colorTag stores the tag of ball (in this case a number denoting its color) |
|
574 |
</code> |
|
575 |
||
421
d584704354ad
Add link to GearTypes for SetTag and GetTag.
almikes@aol.com
parents:
419
diff
changeset
|
576 |
The meaning of tags are described in [GearTypes]. |
419 | 577 |
|
209
26805ae2a319
Edited wiki page LuaAPI through web user interface.
RedGrinner@gmail.com
parents:
203
diff
changeset
|
578 |
=== <tt>!GetFollowGear()</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
579 |
Returns the uid of the gear that is currently being followed. |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
580 |
|
181 | 581 |
=== <tt>!GetTimer(gearUid)</tt> === |
891 | 582 |
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 RC plane time. See [GearTypes] for a full list. |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
583 |
|
181 | 584 |
=== <tt>!GetHealth(gearUid)</tt> === |
891 | 585 |
Returns the health of the gear. Depending on the gear type, the gear's “health” can also refer to other things, see [GearTypes] for a full list. |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
586 |
|
181 | 587 |
=== <tt>!GetHogLevel(gearUid)</tt> === |
576 | 588 |
Returns the bot level ranging from `0` to `5`. `1` is the strongest bot level and `5` is the weakest one. `0` is for human player. |
39
45a576e56425
Updating with visual gear functions and delete gear
kyberneticist
parents:
38
diff
changeset
|
589 |
|
503 | 590 |
=== <tt>!GetGearPos(gearUid)</tt> === |
891 | 591 |
Get the `Pos` value of the specified gear. `Pos` is just another arbitrary value to hold the state of the gear, such as `Tag` and `Health`, the meaning depends on the gear type. See [GearTypes] for the conrete meaning of a gear's `Pos` value. |
592 |
||
593 |
*Important*: Pos is *not* related to the gear's position, use `GetGearPosition` for that. |
|
503 | 594 |
|
612 | 595 |
=== <tt>!GetGearValues(gearUid)</tt> (0.9.22) === |
616 | 596 |
This returns a bunch of values associated with the gear, their meaning is often depending on the gear type and many values might be unused for certain gear types. |
612 | 597 |
|
598 |
This is returned (all variables are integers): |
|
599 |
||
688
d9fc58ac04f2
Update EraseSprite, PlaceSprite and Get/Set GearValues
nemo
parents:
685
diff
changeset
|
600 |
`Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, nImpactSounds, Tint, Damage, Boom` |
d9fc58ac04f2
Update EraseSprite, PlaceSprite and Get/Set GearValues
nemo
parents:
685
diff
changeset
|
601 |
|
d9fc58ac04f2
Update EraseSprite, PlaceSprite and Get/Set GearValues
nemo
parents:
685
diff
changeset
|
602 |
Boom is 0.9.23+ |
612 | 603 |
|
604 |
A rough description of some of the parameters: |
|
615 | 605 |
|
606 |
* `Radius`: Effect or collision radius, most of the time |
|
625 | 607 |
* `ImpactSound`: Sound it makes on a collision (see [Sounds]) |
615 | 608 |
* `Tint`: Used by some gear types to determine its colorization. The color is in RGBA format. |
688
d9fc58ac04f2
Update EraseSprite, PlaceSprite and Get/Set GearValues
nemo
parents:
685
diff
changeset
|
609 |
* `Boom`: Used by most gears to determine the damage dealt. (0.9.23+) |
612 | 610 |
|
611 |
Example: |
|
612 |
<code language="lua"> |
|
688
d9fc58ac04f2
Update EraseSprite, PlaceSprite and Get/Set GearValues
nemo
parents:
685
diff
changeset
|
613 |
-- Get all values in a single line of code (omit Boom in 0.9.22) : |
d9fc58ac04f2
Update EraseSprite, PlaceSprite and Get/Set GearValues
nemo
parents:
685
diff
changeset
|
614 |
local Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, nImpactSounds, Tint, Damage, Boom = GetGearValues(myGear) |
612 | 615 |
</code> |
616 |
||
181 | 617 |
=== <tt>!GetVisualGearValues(vgUid)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
618 |
This returns the typically set visual gear values, useful if manipulating things like smoke or bubbles or circles. It returns the following values: |
614 | 619 |
|
620 |
`X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint` |
|
621 |
||
615 | 622 |
* `X`, `Y`: typically position |
623 |
* `dX`, `dY`: typically speed |
|
624 |
* `Angle` is usually the rotation angle |
|
625 |
* `Frame` is typically the animation frame |
|
626 |
* `FrameTicks` is usually an animation counter |
|
627 |
* `State` can have a variety of values, but is typically bit packed |
|
628 |
* `Timer` is usually the gear lifetime |
|
629 |
* `Tint` is the RGBA color |
|
614 | 630 |
|
39
45a576e56425
Updating with visual gear functions and delete gear
kyberneticist
parents:
38
diff
changeset
|
631 |
Most visual gears require little to no modification of parameters. |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
632 |
|
39
45a576e56425
Updating with visual gear functions and delete gear
kyberneticist
parents:
38
diff
changeset
|
633 |
Example: |
45a576e56425
Updating with visual gear functions and delete gear
kyberneticist
parents:
38
diff
changeset
|
634 |
|
416
5aa55bbe4b73
Fixed faulty syntax highlighting in code block (was: “<code lang=…” instead of “<code language=…”)
almikes@aol.com
parents:
415
diff
changeset
|
635 |
<code language="lua"> GetVisualGearValues(vgUid) -- return visual gear values |
39
45a576e56425
Updating with visual gear functions and delete gear
kyberneticist
parents:
38
diff
changeset
|
636 |
</code> |
45a576e56425
Updating with visual gear functions and delete gear
kyberneticist
parents:
38
diff
changeset
|
637 |
|
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
638 |
== Functions to modify gears == |
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
639 |
|
243
ac34d3763a17
Edited wiki page LuaAPI through web user interface.
szabibibi@gmail.com
parents:
209
diff
changeset
|
640 |
=== <tt>!HideHog(gearUid)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
641 |
Removes a hedgehog from the map. The hidden hedgehog can be restored with `RestoreHog(gearUid)`. The current hedgehog cannot be hidden! |
243
ac34d3763a17
Edited wiki page LuaAPI through web user interface.
szabibibi@gmail.com
parents:
209
diff
changeset
|
642 |
|
ac34d3763a17
Edited wiki page LuaAPI through web user interface.
szabibibi@gmail.com
parents:
209
diff
changeset
|
643 |
Example: |
ac34d3763a17
Edited wiki page LuaAPI through web user interface.
szabibibi@gmail.com
parents:
209
diff
changeset
|
644 |
|
416
5aa55bbe4b73
Fixed faulty syntax highlighting in code block (was: “<code lang=…” instead of “<code language=…”)
almikes@aol.com
parents:
415
diff
changeset
|
645 |
<code language="lua"> gear = AddGear(...) |
361
315e9db1f458
no need to prevent linking of names in code blocks
sheepyluva@gmail.com
parents:
360
diff
changeset
|
646 |
HideHog(gear) -- Hide the newly created gear.</code> |
243
ac34d3763a17
Edited wiki page LuaAPI through web user interface.
szabibibi@gmail.com
parents:
209
diff
changeset
|
647 |
|
ac34d3763a17
Edited wiki page LuaAPI through web user interface.
szabibibi@gmail.com
parents:
209
diff
changeset
|
648 |
=== <tt>!RestoreHog(gearUid)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
649 |
Restores a previously hidden hedgehog. |
243
ac34d3763a17
Edited wiki page LuaAPI through web user interface.
szabibibi@gmail.com
parents:
209
diff
changeset
|
650 |
|
ac34d3763a17
Edited wiki page LuaAPI through web user interface.
szabibibi@gmail.com
parents:
209
diff
changeset
|
651 |
Example: |
ac34d3763a17
Edited wiki page LuaAPI through web user interface.
szabibibi@gmail.com
parents:
209
diff
changeset
|
652 |
|
416
5aa55bbe4b73
Fixed faulty syntax highlighting in code block (was: “<code lang=…” instead of “<code language=…”)
almikes@aol.com
parents:
415
diff
changeset
|
653 |
<code language="lua"> gear = AddGear(...) |
361
315e9db1f458
no need to prevent linking of names in code blocks
sheepyluva@gmail.com
parents:
360
diff
changeset
|
654 |
HideHog(gear) -- Hide the newly created gear. |
315e9db1f458
no need to prevent linking of names in code blocks
sheepyluva@gmail.com
parents:
360
diff
changeset
|
655 |
RestoreHog(gear) -- Restore the newly hidden gear.</code> |
243
ac34d3763a17
Edited wiki page LuaAPI through web user interface.
szabibibi@gmail.com
parents:
209
diff
changeset
|
656 |
|
39
45a576e56425
Updating with visual gear functions and delete gear
kyberneticist
parents:
38
diff
changeset
|
657 |
=== <tt>!DeleteGear(gearUid)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
658 |
Deletes a gear. |
39
45a576e56425
Updating with visual gear functions and delete gear
kyberneticist
parents:
38
diff
changeset
|
659 |
|
45a576e56425
Updating with visual gear functions and delete gear
kyberneticist
parents:
38
diff
changeset
|
660 |
Example: |
45a576e56425
Updating with visual gear functions and delete gear
kyberneticist
parents:
38
diff
changeset
|
661 |
|
416
5aa55bbe4b73
Fixed faulty syntax highlighting in code block (was: “<code lang=…” instead of “<code language=…”)
almikes@aol.com
parents:
415
diff
changeset
|
662 |
<code language="lua"> gear = AddGear(...) |
361
315e9db1f458
no need to prevent linking of names in code blocks
sheepyluva@gmail.com
parents:
360
diff
changeset
|
663 |
DeleteGear(gear) -- Delete the newly created gear.</code> |
39
45a576e56425
Updating with visual gear functions and delete gear
kyberneticist
parents:
38
diff
changeset
|
664 |
|
181 | 665 |
=== <tt>!DeleteVisualGear(vgUid)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
666 |
Deletes a visual gear. Note, most visual gears delete themselves. |
39
45a576e56425
Updating with visual gear functions and delete gear
kyberneticist
parents:
38
diff
changeset
|
667 |
|
45a576e56425
Updating with visual gear functions and delete gear
kyberneticist
parents:
38
diff
changeset
|
668 |
Example: |
45a576e56425
Updating with visual gear functions and delete gear
kyberneticist
parents:
38
diff
changeset
|
669 |
|
416
5aa55bbe4b73
Fixed faulty syntax highlighting in code block (was: “<code lang=…” instead of “<code language=…”)
almikes@aol.com
parents:
415
diff
changeset
|
670 |
<code language="lua"> vgear = AddVisualGear(...) |
361
315e9db1f458
no need to prevent linking of names in code blocks
sheepyluva@gmail.com
parents:
360
diff
changeset
|
671 |
DeleteVisualGear(vgear) -- Delete the newly created visual gear.</code> |
39
45a576e56425
Updating with visual gear functions and delete gear
kyberneticist
parents:
38
diff
changeset
|
672 |
|
688
d9fc58ac04f2
Update EraseSprite, PlaceSprite and Get/Set GearValues
nemo
parents:
685
diff
changeset
|
673 |
=== <tt>!SetGearValues(gearUid, Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, ImpactSounds, Tint, Damage, Boom)</tt> (0.9.22) === |
d9fc58ac04f2
Update EraseSprite, PlaceSprite and Get/Set GearValues
nemo
parents:
685
diff
changeset
|
674 |
Sets various gear value for the specified gear (`gearUid`). The meaining of each value often depends on the gear type. See the documentation on !GetGearValues for a brief description of the gear values. Boom is 0.9.23+. |
612 | 675 |
|
676 |
Set `nil` for each value you do not want to change. |
|
677 |
||
678 |
Example: |
|
679 |
<code language="lua"> |
|
680 |
-- Paints all RC planes into a white color |
|
681 |
function onGearAdd(gear) |
|
682 |
if GetGearType(gear) == gtRCPlane then |
|
683 |
SetGearValues(gear, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0xFFFFFFFF) |
|
684 |
end |
|
685 |
end |
|
686 |
</code> |
|
39
45a576e56425
Updating with visual gear functions and delete gear
kyberneticist
parents:
38
diff
changeset
|
687 |
|
554 | 688 |
=== <tt>!SetVisualGearValues(vgUid, X, Y, dX, dY, Angle, Frame, !FrameTicks, State, Timer, Tint)</tt> === |
613 | 689 |
This allows manipulation of many of the visual gear values. In the case of `vgtCircle`, the visual gear values are mapped as follows: |
690 |
||
615 | 691 |
* `X`, `Y`: Position |
692 |
* `State`: Radius. |
|
693 |
* `Timer`: Thickness |
|
694 |
* `FrameTicks`: Pulsation speed (`0` to disable) |
|
695 |
* `dX`, `dY`: min/max pulsation opacity (`0`-`255`) |
|
696 |
* `Tint`: RGBA color |
|
613 | 697 |
|
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
698 |
Most visual gears require little to no modification of parameters. |
39
45a576e56425
Updating with visual gear functions and delete gear
kyberneticist
parents:
38
diff
changeset
|
699 |
|
613 | 700 |
Example 1: |
39
45a576e56425
Updating with visual gear functions and delete gear
kyberneticist
parents:
38
diff
changeset
|
701 |
|
416
5aa55bbe4b73
Fixed faulty syntax highlighting in code block (was: “<code lang=…” instead of “<code language=…”)
almikes@aol.com
parents:
415
diff
changeset
|
702 |
<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. |
552 | 703 |
SetVisualGearValues(circleUid, 1000,1000, 20, 200, 0, 0, 100, 50, 3, 0xff0000ff)</code> |
704 |
||
705 |
Beginning from 0.9.21-dev, the 2nd to 11th arguments are optional. Any such argument which is declared as `nil` will not overwrite the corresponding value of the visual gear. With this change, it is not required anymore to call `GetVisualGearValues` beforehand. |
|
706 |
||
613 | 707 |
Example 2: |
552 | 708 |
|
709 |
<code language="lua"> -- set a circle to position 1000,1000 |
|
710 |
SetVisualGearValues(circleUid, 1000, 1000)</code> |
|
711 |
<code language="lua"> -- set the color of a circle to bright red. |
|
712 |
SetVisualGearValues(circleUid, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0xff0000ff)</code> |
|
713 |
||
39
45a576e56425
Updating with visual gear functions and delete gear
kyberneticist
parents:
38
diff
changeset
|
714 |
|
136
538adf2596b5
Edited wiki page LuaAPI through web user interface.
RedGrinner@gmail.com
parents:
135
diff
changeset
|
715 |
=== <tt>!FindPlace(gearUid, fall, left, right, tryHarder) (0.9.16)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
716 |
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. |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
717 |
|
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
718 |
Example: |
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
719 |
|
416
5aa55bbe4b73
Fixed faulty syntax highlighting in code block (was: “<code lang=…” instead of “<code language=…”)
almikes@aol.com
parents:
415
diff
changeset
|
720 |
<code language="lua"> gear = AddGear(...) |
361
315e9db1f458
no need to prevent linking of names in code blocks
sheepyluva@gmail.com
parents:
360
diff
changeset
|
721 |
FindPlace(gear, true, 0, LAND_WIDTH) -- places the gear randomly between 0 and LAND_WIDTH</code> |
533 | 722 |
=== <tt>!HogSay(gearUid, text, manner [,vgState])</tt> === |
723 |
Makes the specified gear say, think, or shout some text in a comic-style speech or thought bubble. In 0.9.21 `gearUid` is _not_ limited to hedgehogs, altough the function name suggests otherwise. |
|
724 |
||
725 |
The `manner` parameter specifies the type of the bubble and can have one of these values: |
|
59
233360620ae2
Edited wiki page LuaAPI through web user interface.
RedGrinner
parents:
58
diff
changeset
|
726 |
|
533 | 727 |
|| *Value of `manner`* || *Looks* || |
728 |
|| `SAY_THINK` || Thought bubble || |
|
729 |
|| `SAY_SAY` || Speech bubble || |
|
730 |
|| `SAY_SHOUT` || Exclamatory bubble (denotes shouting) || |
|
59
233360620ae2
Edited wiki page LuaAPI through web user interface.
RedGrinner
parents:
58
diff
changeset
|
731 |
|
533 | 732 |
As of 0.9.21, there is a optional 4th parameter `vgState`, it defines wheather the speechbubble is drawn fully opaque or semi-transparent. The value `0` is the default value. |
733 |
||
734 |
|| *Value of `vgState`* || *Effect* || |
|
735 |
|| `0` || If the specified gear is a hedgehog, and it’s the turn of the hedgehog’s team, the bubble is drawn fully opaque.<br>If the gear is a hedgehog, and it’s another team’s turn, the bubble is drawn translucent.<br>If the gear is not a hedgehog, the bubble is drawn fully opaque. || |
|
736 |
|| `1` || The bubble is drawn translucent. || |
|
737 |
|| `2` || The bubble is drawn fully opaque. || |
|
738 |
||
739 |
Examples: |
|
740 |
||
741 |
<code language="lua">HogSay(CurrentHedgehog, "I wonder what to do …", SAY_THINK) -- thought bubble with text “I wonder what to do …”</code> |
|
742 |
<code language="lua">HogSay(CurrentHedgehog, "I'm hungry.", SAY_SAY) -- speech bubble with text “I’m hungry.”</code> |
|
743 |
<code language="lua">HogSay(CurrentHedgehog, "I smell CAKE!", SAY_SHOUT) -- exclamatory bubble with text “I smell CAKE!”</code> |
|
52
714b56de5ea1
Edited wiki page LuaAPI through web user interface.
RedGrinner
parents:
51
diff
changeset
|
744 |
=== <tt>!HogTurnLeft(gearUid, boolean)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
745 |
Faces the specified hog left or right. |
52
714b56de5ea1
Edited wiki page LuaAPI through web user interface.
RedGrinner
parents:
51
diff
changeset
|
746 |
|
714b56de5ea1
Edited wiki page LuaAPI through web user interface.
RedGrinner
parents:
51
diff
changeset
|
747 |
Example: |
714b56de5ea1
Edited wiki page LuaAPI through web user interface.
RedGrinner
parents:
51
diff
changeset
|
748 |
|
416
5aa55bbe4b73
Fixed faulty syntax highlighting in code block (was: “<code lang=…” instead of “<code language=…”)
almikes@aol.com
parents:
415
diff
changeset
|
749 |
<code language="lua"> HogTurnLeft(CurrentHedgehog, true) -- turns CurrentHedgehog left |
361
315e9db1f458
no need to prevent linking of names in code blocks
sheepyluva@gmail.com
parents:
360
diff
changeset
|
750 |
HogTurnLeft(CurrentHedgehog, false) -- turns CurrentHedgehog right</code> |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
751 |
=== <tt>!SetGearPosition(gearUid, x, y)</tt> === |
891 | 752 |
Places the specified gear exactly at the position (`x`,`y`). Not to be confused with `SetGearPos`. |
71
2dcbebb06088
Edited wiki page LuaAPI through web user interface.
henrik.rostedt
parents:
70
diff
changeset
|
753 |
|
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
754 |
=== <tt>!SetGearVelocity(gearUid, dx, dy)</tt> === |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
755 |
Gives the specified gear the velocity of `dx`, `dy`. |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
756 |
|
555 | 757 |
=== <tt>!SetFlightTime(gearUid, flighttime)</tt> === |
758 |
Sets the `FlightTime` of the given gear to `flighttime`. The meaning of `FlightTime` is explained in the section `GetFlightTime`. |
|
759 |
||
611 | 760 |
=== <tt>!SetGearElasticity(gearUid, Elasticity) </tt> === |
761 |
Sets the elasticity of the specified gear. For most gears, the elasticity determines how strong the gear will bounce after collisions, where higher elasticity is for stronger bounces. Recommended are values between `0` and `9999`. |
|
762 |
||
763 |
=== <tt>!SetGearFriction(gearUid, Friction) </tt> === |
|
764 |
Sets the friction of the specified gear. The friction normally determines how well the gear will slide on terrain. Higher values are for increased sliding properties. `0` is for no sliding whatsoever, where `9999` is for very long slides, greater values are not recommended. |
|
765 |
||
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
766 |
=== <tt>!SetHealth(gearUid, health)</tt> === |
891 | 767 |
Sets the health of the specified gear. The “health” of a gear can refer to many things, depending on the gear type. |
99
983ec9ac63c7
Added a non-exhaustive list of examples for further applications of SetHealth()
RedGrinner@gmail.com
parents:
98
diff
changeset
|
768 |
|
891 | 769 |
Use cases: |
99
983ec9ac63c7
Added a non-exhaustive list of examples for further applications of SetHealth()
RedGrinner@gmail.com
parents:
98
diff
changeset
|
770 |
|
891 | 771 |
* Setting the health of a hedgehog (`gtHedgehog`) to 99 |
772 |
* Starting the RC Plane (`gtRCPlane`) with 10 bombs |
|
773 |
* Starting flying saucer (`gtJetpack`) with only 50% fuel |
|
774 |
* Setting all the mines (`gtMine`) to duds |
|
775 |
* And more! |
|
776 |
||
777 |
See [GearTypes] for a full description. |
|
99
983ec9ac63c7
Added a non-exhaustive list of examples for further applications of SetHealth()
RedGrinner@gmail.com
parents:
98
diff
changeset
|
778 |
|
416
5aa55bbe4b73
Fixed faulty syntax highlighting in code block (was: “<code lang=…” instead of “<code language=…”)
almikes@aol.com
parents:
415
diff
changeset
|
779 |
<code language="lua"> function onGearAdd(gear) |
891 | 780 |
if (GetGearType(gear) == gtHedgehog) then |
781 |
-- Set hedgehog health to 99 |
|
782 |
SetHealth(gear, 99) |
|
783 |
end |
|
361
315e9db1f458
no need to prevent linking of names in code blocks
sheepyluva@gmail.com
parents:
360
diff
changeset
|
784 |
if (GetGearType(gear) == gtRCPlaane) then |
891 | 785 |
-- Give the plane 10 bombs |
361
315e9db1f458
no need to prevent linking of names in code blocks
sheepyluva@gmail.com
parents:
360
diff
changeset
|
786 |
SetHealth(gear, 10) |
99
983ec9ac63c7
Added a non-exhaustive list of examples for further applications of SetHealth()
RedGrinner@gmail.com
parents:
98
diff
changeset
|
787 |
end |
361
315e9db1f458
no need to prevent linking of names in code blocks
sheepyluva@gmail.com
parents:
360
diff
changeset
|
788 |
if (GetGearType(gear) == gtJetpack) then |
891 | 789 |
-- Set fuel to 50% only |
361
315e9db1f458
no need to prevent linking of names in code blocks
sheepyluva@gmail.com
parents:
360
diff
changeset
|
790 |
SetHealth(gear, 1000) |
99
983ec9ac63c7
Added a non-exhaustive list of examples for further applications of SetHealth()
RedGrinner@gmail.com
parents:
98
diff
changeset
|
791 |
end |
361
315e9db1f458
no need to prevent linking of names in code blocks
sheepyluva@gmail.com
parents:
360
diff
changeset
|
792 |
if (GetGearType(gear) == gtMine) then |
891 | 793 |
-- Turn mine into dud |
361
315e9db1f458
no need to prevent linking of names in code blocks
sheepyluva@gmail.com
parents:
360
diff
changeset
|
794 |
SetHealth(gear, 0) |
99
983ec9ac63c7
Added a non-exhaustive list of examples for further applications of SetHealth()
RedGrinner@gmail.com
parents:
98
diff
changeset
|
795 |
end |
983ec9ac63c7
Added a non-exhaustive list of examples for further applications of SetHealth()
RedGrinner@gmail.com
parents:
98
diff
changeset
|
796 |
end</code> |
983ec9ac63c7
Added a non-exhaustive list of examples for further applications of SetHealth()
RedGrinner@gmail.com
parents:
98
diff
changeset
|
797 |
|
983ec9ac63c7
Added a non-exhaustive list of examples for further applications of SetHealth()
RedGrinner@gmail.com
parents:
98
diff
changeset
|
798 |
|
983ec9ac63c7
Added a non-exhaustive list of examples for further applications of SetHealth()
RedGrinner@gmail.com
parents:
98
diff
changeset
|
799 |
|
373 | 800 |
=== <tt>!SetEffect(gearUid, effect, effectState)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
801 |
Sets the state for one of the effects <tt>heInvulnerable, heResurrectable, hePoisoned, heResurrected, heFrozen</tt> for the specified hedgehog gear. |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
802 |
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. |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
803 |
|
824 | 804 |
|| *`effect`* || *Description* || *`effectState`* || |
823 | 805 |
|| `heInvulnerable` || Wether hog is invulnerable || Any non-zero value turns on invulnerability. `0` turns it off. || |
806 |
|| `hePoisoned` || Poison damage, damages hog each turn. || Amount of damage per turn. Use `0` to disable poisoning. || |
|
807 |
|| `heResurrectable` || Whether to resurrect the hog on death || With a non-zero value, the hedgehog will be resurrected and teleported to a random location on death. `0` disables this. || |
|
824 | 808 |
|| `heResurrected` || Whether the hedgehog has been resurrected once. This is only a subtle graphical effect. || With a non-zero value, the hedgehog was resurrected, `0` otherwise. || |
907 | 809 |
|| `heFrozen` || Freeze level. Frozen hedgehogs skip turn, are heavy and take half damage || The number denotes “how frozen” the hedgehog is, i.e. how long it takes to melt. The freezer sets this to `199999` initially. The value will be reduced by `50000` each round. Being hit by a flame reduces this number by `1000`. If `0`, the hedgehog is not frozen. The value will also be used for some other things by the engine, like animation, etc. || |
823 | 810 |
|
811 |
Example (sets all bots poisoned with poison damage of 1): |
|
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
812 |
|
416
5aa55bbe4b73
Fixed faulty syntax highlighting in code block (was: “<code lang=…” instead of “<code language=…”)
almikes@aol.com
parents:
415
diff
changeset
|
813 |
<code language="lua"> function onGearAdd(gear) |
558 | 814 |
if (GetGearType(gear) == gtHedgehog) and (GetHogLevel(gear) > 0) then |
373 | 815 |
SetEffect(gear, hePoisoned, 1) |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
816 |
end |
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
817 |
end</code> |
181 | 818 |
|
823 | 819 |
*Historic note*: prior to the ice-gun release, 0.9.19 (commit r10a0a31804f3) `effectState` was of boolean type (`true` = effect enabled, `false` = effect disabled) |
373 | 820 |
|
17 | 821 |
=== <tt>CopyPV(gearUid, gearUid)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
822 |
This sets the position and velocity of the second gear to the first one. |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
823 |
|
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
824 |
=== <tt>!FollowGear(gearUid)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
825 |
Makes the game client follow the specifiec gear. |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
826 |
|
139
6bf231a611a7
Edited wiki page LuaAPI through web user interface.
RedGrinner@gmail.com
parents:
138
diff
changeset
|
827 |
=== <tt>!SetHogName(gearUid, name)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
828 |
Sets the name of the specified hedgehog gear. |
139
6bf231a611a7
Edited wiki page LuaAPI through web user interface.
RedGrinner@gmail.com
parents:
138
diff
changeset
|
829 |
|
398
1f9f7fb00be3
Added entries for SetHogTeamName, SetWeapon
RedGrinner@gmail.com
parents:
394
diff
changeset
|
830 |
=== <tt>!SetHogTeamName(gearUid, name)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
831 |
Sets the team name of the specified hedgehog gear. |
398
1f9f7fb00be3
Added entries for SetHogTeamName, SetWeapon
RedGrinner@gmail.com
parents:
394
diff
changeset
|
832 |
|
1f9f7fb00be3
Added entries for SetHogTeamName, SetWeapon
RedGrinner@gmail.com
parents:
394
diff
changeset
|
833 |
=== <tt>!SetWeapon(ammoType)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
834 |
Sets the selected weapon of `CurrentHedgehog` to one of the [AmmoTypes Ammo Type]. |
398
1f9f7fb00be3
Added entries for SetHogTeamName, SetWeapon
RedGrinner@gmail.com
parents:
394
diff
changeset
|
835 |
|
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
836 |
Example: |
398
1f9f7fb00be3
Added entries for SetHogTeamName, SetWeapon
RedGrinner@gmail.com
parents:
394
diff
changeset
|
837 |
|
416
5aa55bbe4b73
Fixed faulty syntax highlighting in code block (was: “<code lang=…” instead of “<code language=…”)
almikes@aol.com
parents:
415
diff
changeset
|
838 |
<code language="lua"> |
398
1f9f7fb00be3
Added entries for SetHogTeamName, SetWeapon
RedGrinner@gmail.com
parents:
394
diff
changeset
|
839 |
AddAmmo(CurrentHedgehog, amBazooka, 1) -- give the CurrentHedgehog a bazooka |
1f9f7fb00be3
Added entries for SetHogTeamName, SetWeapon
RedGrinner@gmail.com
parents:
394
diff
changeset
|
840 |
SetWeapon(amBazooka) -- select the Bazooka.</code> |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
841 |
|
408 | 842 |
|
410 | 843 |
=== <tt>!SetNextWeapon()</tt> (0.9.21) === |
408 | 844 |
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. |
845 |
||
846 |
||
139
6bf231a611a7
Edited wiki page LuaAPI through web user interface.
RedGrinner@gmail.com
parents:
138
diff
changeset
|
847 |
=== <tt>!SetHogHat(gearUid, hat)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
848 |
Sets the hat of the specified hedgehog gear. |
139
6bf231a611a7
Edited wiki page LuaAPI through web user interface.
RedGrinner@gmail.com
parents:
138
diff
changeset
|
849 |
|
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
850 |
=== <tt>!SetGearTarget(gearUid, x, y) (0.9.16)</tt> === |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
851 |
Sets the x and y coordinate of target-based weapons/utilities. |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
852 |
*Note*: This can’t be used in onGearAdd() but must be called after gear creation. |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
853 |
|
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
854 |
=== <tt>!SetState(gearUid, state)</tt> === |
415
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
855 |
Sets the state of the specified gear to the specified `state`. This is a bitmask made out of the variables as seen in [States]. |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
856 |
|
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
857 |
This function is often used together with `GetState` and the bitmask utility functions `band` and `bnot` in order to manipulate a single flag. |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
858 |
|
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
859 |
Examples: |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
860 |
<code language="lua"> |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
861 |
SetState(CurrentHedgehog, bor(GetState(CurrentHedgehog), gstInvisible)) |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
862 |
--[[ first the state bitmask of CurrentHedgehog is bitwise ORed with |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
863 |
the gstInvisible flag, thus making the bit responsible for |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
864 |
invisiblity to become 1. Then the new bitmask is applied to |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
865 |
CurrentHedgehog, thus making it invisible. ]] |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
866 |
</code> |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
867 |
|
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
868 |
<code language="lua"> |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
869 |
SetState(CurrentHedgehog, band(GetState(CurrentHedgehog), bnot(gstInvisible))) |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
870 |
--[[ The reverse of the above: This function toggles CurrentHedgehog’s |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
871 |
gstInvisible flag off, thus making it visible again. ]] |
70961d4eef05
Fixed misleading descriptions of GetState and SetState (use of bitmasks were not mentioned). Added commented examples.
almikes@aol.com
parents:
414
diff
changeset
|
872 |
</code> |
28
026591d95ac6
Edited wiki page LuaAPI through web user interface.
henrik.rostedt
parents:
24
diff
changeset
|
873 |
|
114
e311af715b57
Edited wiki page LuaAPI through web user interface.
henrik.rostedt@gmail.com
parents:
107
diff
changeset
|
874 |
=== <tt>!SetGearMessage(gearUid, message)</tt> === |
625 | 875 |
Sets the gear messages of the specified gear. `message` is a bitmask built out of flags seen in [GearMessages]. |
114
e311af715b57
Edited wiki page LuaAPI through web user interface.
henrik.rostedt@gmail.com
parents:
107
diff
changeset
|
876 |
|
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
877 |
=== <tt>!SetTag(gearUid, tag)</tt> === |
891 | 878 |
Sets the `Tag` value of the specified gear (by `gearUid`). The `Tag` value of a gear is simply an extra variable to modify misc. things. The meaning of a tag depends on the gear type. For example, for `gtBall` gears, it specifies the ball color, for `gtAirAttack` gears (airplane) it specifies the direction of the plane, etc. See [GearTypes] for a full list. `tag` has to be an integer. |
419 | 879 |
|
880 |
Note that the word “tag” here does _not_ refer to the name and health tags you see above hedgehogs, this is something different. |
|
881 |
||
882 |
<code language="lua"> |
|
883 |
-- This adds a ball (the one from the ballgun) at (123, 456): |
|
884 |
ball = AddGear(123, 456, gtBall, 0, 0, 0, 0) |
|
885 |
-- This sets the tag of the gear. For gtBall, the tag specified the color. “8” is the color white. |
|
886 |
SetTag(ball, 8) -- |
|
887 |
</code> |
|
888 |
||
421
d584704354ad
Add link to GearTypes for SetTag and GetTag.
almikes@aol.com
parents:
419
diff
changeset
|
889 |
The meaning of tags are described in [GearTypes]. |
28
026591d95ac6
Edited wiki page LuaAPI through web user interface.
henrik.rostedt
parents:
24
diff
changeset
|
890 |
|
181 | 891 |
=== <tt>!SetTimer(gearUid, timer)</tt> === |
891 | 892 |
Sets the timer of the specified gear. Also see `GetTimer`. |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
893 |
|
360 | 894 |
=== <tt>!SetHogLevel(gearUid, level)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
895 |
Sets the bot level from 0 to 5. `0` means human player. |
69
48f6e6c0076d
Edited wiki page LuaAPI through web user interface.
henrik.rostedt
parents:
68
diff
changeset
|
896 |
|
360 | 897 |
=== <tt>!SetGearPos(gearUid, value) (0.9.18-dev)</tt> === |
891 | 898 |
Sets the `Pos` value (not the position!) of the specified gear to specified value. See `GetGearPos` for more information. |
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
899 |
|
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
900 |
== Gameplay functions == |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
901 |
|
549 | 902 |
=== `GameFlags` functions === |
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
903 |
|
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
904 |
==== <tt>!ClearGameFlags()</tt> ==== |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
905 |
Disables *all* !GameFlags. |
380 | 906 |
|
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
907 |
==== <tt>!DisableGameFlags(gameflag, ...)</tt> ==== |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
908 |
Disables the listed !GameFlags, without changing the status of other !GameFlags. |
380 | 909 |
|
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
910 |
==== <tt>!EnableGameFlags(gameflag, ...)</tt> ==== |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
911 |
Enables the listed !GameFlags, without changing the status of other !GameFlags. |
380 | 912 |
|
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
913 |
==== <tt>!GetGameFlag(gameflag)</tt> ==== |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
914 |
Returns `true` if the specified gameflag is enabled, otherwise `false`. |
380 | 915 |
|
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
916 |
=== Environment === |
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
917 |
|
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
918 |
==== <tt>!SetGravity(percent)</tt> ==== |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
919 |
Changes the current gravity of the game in percent (relative to default, integer value). |
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
920 |
Setting it to 100 will set gravity to default gravity of hedgewars, 200 will double it, etc. |
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
921 |
|
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
922 |
==== <tt>!GetGravity()</tt> ==== |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
923 |
Returns the current gravity in percent. |
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
924 |
|
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
925 |
==== <tt>!SetWaterLine(waterline)</tt> ==== |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
926 |
Sets the water level (`WaterLine`) to the specified y-coordinate. |
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
927 |
|
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
928 |
==== <tt>!SetWind(windSpeed)</tt> ==== |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
929 |
Sets the current wind in the range of -100 to 100. Use together with `gfDisableWind` for full control. |
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
930 |
|
608 | 931 |
==== <tt>!SetMaxBuildDistance(distInPx)</tt> (0.9.22) ==== |
790 | 932 |
Sets the maximum building distance for of girders and rubber bands in pixels to `distInPx`. If `distInPx` is `0`, the limit is disabled. If called without arguments, the distance will be reset to the default value. |
608 | 933 |
|
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
934 |
==== <tt>!EndGame()</tt> ==== |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
935 |
Makes the game end. |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
936 |
|
912
ea13b02292c5
LuaAPI: Move non-gear related ammo functions to new section
Wuzzy
parents:
911
diff
changeset
|
937 |
=== Ammo === |
ea13b02292c5
LuaAPI: Move non-gear related ammo functions to new section
Wuzzy
parents:
911
diff
changeset
|
938 |
==== <tt>!SetAmmo(ammoType, count, probability, delay, numberInCrate)</tt> ==== |
ea13b02292c5
LuaAPI: Move non-gear related ammo functions to new section
Wuzzy
parents:
911
diff
changeset
|
939 |
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. |
ea13b02292c5
LuaAPI: Move non-gear related ammo functions to new section
Wuzzy
parents:
911
diff
changeset
|
940 |
|
ea13b02292c5
LuaAPI: Move non-gear related ammo functions to new section
Wuzzy
parents:
911
diff
changeset
|
941 |
Example: |
ea13b02292c5
LuaAPI: Move non-gear related ammo functions to new section
Wuzzy
parents:
911
diff
changeset
|
942 |
|
ea13b02292c5
LuaAPI: Move non-gear related ammo functions to new section
Wuzzy
parents:
911
diff
changeset
|
943 |
<code language="lua"> SetAmmo(amShotgun, 9, 0, 0, 0) -- unlimited amount of shotgun ammo for players |
ea13b02292c5
LuaAPI: Move non-gear related ammo functions to new section
Wuzzy
parents:
911
diff
changeset
|
944 |
SetAmmo(amGrenade, 0, 0, 0, 3) -- crates should contain always three grenade</code> |
ea13b02292c5
LuaAPI: Move non-gear related ammo functions to new section
Wuzzy
parents:
911
diff
changeset
|
945 |
|
ea13b02292c5
LuaAPI: Move non-gear related ammo functions to new section
Wuzzy
parents:
911
diff
changeset
|
946 |
==== <tt>!SetAmmoDelay(ammoType, delay)</tt> ==== |
ea13b02292c5
LuaAPI: Move non-gear related ammo functions to new section
Wuzzy
parents:
911
diff
changeset
|
947 |
Changes the delay of a specified [AmmoTypes Ammo Type]. |
ea13b02292c5
LuaAPI: Move non-gear related ammo functions to new section
Wuzzy
parents:
911
diff
changeset
|
948 |
|
918
87e1d0a11e99
LuaAPI: Add SetAmmoDescriptionAppendix, SetAmmoTexts and update GetAmmoName
Wuzzy
parents:
917
diff
changeset
|
949 |
==== <tt>!SetAmmoTexts(ammoType, name, caption, description)</tt> (0.9.23) ==== |
87e1d0a11e99
LuaAPI: Add SetAmmoDescriptionAppendix, SetAmmoTexts and update GetAmmoName
Wuzzy
parents:
917
diff
changeset
|
950 |
Allows you to overwrite the displayed name and tooltip descriptions of a given ammo type. |
87e1d0a11e99
LuaAPI: Add SetAmmoDescriptionAppendix, SetAmmoTexts and update GetAmmoName
Wuzzy
parents:
917
diff
changeset
|
951 |
|
919 | 952 |
* `ammoType`: The ammo type to set the text for |
953 |
* `name`: Name of the ammo type (e.g. “Grenade” for `amGrenade`), affects both name in ammo menu and in the “ticker” message on the screen top. |
|
954 |
* `caption`: The second line in the ammo menu (below the title). E.g. “Timed grenade” for `amGrenade`. |
|
955 |
* `description`: Description text in ammo menu, below the caption. |
|
918
87e1d0a11e99
LuaAPI: Add SetAmmoDescriptionAppendix, SetAmmoTexts and update GetAmmoName
Wuzzy
parents:
917
diff
changeset
|
956 |
|
87e1d0a11e99
LuaAPI: Add SetAmmoDescriptionAppendix, SetAmmoTexts and update GetAmmoName
Wuzzy
parents:
917
diff
changeset
|
957 |
`title`, `caption`, `description` can be `nil`, in which case they will be reverted to the engine default value. This function returns `nil`. |
87e1d0a11e99
LuaAPI: Add SetAmmoDescriptionAppendix, SetAmmoTexts and update GetAmmoName
Wuzzy
parents:
917
diff
changeset
|
958 |
|
87e1d0a11e99
LuaAPI: Add SetAmmoDescriptionAppendix, SetAmmoTexts and update GetAmmoName
Wuzzy
parents:
917
diff
changeset
|
959 |
Example: |
87e1d0a11e99
LuaAPI: Add SetAmmoDescriptionAppendix, SetAmmoTexts and update GetAmmoName
Wuzzy
parents:
917
diff
changeset
|
960 |
<code language="lua"> |
87e1d0a11e99
LuaAPI: Add SetAmmoDescriptionAppendix, SetAmmoTexts and update GetAmmoName
Wuzzy
parents:
917
diff
changeset
|
961 |
-- Overwrites bazooka name and description |
87e1d0a11e99
LuaAPI: Add SetAmmoDescriptionAppendix, SetAmmoTexts and update GetAmmoName
Wuzzy
parents:
917
diff
changeset
|
962 |
SetAmmoTexts(amBazooka, "Spoon Missile", "Crazy weapon", "This crazy weapon looks like a spoon and explodes on impact.|Attack: Hold to launch with more power")</code> |
87e1d0a11e99
LuaAPI: Add SetAmmoDescriptionAppendix, SetAmmoTexts and update GetAmmoName
Wuzzy
parents:
917
diff
changeset
|
963 |
|
87e1d0a11e99
LuaAPI: Add SetAmmoDescriptionAppendix, SetAmmoTexts and update GetAmmoName
Wuzzy
parents:
917
diff
changeset
|
964 |
==== <tt>!SetAmmoDescriptionAppendix(ammoType, descAppend)</tt> (0.9.23) ==== |
87e1d0a11e99
LuaAPI: Add SetAmmoDescriptionAppendix, SetAmmoTexts and update GetAmmoName
Wuzzy
parents:
917
diff
changeset
|
965 |
Will set a string `descAppend` to be appended below the “core” description (ammo tooltip) of the specified `ammoType`, without changing the ordinary description. |
87e1d0a11e99
LuaAPI: Add SetAmmoDescriptionAppendix, SetAmmoTexts and update GetAmmoName
Wuzzy
parents:
917
diff
changeset
|
966 |
Note that calling this function always sets the complete appended string, you can't use this function to append multiple texts in row. |
87e1d0a11e99
LuaAPI: Add SetAmmoDescriptionAppendix, SetAmmoTexts and update GetAmmoName
Wuzzy
parents:
917
diff
changeset
|
967 |
|
920 | 968 |
This function is recommended if you have tweaked an existing ammo type only a little and want to keep the original description intact as much as possible. |
918
87e1d0a11e99
LuaAPI: Add SetAmmoDescriptionAppendix, SetAmmoTexts and update GetAmmoName
Wuzzy
parents:
917
diff
changeset
|
969 |
|
87e1d0a11e99
LuaAPI: Add SetAmmoDescriptionAppendix, SetAmmoTexts and update GetAmmoName
Wuzzy
parents:
917
diff
changeset
|
970 |
Example: |
87e1d0a11e99
LuaAPI: Add SetAmmoDescriptionAppendix, SetAmmoTexts and update GetAmmoName
Wuzzy
parents:
917
diff
changeset
|
971 |
<code language="lua"> |
87e1d0a11e99
LuaAPI: Add SetAmmoDescriptionAppendix, SetAmmoTexts and update GetAmmoName
Wuzzy
parents:
917
diff
changeset
|
972 |
-- Appends a text to the ammo tooltip of the bazooka but leaves name and main description intact |
87e1d0a11e99
LuaAPI: Add SetAmmoDescriptionAppendix, SetAmmoTexts and update GetAmmoName
Wuzzy
parents:
917
diff
changeset
|
973 |
SetAmmoTexts(amBazooka, "This weapon deals double the damage than usually.")</code> |
87e1d0a11e99
LuaAPI: Add SetAmmoDescriptionAppendix, SetAmmoTexts and update GetAmmoName
Wuzzy
parents:
917
diff
changeset
|
974 |
|
912
ea13b02292c5
LuaAPI: Move non-gear related ammo functions to new section
Wuzzy
parents:
911
diff
changeset
|
975 |
==== <tt>!AddAmmo(gearUid, ammoType, ammoCount) (0.9.16) </tt> ==== |
ea13b02292c5
LuaAPI: Move non-gear related ammo functions to new section
Wuzzy
parents:
911
diff
changeset
|
976 |
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. |
ea13b02292c5
LuaAPI: Move non-gear related ammo functions to new section
Wuzzy
parents:
911
diff
changeset
|
977 |
|
ea13b02292c5
LuaAPI: Move non-gear related ammo functions to new section
Wuzzy
parents:
911
diff
changeset
|
978 |
*Note:* The effectiveness of this function may be limited due to problems with `gfPerHogAmmo` in Lua scripting. |
ea13b02292c5
LuaAPI: Move non-gear related ammo functions to new section
Wuzzy
parents:
911
diff
changeset
|
979 |
|
918
87e1d0a11e99
LuaAPI: Add SetAmmoDescriptionAppendix, SetAmmoTexts and update GetAmmoName
Wuzzy
parents:
917
diff
changeset
|
980 |
==== <tt>!GetAmmoName(ammoType [, ignoreOverwrite ])</tt> (0.9.23) ==== |
87e1d0a11e99
LuaAPI: Add SetAmmoDescriptionAppendix, SetAmmoTexts and update GetAmmoName
Wuzzy
parents:
917
diff
changeset
|
981 |
Returns the localized name for the specified `ammoType`, taking an ammo name overwritten by `SetAmmoTexts` into account. If `ignoreOverwrite` is `true`, this function will always return the original ammo name of the weapon and ignores names which may have been overwritten by `SetAmmoTexts`. |
912
ea13b02292c5
LuaAPI: Move non-gear related ammo functions to new section
Wuzzy
parents:
911
diff
changeset
|
982 |
|
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
983 |
=== Map === |
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
984 |
==== <tt>!MapHasBorder()</tt> ==== |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
985 |
Returns `true`/`false` if the map has a border or not. |
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
986 |
|
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
987 |
==== <tt>!TestRectForObstacle(x1, y1, x2, y2, landOnly) (0.9.16) </tt> ==== |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
988 |
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.). |
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
989 |
|
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
990 |
==== <tt>!PlaceGirder(x, y, state)</tt> (0.9.16) ==== |
869 | 991 |
Attempts to place girder with centre points `x`, `y` and a certain length and orientation, specified by `state`. The girder can only be placed in open space and must not collide with anything so this function may fail. It will return `true` on successful placement and `false` on failure. |
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
992 |
|
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
993 |
These are the accepted states: |
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
994 |
|
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
995 |
|| *`state`* || *Length* || *Orientation* || |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
996 |
|| 0 || short || horizontal || |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
997 |
|| 1 || short || decreasing right || |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
998 |
|| 2 || short || vertical || |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
999 |
|| 3 || short || increasing right || |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1000 |
|| 4 || long || horizontal || |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1001 |
|| 5 || long || decreasing right || |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1002 |
|| 6 || long || vertical || |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1003 |
|| 7 || long || increasing right || |
412 | 1004 |
|
688
d9fc58ac04f2
Update EraseSprite, PlaceSprite and Get/Set GearValues
nemo
parents:
685
diff
changeset
|
1005 |
==== <tt>!PlaceSprite(x, y, sprite, frameIdx, tint, behind, flipHoriz, flipVert, [, landFlag, ...])</tt> ==== |
869 | 1006 |
Places a [Sprites sprite] at the specified position (`x`, `y`) on the map, it behaves like terrain then. Unlike `PlaceGirder`, this function does not check for collisions, so the sprite can be placed anywhere within map boundaries. The function returns `true` if the placement was successful, `false` otherwise. `frameIdx` is the frame index starting by 0. `frameIdx` is used if the sprite consists of several sub-images. Only a subset of the sprites is currently supported by this function: |
539 | 1007 |
|
1008 |
* `sprAmGirder` |
|
1009 |
* `sprAmRubber` |
|
1010 |
* `sprAMSlot` |
|
1011 |
* `sprAMAmmos` |
|
1012 |
* `sprAMAmmosBW` |
|
1013 |
* `sprAMCorners` |
|
1014 |
* `sprHHTelepMask` |
|
1015 |
* `sprTurnsLeft` |
|
1016 |
* `sprSpeechCorner` |
|
1017 |
* `sprSpeechEdge` |
|
1018 |
* `sprSpeechTail` |
|
691
30323b8a8830
Add sprTargetBee to list of allowed PlaceSprite sprite types
Wuzzy
parents:
689
diff
changeset
|
1019 |
* `sprTargetBee` (since 0.9.23) |
539 | 1020 |
* `sprThoughtCorner` |
1021 |
* `sprThoughtEdge` |
|
1022 |
* `sprThoughtTail` |
|
1023 |
* `sprShoutCorner` |
|
1024 |
* `sprShoutEdge` |
|
1025 |
* `sprShoutTail` |
|
1026 |
* `sprBotlevels` |
|
1027 |
* `sprIceTexture` |
|
1028 |
* `sprCustom1` |
|
1029 |
* `sprCustom2` |
|
1030 |
||
692
111f39408390
Clean up markup for PlaceSprite and EraseSprite and clarify some stuff
Wuzzy
parents:
691
diff
changeset
|
1031 |
`tint` is for an RGBA colouring to apply, this works about the same as `Tint` in gears. `behind` indicates the sprite should not replace existing land. `flipHoriz` and `flipVert` are for mirroring the sprite vertically and horizontally before placing, respectively. |
688
d9fc58ac04f2
Update EraseSprite, PlaceSprite and Get/Set GearValues
nemo
parents:
685
diff
changeset
|
1032 |
The 9th and later arguments specify land flags (see the constants section) to be used for the newly created terrain. If omited, `lfNormal` is assumed. |
539 | 1033 |
|
1034 |
Example: |
|
1035 |
||
688
d9fc58ac04f2
Update EraseSprite, PlaceSprite and Get/Set GearValues
nemo
parents:
685
diff
changeset
|
1036 |
<code language="lua">PlaceSprite(2836, 634, sprAmGirder, 5) |
539 | 1037 |
-- Places the girder sprite as normal terrain at (2836, 634). The `frameIdx` 5 is for the long decreasing right girder.</code> |
688
d9fc58ac04f2
Update EraseSprite, PlaceSprite and Get/Set GearValues
nemo
parents:
685
diff
changeset
|
1038 |
<code language="lua">PlaceSprite(1411, 625, sprAmRubber, 1, nil, nil, nil, nil, lfBouncy) |
539 | 1039 |
-- Places the rubber band sprite as bouncy terrain at (2836, 634). The `frameIdx` 1 is for the decreasing right rubber band.</code> |
1040 |
||
688
d9fc58ac04f2
Update EraseSprite, PlaceSprite and Get/Set GearValues
nemo
parents:
685
diff
changeset
|
1041 |
==== <tt>!EraseSprite(x, y, sprite, frameIdx, eraseOnLFMatch, onlyEraseLF, flipHoriz, flipVert, [, landFlag, ...])</tt> ==== |
692
111f39408390
Clean up markup for PlaceSprite and EraseSprite and clarify some stuff
Wuzzy
parents:
691
diff
changeset
|
1042 |
Erases a [Sprites sprite] at the specified position (`x`, `y`) on the map. `frameIdx` is the frame index starting by 0. `sprite`, `frameIdx`, `flipHoriz` and `flipVert` behave the same as in `PlaceSprite`. For `sprite`, the same subset of sprites is permitted. |
688
d9fc58ac04f2
Update EraseSprite, PlaceSprite and Get/Set GearValues
nemo
parents:
685
diff
changeset
|
1043 |
|
692
111f39408390
Clean up markup for PlaceSprite and EraseSprite and clarify some stuff
Wuzzy
parents:
691
diff
changeset
|
1044 |
Set `eraseOnLFMatch` to `true` to erase all land for a pixel that matches any of the passed in land flags. This is useful if, for example, an `lfBouncy` sprite was placed “behind” land using `PlaceSprite` and you want to remove it without destroying the non-bouncy terrain. |
688
d9fc58ac04f2
Update EraseSprite, PlaceSprite and Get/Set GearValues
nemo
parents:
685
diff
changeset
|
1045 |
|
692
111f39408390
Clean up markup for PlaceSprite and EraseSprite and clarify some stuff
Wuzzy
parents:
691
diff
changeset
|
1046 |
Set `onlyEraseLF` to `true` to only remove specific land flags. If for example a sprite consists of `lfIndestructible` and `lfBouncy`, and you call `EraseSprite` with `onlyEraseLF` and `lfIndestructible` set, the sprite will remain bouncy but can be destroyed. You can use this to entirely remove all land flags from a sprite—at this point the sprite will be visual only, painted on the map but with no collision. |
688
d9fc58ac04f2
Update EraseSprite, PlaceSprite and Get/Set GearValues
nemo
parents:
685
diff
changeset
|
1047 |
|
692
111f39408390
Clean up markup for PlaceSprite and EraseSprite and clarify some stuff
Wuzzy
parents:
691
diff
changeset
|
1048 |
Examples: |
688
d9fc58ac04f2
Update EraseSprite, PlaceSprite and Get/Set GearValues
nemo
parents:
685
diff
changeset
|
1049 |
|
d9fc58ac04f2
Update EraseSprite, PlaceSprite and Get/Set GearValues
nemo
parents:
685
diff
changeset
|
1050 |
<code language="lua">EraseSprite(2836, 634, sprAmGirder, 5) |
692
111f39408390
Clean up markup for PlaceSprite and EraseSprite and clarify some stuff
Wuzzy
parents:
691
diff
changeset
|
1051 |
-- Removes the girder sprite at (2836, 634). The frameIdx 5 is for the long decreasing right girder.</code> |
688
d9fc58ac04f2
Update EraseSprite, PlaceSprite and Get/Set GearValues
nemo
parents:
685
diff
changeset
|
1052 |
<code language="lua">EraseSprite(1411, 625, sprAmRubber, 1, true, true, nil, nil, lfIndestructible) |
692
111f39408390
Clean up markup for PlaceSprite and EraseSprite and clarify some stuff
Wuzzy
parents:
691
diff
changeset
|
1053 |
-- Removes indestructibility from a rubber band sprite at (2836, 634). The frameIdx 1 is for the decreasing right rubber band.</code> |
688
d9fc58ac04f2
Update EraseSprite, PlaceSprite and Get/Set GearValues
nemo
parents:
685
diff
changeset
|
1054 |
|
412 | 1055 |
==== <tt>!AddPoint(x, y [, width [, erase] ])</tt> (0.9.21) ==== |
1056 |
This function is used to draw your own maps using Lua. The maps drawn with this are of type “hand-drawn”. |
|
1057 |
||
1058 |
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). |
|
1059 |
||
1060 |
This function must be called within `onGameInit`, where `MapGen` has been set to `mgDrawn`. You also should call `FlushPoints` when you are finished with drawing. |
|
1061 |
||
1062 |
==== <tt>!FlushPoints()</tt> (0.9.21) ==== |
|
1063 |
Makes sure that all the points/lines specified using `AddPoint` are actually applied to the map. This function must be called within `onGameInit`. |
|
1064 |
||
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1065 |
=== Current hedgehog === |
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1066 |
|
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1067 |
==== <tt>!GetCurAmmoType()</tt> (0.9.16) ==== |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1068 |
Returns the currently selected [AmmoTypes Ammo Type]. |
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1069 |
|
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1070 |
==== <tt>!SwitchHog(gearUid)</tt> (0.9.16) ==== |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1071 |
This function will switch to the hedgehog with the specifiedd `gearUid`. |
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1072 |
|
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1073 |
==== <tt>!SetInputMask(mask)</tt> ==== |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1074 |
Masks specified player input. This means that Hedgewars ignores certain player inputs, such as walking or jumping. |
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1075 |
|
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1076 |
Example: |
416
5aa55bbe4b73
Fixed faulty syntax highlighting in code block (was: “<code lang=…” instead of “<code language=…”)
almikes@aol.com
parents:
415
diff
changeset
|
1077 |
<code language="lua"> -- masks the long and high jump commands |
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1078 |
SetInputMask(band(0xFFFFFFFF, bnot(gmLJump + gmHJump))) |
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1079 |
-- clears input mask, allowing player to take actions |
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1080 |
SetInputMask(0xFFFFFFFF) |
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1081 |
</code> |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1082 |
*Note*: Using the input mask is an effective way to script uninterrupted cinematics, or create modes such as No Jumping. |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1083 |
|
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1084 |
See also [GearMessages]. |
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1085 |
|
405 | 1086 |
==== <tt>!GetInputMask()</tt> ==== |
1087 |
Returns the current input mask of the player. |
|
1088 |
||
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1089 |
=== Randomness === |
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1090 |
==== <tt>!GetRandom(number)</tt> ==== |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1091 |
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`. |
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1092 |
|
413
6d90d6994e95
Add DismissTeam, move AddTeam to new “Clans and teams” section.
almikes@aol.com
parents:
412
diff
changeset
|
1093 |
=== Clans and teams === |
6d90d6994e95
Add DismissTeam, move AddTeam to new “Clans and teams” section.
almikes@aol.com
parents:
412
diff
changeset
|
1094 |
==== <tt>!AddTeam(teamname, color, grave, fort, voicepack, flag)</tt> ==== |
6d90d6994e95
Add DismissTeam, move AddTeam to new “Clans and teams” section.
almikes@aol.com
parents:
412
diff
changeset
|
1095 |
|
476
dd4470df66ad
Restructure information about AddTeam, add info that Hedgewars does not support empty teams.
almikes@aol.com
parents:
461
diff
changeset
|
1096 |
Adds a new team. Note that this can only be done in `onGameInit`, not at a later time. |
dd4470df66ad
Restructure information about AddTeam, add info that Hedgewars does not support empty teams.
almikes@aol.com
parents:
461
diff
changeset
|
1097 |
You *must* add at least one hedgehog with `AddHog` after calling this. The engine does not support empty teams. |
dd4470df66ad
Restructure information about AddTeam, add info that Hedgewars does not support empty teams.
almikes@aol.com
parents:
461
diff
changeset
|
1098 |
|
dd4470df66ad
Restructure information about AddTeam, add info that Hedgewars does not support empty teams.
almikes@aol.com
parents:
461
diff
changeset
|
1099 |
Arguments: |
dd4470df66ad
Restructure information about AddTeam, add info that Hedgewars does not support empty teams.
almikes@aol.com
parents:
461
diff
changeset
|
1100 |
|
dd4470df66ad
Restructure information about AddTeam, add info that Hedgewars does not support empty teams.
almikes@aol.com
parents:
461
diff
changeset
|
1101 |
* `teamname`: The name of the team. |
583
0818d57c392f
Clarifications on differences of RGB vs RGBA.
almikes@aol.com
parents:
579
diff
changeset
|
1102 |
* `color`: The RGB color of the team as defined in [LuaAPI#Color] |
476
dd4470df66ad
Restructure information about AddTeam, add info that Hedgewars does not support empty teams.
almikes@aol.com
parents:
461
diff
changeset
|
1103 |
* `grave`: The name of the team’s grave (equals file name without the suffix) |
638 | 1104 |
* `fort`: The name of the team’s fort (equals file name without the suffix and without the letter “L” or “R” before that suffix) |
476
dd4470df66ad
Restructure information about AddTeam, add info that Hedgewars does not support empty teams.
almikes@aol.com
parents:
461
diff
changeset
|
1105 |
* `voicepack`: The name of the team’s voice pack (equals the directory name) |
638 | 1106 |
* `flag`: Optional argument for the name of the team’s flag (equals file name without the suffix). If set to `nil`, the flag “hedgewars” is used. |
476
dd4470df66ad
Restructure information about AddTeam, add info that Hedgewars does not support empty teams.
almikes@aol.com
parents:
461
diff
changeset
|
1107 |
|
625 | 1108 |
*Note*: This works only for singleplayer training missions for now and will desync multiplayer games. |
413
6d90d6994e95
Add DismissTeam, move AddTeam to new “Clans and teams” section.
almikes@aol.com
parents:
412
diff
changeset
|
1109 |
|
6d90d6994e95
Add DismissTeam, move AddTeam to new “Clans and teams” section.
almikes@aol.com
parents:
412
diff
changeset
|
1110 |
Example: |
6d90d6994e95
Add DismissTeam, move AddTeam to new “Clans and teams” section.
almikes@aol.com
parents:
412
diff
changeset
|
1111 |
|
476
dd4470df66ad
Restructure information about AddTeam, add info that Hedgewars does not support empty teams.
almikes@aol.com
parents:
461
diff
changeset
|
1112 |
<code language="lua">AddTeam("team 1", 0xDD0000, "Simple", "Tank", "Default", "hedgewars") |
dd4470df66ad
Restructure information about AddTeam, add info that Hedgewars does not support empty teams.
almikes@aol.com
parents:
461
diff
changeset
|
1113 |
--[[ Adds a new team with name “team 1”, red color (hexadecimal notation), the grave “Simple”, |
dd4470df66ad
Restructure information about AddTeam, add info that Hedgewars does not support empty teams.
almikes@aol.com
parents:
461
diff
changeset
|
1114 |
the fort “Tank” the voicepack “Default” and the flag “hedgewars”. ]]</code> |
413
6d90d6994e95
Add DismissTeam, move AddTeam to new “Clans and teams” section.
almikes@aol.com
parents:
412
diff
changeset
|
1115 |
|
6d90d6994e95
Add DismissTeam, move AddTeam to new “Clans and teams” section.
almikes@aol.com
parents:
412
diff
changeset
|
1116 |
==== <tt>!DismissTeam(teamname)</tt> ==== |
6d90d6994e95
Add DismissTeam, move AddTeam to new “Clans and teams” section.
almikes@aol.com
parents:
412
diff
changeset
|
1117 |
Removes the team with the given team name from the game. |
6d90d6994e95
Add DismissTeam, move AddTeam to new “Clans and teams” section.
almikes@aol.com
parents:
412
diff
changeset
|
1118 |
|
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1119 |
==== <tt>!GetClanColor(clan)</tt> ==== |
858
2a562faa73fb
LuaAPI: GetClanColor, SetClanColor: They use RGBA instead of RGB
Wuzzy
parents:
826
diff
changeset
|
1120 |
Returns the RGBA color of the chosen clan by its number. The color data type is described in [LuaAPI#Color]. |
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1121 |
|
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1122 |
==== <tt>!SetClanColor(clan, color)</tt> ==== |
858
2a562faa73fb
LuaAPI: GetClanColor, SetClanColor: They use RGBA instead of RGB
Wuzzy
parents:
826
diff
changeset
|
1123 |
Sets the RGBA color of the chosen clan by its number. The color data type is described in [LuaAPI#Color]. |
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1124 |
|
577 | 1125 |
=== Campaign management === |
1126 |
==== <tt>!SaveCampaignVar(varname, value)</tt> ==== |
|
1127 |
Stores the value `value` (a string) into the campaign variable `varname` (also a string). Campaign variables allow you to save progress of a team in a certain campaign. Campaign variables are saved on a per-team per-campaign basis. They are written into the team file (see [ConfigurationFiles#TeamName.hwt]). |
|
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1128 |
|
579
9895045e9963
Updated SaveCampaignVar / GetCampaignVar links
almikes@aol.com
parents:
577
diff
changeset
|
1129 |
There are some special campaign variables which are used by Hedgewars to determine which missions to display in the campaign menu. This is described [ConfigurationFiles#%5BCampaign%20%3CCAMPAIGN_NAME%3E%5D here]. |
9895045e9963
Updated SaveCampaignVar / GetCampaignVar links
almikes@aol.com
parents:
577
diff
changeset
|
1130 |
|
577 | 1131 |
==== <tt>!GetCampaignVar(varname)</tt> ==== |
579
9895045e9963
Updated SaveCampaignVar / GetCampaignVar links
almikes@aol.com
parents:
577
diff
changeset
|
1132 |
Returns the value of the campaign variable `varname` as a string. See also `SaveCampaignVar`. |
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1133 |
|
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1134 |
== Functions affecting the GUI == |
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1135 |
|
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1136 |
=== <tt>!AddCaption(text)</tt> === |
561 | 1137 |
Display an event text in the upper part of the screen. The text will be white and the caption group will be `capgrpMessage`. |
1138 |
||
583
0818d57c392f
Clarifications on differences of RGB vs RGBA.
almikes@aol.com
parents:
579
diff
changeset
|
1139 |
Example: |
0818d57c392f
Clarifications on differences of RGB vs RGBA.
almikes@aol.com
parents:
579
diff
changeset
|
1140 |
<code language="lua"> |
0818d57c392f
Clarifications on differences of RGB vs RGBA.
almikes@aol.com
parents:
579
diff
changeset
|
1141 |
AddCaption("Hello, world!") |
0818d57c392f
Clarifications on differences of RGB vs RGBA.
almikes@aol.com
parents:
579
diff
changeset
|
1142 |
</code> |
0818d57c392f
Clarifications on differences of RGB vs RGBA.
almikes@aol.com
parents:
579
diff
changeset
|
1143 |
|
561 | 1144 |
=== <tt>!AddCaption(text, color, captiongroup)</tt> === |
583
0818d57c392f
Clarifications on differences of RGB vs RGBA.
almikes@aol.com
parents:
579
diff
changeset
|
1145 |
Display an event text in the upper part of the screen with the specified RGBA [LuaAPI#Color color] and caption group. Although an RBGA color is used, Hedgewars does not actually support transparent or semi-transparent captions, so the fourth byte is ignored. We recommend you to always specify a full opacity (`FF` in hexadecimal) for the caption. |
561 | 1146 |
|
1147 |
|| *`captiongroup`* || *Meaning* || |
|
1148 |
|| `capgrpGameState` || Used for important global game events, like Sudden Death || |
|
1149 |
|| `capgrpAmmoinfo` || Used for new weapon crates and some other events || |
|
1150 |
|| `capgrpVolume` || Used when adjusting volume || |
|
1151 |
|| `capgrpMessage` || Generic message || |
|
1152 |
|| `capgrpMessage2` || Generic message || |
|
1153 |
|| `capgrpAmmostate` || Used to show information about weapon state, i.e. bounce level, timer, remaining shots, etc. || |
|
1154 |
||
583
0818d57c392f
Clarifications on differences of RGB vs RGBA.
almikes@aol.com
parents:
579
diff
changeset
|
1155 |
Example: |
0818d57c392f
Clarifications on differences of RGB vs RGBA.
almikes@aol.com
parents:
579
diff
changeset
|
1156 |
<code language="lua"> |
0818d57c392f
Clarifications on differences of RGB vs RGBA.
almikes@aol.com
parents:
579
diff
changeset
|
1157 |
AddCaption("Melon bomb rain in 2 rounds!", 0xFF0000FF, capgrpGameState) |
0818d57c392f
Clarifications on differences of RGB vs RGBA.
almikes@aol.com
parents:
579
diff
changeset
|
1158 |
-- Green example message. |
0818d57c392f
Clarifications on differences of RGB vs RGBA.
almikes@aol.com
parents:
579
diff
changeset
|
1159 |
</code> |
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1160 |
|
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
1161 |
=== <tt>!ShowMission(caption, subcaption, text, icon, time)</tt> === |
894 | 1162 |
This function will open the mission panel and set the texts in it. |
1163 |
||
1164 |
Use to tell the player what he/she is supposed to do. If you use this function, a mission panel is shown for the amount of time specified in `time` (in milliseconds). If `time` is set to 0, it will be displayed for a default amount of time. |
|
1165 |
This function replaces the *entire* text of the mission panel. Compare this to the global `Goals` variable, which *adds* to the default text without replacing it. |
|
645 | 1166 |
|
1167 |
`caption` is the text displayed in the first line, `subcaption` is displayed in the second line and `text` is the text displayed in the third and following lines. |
|
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
1168 |
|
647 | 1169 |
`text` uses some special characters for formatting: `|` is used for a line break, and everything written before and including a `:` in a line is written in a lighter color. |
645 | 1170 |
|
1171 |
As of version 0.9.22, `icon` accepts the following values: |
|
79 | 1172 |
|
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1173 |
|| *`icon`* || *What is shown* || |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1174 |
|| _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. || |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1175 |
|| `0` || Golden crown || |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1176 |
|| `1` || Target || |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1177 |
|| `2` || Exclamation mark || |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1178 |
|| `3` || Question mark || |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1179 |
|| `4` || Golden star || |
636 | 1180 |
|| `5` || Utility crate || |
1181 |
|| `6` || Health crate || |
|
1182 |
|| `7` || Ammo crate || |
|
1183 |
|| `8` || Barrel || |
|
28
026591d95ac6
Edited wiki page LuaAPI through web user interface.
henrik.rostedt
parents:
24
diff
changeset
|
1184 |
|
645 | 1185 |
Example: |
1186 |
<code language="lua"> |
|
1187 |
ShowMission(loc("Nobody Laugh"), loc("User Challenge"), loc("Eliminate the enemy before the time runs out"), 0, 0) |
|
1188 |
</code> |
|
1189 |
||
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
1190 |
=== <tt>!HideMission()</tt> === |
894 | 1191 |
Hides the mission panel if it is currently displayed, otherwise, this function does nothing. |
28
026591d95ac6
Edited wiki page LuaAPI through web user interface.
henrik.rostedt
parents:
24
diff
changeset
|
1192 |
|
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1193 |
=== <tt>!SetZoom(zoomLevel)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1194 |
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 |
28
026591d95ac6
Edited wiki page LuaAPI through web user interface.
henrik.rostedt
parents:
24
diff
changeset
|
1195 |
|
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1196 |
=== <tt>!GetZoom()</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1197 |
Returns the current zoom level. |
147
379d7931ffc7
Edited wiki page LuaAPI through web user interface.
RedGrinner@gmail.com
parents:
146
diff
changeset
|
1198 |
|
775 | 1199 |
=== `SetCinematicMode(enable)` (0.9.23) === |
1200 |
Turns on or off cinematic mode. Cinematic mode can be used for cutscenes etc. |
|
1201 |
If `enable` is set to `true`, cinematic mode is enabled, |
|
1202 |
if it is `false`, cinematic mode is disabled. |
|
1203 |
||
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1204 |
== Sound functions == |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
1205 |
=== <tt>!PlaySound(soundId)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1206 |
Plays the specified sound. Possible values for `soundId` are listed on the [Sounds] page. |
28
026591d95ac6
Edited wiki page LuaAPI through web user interface.
henrik.rostedt
parents:
24
diff
changeset
|
1207 |
|
181 | 1208 |
=== <tt>!PlaySound(soundId, gearUid)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1209 |
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. |
70
ff7d4c176303
Edited wiki page LuaAPI through web user interface.
henrik.rostedt
parents:
69
diff
changeset
|
1210 |
|
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1211 |
Possible values for `soundId` are listed on the [Sounds] page. See also [Taunts]. |
77 | 1212 |
|
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1213 |
== File system functions == |
410 | 1214 |
=== <tt>!HedgewarsScriptLoad(scriptPath)</tt> === |
407 | 1215 |
Loads a script (i.e. a [LuaLibraries library]) from the specified `scriptPath`. The root directory is here Hedgewars’ data directory. |
1216 |
||
1217 |
Example: |
|
416
5aa55bbe4b73
Fixed faulty syntax highlighting in code block (was: “<code lang=…” instead of “<code language=…”)
almikes@aol.com
parents:
415
diff
changeset
|
1218 |
<code language="lua"> |
407 | 1219 |
HedgewarsScriptLoad("/Scripts/Locale.lua") -- loads locale library |
416
5aa55bbe4b73
Fixed faulty syntax highlighting in code block (was: “<code lang=…” instead of “<code language=…”)
almikes@aol.com
parents:
415
diff
changeset
|
1220 |
</code> |
407 | 1221 |
|
181 | 1222 |
=== <tt>!GetDataPath()</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1223 |
Returns the path to the data directory, used when adding libraries. |
68
fd230628d72c
Edited wiki page LuaAPI through web user interface.
henrik.rostedt
parents:
67
diff
changeset
|
1224 |
|
181 | 1225 |
=== <tt>!GetUserDataPath()</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1226 |
Returns the path to the user data directory, used when adding libraries. |
180
96e6b405bcf6
Edited wiki page LuaAPI through web user interface.
azizi.054@gmail.com
parents:
179
diff
changeset
|
1227 |
|
96e6b405bcf6
Edited wiki page LuaAPI through web user interface.
azizi.054@gmail.com
parents:
179
diff
changeset
|
1228 |
|
73
c6623486d077
Edited wiki page LuaAPI through web user interface.
henrik.rostedt
parents:
72
diff
changeset
|
1229 |
|
89
caf6544f767a
Edited wiki page LuaAPI through web user interface.
henrik.rostedt@gmail.com
parents:
87
diff
changeset
|
1230 |
|
caf6544f767a
Edited wiki page LuaAPI through web user interface.
henrik.rostedt@gmail.com
parents:
87
diff
changeset
|
1231 |
|
404
37d44392ad2b
Reorganize the section “other functions” into several logical subunits.
almikes@aol.com
parents:
403
diff
changeset
|
1232 |
== Stats functions == |
360 | 1233 |
=== <tt>!SendStat(TStatInfoType, statMessage[, teamName])</tt> (0.9.20) === |
328
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1234 |
|
893 | 1235 |
This function allows to change the details of the stats screen seen after the end of a game. |
418
a7d34a3e5786
Make documentation for SendStat much more readable: Add a table (still not perfect), added some basic parameter descriptions.
almikes@aol.com
parents:
417
diff
changeset
|
1236 |
|
a7d34a3e5786
Make documentation for SendStat much more readable: Add a table (still not perfect), added some basic parameter descriptions.
almikes@aol.com
parents:
417
diff
changeset
|
1237 |
`TStatInfoType` is the piece of information you want to manipulate. The result of this functions varies greatly for different `TStatInfoType`s. The parameter `statMessage` is mandatory and is a string used for the statistics, its meaning depends on the `TStatInfoType`. The parameter `teamName` contains the name of a team which is relevant to the chosen stat. This parameter is not always required, this also depends on `TStatInfoType`. |
a7d34a3e5786
Make documentation for SendStat much more readable: Add a table (still not perfect), added some basic parameter descriptions.
almikes@aol.com
parents:
417
diff
changeset
|
1238 |
|
a7d34a3e5786
Make documentation for SendStat much more readable: Add a table (still not perfect), added some basic parameter descriptions.
almikes@aol.com
parents:
417
diff
changeset
|
1239 |
This tables explains the different behaviours of this function for different values of `TStatInfoType`: |
a7d34a3e5786
Make documentation for SendStat much more readable: Add a table (still not perfect), added some basic parameter descriptions.
almikes@aol.com
parents:
417
diff
changeset
|
1240 |
|
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1241 |
|| *`TStatInfoType`* || *Meaning of `statMessage`* || *Team parameter used?* || |
418
a7d34a3e5786
Make documentation for SendStat much more readable: Add a table (still not perfect), added some basic parameter descriptions.
almikes@aol.com
parents:
417
diff
changeset
|
1242 |
|| `siGraphTitle` || Title of the graph. If you use this, the health icon changes into a star. || No || |
a7d34a3e5786
Make documentation for SendStat much more readable: Add a table (still not perfect), added some basic parameter descriptions.
almikes@aol.com
parents:
417
diff
changeset
|
1243 |
|| `siGameResult` || Title of the stats screen, used to show the result of the game, i.e. who won the game || No || |
a7d34a3e5786
Make documentation for SendStat much more readable: Add a table (still not perfect), added some basic parameter descriptions.
almikes@aol.com
parents:
417
diff
changeset
|
1244 |
|| `siCustomAchievement` || A freeform text for a single “bullet point” in the “bullet point” list in the details section. For each time you call `SendStat` with this `TStatInfoType`, a new “bullet point” gets added to the list. || No || |
685 | 1245 |
|| `siPointType` || Replaces the word “kills” in the ranking list. You have to call this each time before you report the score or kills of a team with `siPlayerKills`. Sadly, grammatical number is currently not respected at all here. || No || |
418
a7d34a3e5786
Make documentation for SendStat much more readable: Add a table (still not perfect), added some basic parameter descriptions.
almikes@aol.com
parents:
417
diff
changeset
|
1246 |
|| `siPlayerKills` || The number of kills for the specified team (converted to a string), as shown in the ranking list. Unless the word “kills” has been replaced by `siPointType`, then that word is used instead. Only integers (converted to string) are possible. || Yes || |
a7d34a3e5786
Make documentation for SendStat much more readable: Add a table (still not perfect), added some basic parameter descriptions.
almikes@aol.com
parents:
417
diff
changeset
|
1247 |
|| `siClanHealth` || Value of a data point (converted to a string). This sets a single data point on the graph for the specified team. Subsequent calls will draw the next point along the horizontal axis; the frontend will then simply connect the dots in the final graph. The graphs are treated independently for each other. Currently the graph only can display positive values. You also should have called `SendHealthStatsOff` if you use this to prevent the default health graphs to be drawn. || Yes || |
a7d34a3e5786
Make documentation for SendStat much more readable: Add a table (still not perfect), added some basic parameter descriptions.
almikes@aol.com
parents:
417
diff
changeset
|
1248 |
|| `siMaxStepKills` || Most hedgehogs killed in a round. `statText` must be in format “`<kills> <name of killer hedgehog> (<team name of killer>)`”. || No || |
a7d34a3e5786
Make documentation for SendStat much more readable: Add a table (still not perfect), added some basic parameter descriptions.
almikes@aol.com
parents:
417
diff
changeset
|
1249 |
|| `siMaxTeamDamage` || Hedgehog with most damage inflicted to his own team. `statText` must be in the format “`<damage> <hedgehog name>`”. || No || |
a7d34a3e5786
Make documentation for SendStat much more readable: Add a table (still not perfect), added some basic parameter descriptions.
almikes@aol.com
parents:
417
diff
changeset
|
1250 |
|| `siKilledHHs` || Total number of killed hedgehogs (converted to string). || No || |
a7d34a3e5786
Make documentation for SendStat much more readable: Add a table (still not perfect), added some basic parameter descriptions.
almikes@aol.com
parents:
417
diff
changeset
|
1251 |
|| `siTeamStats` || Increases the wins of local teams in case the given number is greater than 0. || No || |
a7d34a3e5786
Make documentation for SendStat much more readable: Add a table (still not perfect), added some basic parameter descriptions.
almikes@aol.com
parents:
417
diff
changeset
|
1252 |
|| `siMaxStepDamage` || Best shot award (most damage in one turn). `statText` must be in format “`<damage> <hedgehog name> (<team name>)`”. || No || |
a7d34a3e5786
Make documentation for SendStat much more readable: Add a table (still not perfect), added some basic parameter descriptions.
almikes@aol.com
parents:
417
diff
changeset
|
1253 |
|| `siMaxTurnSkips` || Team with most skips. `statText` must be of format “`<number> <teamName>`”. || No || |
a7d34a3e5786
Make documentation for SendStat much more readable: Add a table (still not perfect), added some basic parameter descriptions.
almikes@aol.com
parents:
417
diff
changeset
|
1254 |
|
328
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1255 |
|
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1256 |
<b>Examples:</b> |
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1257 |
|
416
5aa55bbe4b73
Fixed faulty syntax highlighting in code block (was: “<code lang=…” instead of “<code language=…”)
almikes@aol.com
parents:
415
diff
changeset
|
1258 |
<code language="lua"> |
328
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1259 |
-- will automatically change the health icon to a star |
347
edc8d322d02d
Edited wiki page LuaAPI, fixing SendStat
pntanasis@gmail.com
parents:
346
diff
changeset
|
1260 |
SendStat(siGraphTitle,'Custom Graph Title') |
edc8d322d02d
Edited wiki page LuaAPI, fixing SendStat
pntanasis@gmail.com
parents:
346
diff
changeset
|
1261 |
SendStat(siGameResult,'Winner is Team A!') |
418
a7d34a3e5786
Make documentation for SendStat much more readable: Add a table (still not perfect), added some basic parameter descriptions.
almikes@aol.com
parents:
417
diff
changeset
|
1262 |
SendStat(siCustomAchievement,'This is a custom message posted in the Details section!') |
328
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1263 |
-- Changes the word kill to Point, call it just before sending kills/score for each hog |
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1264 |
-- in case you want to change the word i.e. print Point or Points |
347
edc8d322d02d
Edited wiki page LuaAPI, fixing SendStat
pntanasis@gmail.com
parents:
346
diff
changeset
|
1265 |
SendStat(siPointType,'Point') |
328
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1266 |
-- if above function call was not used it will print 3 kills for teamName in Ranking section. |
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1267 |
-- if it was used it will print 3 Point for teamName in Ranking section. |
347
edc8d322d02d
Edited wiki page LuaAPI, fixing SendStat
pntanasis@gmail.com
parents:
346
diff
changeset
|
1268 |
SendStat(siPlayerKills,'3',teamName) |
328
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1269 |
-- call siClanHealth to send the "value" of a clan that will be used for the graph creation |
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1270 |
-- a good idea is to call it always for every hog by using the runOnGears(function) |
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1271 |
-- in normal mode "value" represents clan health |
347
edc8d322d02d
Edited wiki page LuaAPI, fixing SendStat
pntanasis@gmail.com
parents:
346
diff
changeset
|
1272 |
SendStat(siClanHealth, "100",teamName) |
328
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1273 |
-- most hedgehogs killed in a round (hedgeHogName is who killed them) |
347
edc8d322d02d
Edited wiki page LuaAPI, fixing SendStat
pntanasis@gmail.com
parents:
346
diff
changeset
|
1274 |
SendStat(siMaxStepKills, "1 hedgeHogName (teamName)") |
328
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1275 |
-- hog with most damage inflicted to his own team |
347
edc8d322d02d
Edited wiki page LuaAPI, fixing SendStat
pntanasis@gmail.com
parents:
346
diff
changeset
|
1276 |
SendStat(siMaxTeamDamage, "100 hedgeHogName") |
328
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1277 |
-- total number of killed hedgehogs |
347
edc8d322d02d
Edited wiki page LuaAPI, fixing SendStat
pntanasis@gmail.com
parents:
346
diff
changeset
|
1278 |
SendStat(siKilledHHs, "1") |
328
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1279 |
-- increases the wins of local teams in case the given number is greater than 0 |
347
edc8d322d02d
Edited wiki page LuaAPI, fixing SendStat
pntanasis@gmail.com
parents:
346
diff
changeset
|
1280 |
SendStat(siTeamStats, "teamName:0:") |
328
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1281 |
-- best shot award |
347
edc8d322d02d
Edited wiki page LuaAPI, fixing SendStat
pntanasis@gmail.com
parents:
346
diff
changeset
|
1282 |
SendStat(siMaxStepDamage, "30 hedgeHogName (teamName)") |
328
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1283 |
-- team with most kills of own hedgehogs |
347
edc8d322d02d
Edited wiki page LuaAPI, fixing SendStat
pntanasis@gmail.com
parents:
346
diff
changeset
|
1284 |
SendStat(siMaxStepDamage, "2 teamName") |
328
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1285 |
-- team with most skips |
347
edc8d322d02d
Edited wiki page LuaAPI, fixing SendStat
pntanasis@gmail.com
parents:
346
diff
changeset
|
1286 |
SendStat(siMaxTurnSkips, "3 teamName") |
328
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1287 |
</code> |
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1288 |
|
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1289 |
<b>Important:</b> |
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1290 |
|
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1291 |
* As the game engine send stats to the frontend at the end of the game one should send her stats when the game is going to finish and right before the call of `EndGame()`. (Note: Stats are sent from the engine in `CheckForWin`. If conditions are met (win or draw) then `SendStats(uStats)` is called.) |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1292 |
* Calling just `EndGame()` won’t produce any stats. |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1293 |
* If one would like to produce a custom graph see also `SendHealthStatsOff()`. |
328
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1294 |
|
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1295 |
=== <tt>!SendHealthStatsOff()</tt> (0.9.20) === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1296 |
Prevents the engine of sending health stats to the frontend. |
328
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1297 |
|
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1298 |
If any health stats haven’t been sent before this will cause the health graph to the stats page to be hidden. Use this function in the Lua scripts to produce custom graphs by calling it inside `onGameStart()` and using the `SendStat()`. |
328
fdc71ac8db83
Updated wiki page LuaAPI with the SendStat() and SendHealthStatsOff() functions.
pntanasis@gmail.com
parents:
313
diff
changeset
|
1299 |
|
382 | 1300 |
== Math Functions == |
1301 |
||
383
6679b75048c0
I really have to get used to using preview on google code wiki...
sheepyluva@gmail.com
parents:
382
diff
changeset
|
1302 |
=== <tt>div(dividend, divisor)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1303 |
Performs an integer division and returns the result. |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1304 |
The result is an integer and has the value of the first parameter (an integer) divided by the second parameter (another integer), rounded towards zero. |
382 | 1305 |
|
401
aee281298267
Documented the following functions: band, bnot, bor.
almikes@aol.com
parents:
400
diff
changeset
|
1306 |
=== <tt>band(value1, value2)</tt> === |
aee281298267
Documented the following functions: band, bnot, bor.
almikes@aol.com
parents:
400
diff
changeset
|
1307 |
Returns the bitwise logical AND of `value1` and `value2`. |
aee281298267
Documented the following functions: band, bnot, bor.
almikes@aol.com
parents:
400
diff
changeset
|
1308 |
|
aee281298267
Documented the following functions: band, bnot, bor.
almikes@aol.com
parents:
400
diff
changeset
|
1309 |
=== <tt>bor(value1, value2)</tt> === |
aee281298267
Documented the following functions: band, bnot, bor.
almikes@aol.com
parents:
400
diff
changeset
|
1310 |
Returns the bitwise logical OR of `value1` and `value2`. |
aee281298267
Documented the following functions: band, bnot, bor.
almikes@aol.com
parents:
400
diff
changeset
|
1311 |
|
aee281298267
Documented the following functions: band, bnot, bor.
almikes@aol.com
parents:
400
diff
changeset
|
1312 |
=== <tt>bnot(value)</tt> === |
aee281298267
Documented the following functions: band, bnot, bor.
almikes@aol.com
parents:
400
diff
changeset
|
1313 |
Returns the bitwise logical NOT of `value`. |
aee281298267
Documented the following functions: band, bnot, bor.
almikes@aol.com
parents:
400
diff
changeset
|
1314 |
|
aee281298267
Documented the following functions: band, bnot, bor.
almikes@aol.com
parents:
400
diff
changeset
|
1315 |
|
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
1316 |
== Debugging Functions == |
820 | 1317 |
=== `WriteLnToConsole(string)` === |
1318 |
Writes `string` to `Logs/game0.log`, found in the user data directory. |
|
1319 |
||
1320 |
=== `DumpPoint(x, y)` (0.9.23) === |
|
821 | 1321 |
Converts the whole numbers `x` and `y` to strings and writes them to `Logs/game0.log`, one line each. |
12
74ead59b6c64
LuaAPI page + GearTypes,AmmoTypes,Sounds,States listing pages
Tobias Neumann <mail@tobias-neumann.eu>
parents:
diff
changeset
|
1322 |
|
394
b2742eb19396
Edited wiki page LuaAPI through web abuser interface.
sheepyluva@gmail.com
parents:
384
diff
changeset
|
1323 |
=== <tt>!ParseCommand(string)</tt> === |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1324 |
Makes the game client parse the specified custom command. |
394
b2742eb19396
Edited wiki page LuaAPI through web abuser interface.
sheepyluva@gmail.com
parents:
384
diff
changeset
|
1325 |
|
b2742eb19396
Edited wiki page LuaAPI through web abuser interface.
sheepyluva@gmail.com
parents:
384
diff
changeset
|
1326 |
*Note*: Please be aware that the *engine protocol can (and will) change* between releases. |
b2742eb19396
Edited wiki page LuaAPI through web abuser interface.
sheepyluva@gmail.com
parents:
384
diff
changeset
|
1327 |
|
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1328 |
If you use `ParseCommand` to overcome a shortcoming in our Lua API (e.g. a missing function), please make sure to [https://code.google.com/p/hedgewars/issues/entry report the issue]. |
394
b2742eb19396
Edited wiki page LuaAPI through web abuser interface.
sheepyluva@gmail.com
parents:
384
diff
changeset
|
1329 |
|
b2742eb19396
Edited wiki page LuaAPI through web abuser interface.
sheepyluva@gmail.com
parents:
384
diff
changeset
|
1330 |
With your report we can fix the shortcoming in future releases. |
515
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1331 |
This will allow scripts to use the previously missing feature in a way that won’t break! |
8e9d86efc07b
Copy-editing of the entire page. Also a few updates to some fairly out-dated information while I’m at it.
almikes@aol.com
parents:
505
diff
changeset
|
1332 |
|
394
b2742eb19396
Edited wiki page LuaAPI through web abuser interface.
sheepyluva@gmail.com
parents:
384
diff
changeset
|
1333 |