Reorganize the section “other functions” into several logical subunits.
authoralmikes@aol.com
Wed, 03 Dec 2014 02:39:27 +0000
changeset 404 37d44392ad2b
parent 403 7642806ce7b9
child 405 4e1c166740b0
Reorganize the section “other functions” into several logical subunits.
LuaAPI.wiki
--- a/LuaAPI.wiki	Wed Dec 03 02:01:19 2014 +0000
+++ b/LuaAPI.wiki	Wed Dec 03 02:39:27 2014 +0000
@@ -1,6 +1,6 @@
 #summary API for writing Lua scripts in Hedgewars.
 #labels Featured
-<wiki:toc max_depth="3" />
+<wiki:toc max_depth="4" />
 
 == Introduction ==
 
@@ -674,33 +674,133 @@
 
 <blockquote>Set pos of specified gear to specified value.</blockquote>
 
-== Other Functions ==
+
+== Gameplay functions ==
 
-=== <tt>!ClearGameFlags()</tt> ===
+=== `GameFlags` ===
+
+==== <tt>!ClearGameFlags()</tt> ====
 
 <blockquote>Disables *all* !GameFlags
 </blockquote>
 
-=== <tt>!DisableGameFlags(gameflag, ...)</tt> ===
+==== <tt>!DisableGameFlags(gameflag, ...)</tt> ====
 
 <blockquote>Disables the listed !GameFlags, without changing the status of other !GameFlags
 </blockquote>
 
-=== <tt>!EnableGameFlags(gameflag, ...)</tt> ===
+==== <tt>!EnableGameFlags(gameflag, ...)</tt> ====
 
 <blockquote>Enables the listed !GameFlags, without changing the status of other !GameFlags
 </blockquote>
 
-=== <tt>!GetGameFlag(gameflag)</tt> ===
+==== <tt>!GetGameFlag(gameflag)</tt> ====
 
 <blockquote>Returns true if the specified gameflag is enabled, otherwise false
 </blockquote>
 
-=== <tt>!EndGame()</tt> ===
+=== Environment ===
+
+==== <tt>!SetGravity(percent)</tt> ====
+
+<blockquote>Changes the current gravity of the game in percent (relative to default, integer value).
+Setting it to 100 will set gravity to default gravity of hedgewars, 200 will double it, etc.
+</blockquote>
+
+==== <tt>!GetGravity()</tt> ====
+
+<blockquote>Returns the current gravity in percent
+</blockquote>
+
+==== <tt>!SetWaterLine(waterline)</tt> ====
+
+<blockquote>Sets the water level to the specified y-coordinate
+</blockquote>
+
+==== <tt>!SetWind(windSpeed)</tt> ====
+
+<blockquote>Sets the current wind in the range of -100 to 100. Use together with gfDisableWind for full control.
+</blockquote>
+
+==== <tt>!EndGame()</tt> ====
 
 <blockquote>Makes the game end.
 </blockquote>
 
+=== Map ===
+==== <tt>!MapHasBorder()</tt> ====
+
+<blockquote>Returns true/false if the map has a border or not.
+</blockquote>
+
+==== <tt>!TestRectForObstacle(x1, y1, x2, y2, landOnly) (0.9.16) </tt> ====
+<blockquote>Checks the rectangle between the given coordinates for possible collisions. set landOnly to true if you don't want to check for collisions with gears (hedgehogs, etc.)
+</blockquote>
+
+==== <tt>!PlaceGirder(x, y, state)</tt> (0.9.16) ====
+
+<blockquote>Places a girder with centre points x, y and the chosen state.
+These are the accepted states:
+  * 0: short, horizontal
+  * 1: short, decreasing right
+  * 2: short, vertical
+  * 3: short, increasing right
+  * 4: long, horizontal
+  * 5: long, decreasing right
+  * 6: long, vertical
+  * 7: long, increasing right
+</blockquote>
+
+=== Current hedgehog ===
+
+==== <tt>!GetCurAmmoType()</tt> (0.9.16) ====
+
+<blockquote>Returns the currently selected [AmmoTypes Ammo Type].
+</blockquote>
+
+==== <tt>!SwitchHog(gearUid)</tt> (0.9.16) ====
+
+<blockquote>This function will switch to the hedgehog with the specified Uid.</blockquote>
+
+==== <tt>!SetInputMask(mask)</tt> ====
+
+<blockquote>Masks specified player input.
+</blockquote>
+Example: 
+<code lang="lua">    -- masks the long and high jump commands
+SetInputMask(band(0xFFFFFFFF, bnot(gmLJump + gmHJump))) 
+    -- clears input mask, allowing player to take actions
+    SetInputMask(0xFFFFFFFF) 
+		</code>
+Note: Using the input mask is an effective way to script uninterrupted cinematics, or create modes such as No Jumping. 
+
+
+=== Randomness ===
+==== <tt>!GetRandom(number)</tt> ====
+
+<blockquote>Returns a randomly generated number in the range of 0 to number - 1.  This random number uses the game seed, so is synchronised, and thus safe for multiplayer and saved games.  Use GetRandom for anything that could impact the engine state.  For example, a visual gear can use the Lua random, but adding a regular gear should use GetRandom.
+</blockquote>
+
+=== Clans ===
+==== <tt>!GetClanColor(clan)</tt> ====
+
+<blockquote>Returns the colour of the chosen clan by its number.
+</blockquote>
+==== <tt>!SetClanColor(clan, color)</tt> ====
+
+<blockquote>Sets the colour of the chosen clan by its number.
+</blockquote>
+
+
+
+
+== Functions affecting the GUI ==
+
+=== <tt>!AddCaption(text)</tt> ===
+
+<blockquote>Display event text in the upper part of the screen.
+</blockquote>
+
 === <tt>!ShowMission(caption, subcaption, text, icon, time)</tt> ===
 
 <blockquote>Use to tell the player what he is supposed to do.
@@ -719,21 +819,17 @@
 <blockquote>Hides the mission. This function is currently bugged somehow and will completely ruin your life, and your script should you happen to use it.
 </blockquote>
 
-=== <tt>!AddCaption(text)</tt> ===
+=== <tt>!SetZoom(zoomLevel)</tt> ===
 
-<blockquote>Display event text in the upper part of the screen.
+<blockquote>Sets the zoom level. The value for maximum zoom is currently 1.0 and for minimum 3.0 The default zoom level is 2.0
 </blockquote>
 
-=== <tt>!MapHasBorder()</tt> ===
+=== <tt>!GetZoom()</tt> ===
 
-<blockquote>Returns true/false if the map has a border or not.
+<blockquote>Returns the current zoom level
 </blockquote>
 
-=== <tt>!TestRectForObstacle(x1, y1, x2, y2, landOnly) (0.9.16) </tt> ===
-
-<blockquote>Checks the rectangle between the given coordinates for possible collisions. set landOnly to true if you don't want to check for collisions with gears (hedgehogs, etc.)
-</blockquote>
-
+== Sound functions ==
 === <tt>!PlaySound(soundId)</tt> ===
 
 <blockquote>Plays the specified sound.
@@ -744,55 +840,8 @@
 <blockquote>Plays the specified sound for the chosen hedgehog's team.
 </blockquote>
 
-=== <tt>!SetInputMask(mask)</tt> ===
 
-<blockquote>Masks specified player input.
-</blockquote>
-Example: 
-<code lang="lua">    -- masks the long and high jump commands
-SetInputMask(band(0xFFFFFFFF, bnot(gmLJump + gmHJump))) 
-    -- clears input mask, allowing player to take actions
-    SetInputMask(0xFFFFFFFF) 
-		</code>
-Note: Using the input mask is an effective way to script uninterrupted cinematics, or create modes such as No Jumping. 
-
-
-=== <tt>!SetGravity(percent)</tt> ===
-
-<blockquote>Changes the current gravity of the game in percent (relative to default, integer value).
-Setting it to 100 will set gravity to default gravity of hedgewars, 200 will double it, etc.
-</blockquote>
-
-=== <tt>!GetGravity()</tt> ===
-
-<blockquote>Returns the current gravity in percent
-</blockquote>
-
-=== <tt>!SetWaterLine(waterline)</tt> ===
-
-<blockquote>Sets the water level to the specified y-coordinate
-</blockquote>
-
-=== <tt>!SetZoom(zoomLevel)</tt> ===
-
-<blockquote>Sets the zoom level. The value for maximum zoom is currently 1.0 and for minimum 3.0 The default zoom level is 2.0
-</blockquote>
-
-=== <tt>!GetZoom()</tt> ===
-
-<blockquote>Returns the current zoom level
-</blockquote>
-
-=== <tt>!GetRandom(number)</tt> ===
-
-<blockquote>Returns a randomly generated number in the range of 0 to number - 1.  This random number uses the game seed, so is synchronised, and thus safe for multiplayer and saved games.  Use GetRandom for anything that could impact the engine state.  For example, a visual gear can use the Lua random, but adding a regular gear should use GetRandom.
-</blockquote>
-
-=== <tt>!SetWind(windSpeed)</tt> ===
-
-<blockquote>Sets the current wind in the range of -100 to 100. Use together with gfDisableWind for full control.
-</blockquote>
-
+== File system functions ==
 === <tt>!GetDataPath()</tt> ===
 
 <blockquote>Returns the path to the data directory, used when adding libraries.
@@ -803,38 +852,10 @@
 <blockquote>Returns the path to the user data directory, used when adding libraries.
 </blockquote>
 
-=== <tt>!GetClanColor(clan)</tt> ===
 
-<blockquote>Returns the colour of the chosen clan by its number.
-</blockquote>
-=== <tt>!SetClanColor(clan, color)</tt> ===
-
-<blockquote>Sets the colour of the chosen clan by its number.
-</blockquote>
-
-=== <tt>!PlaceGirder(x, y, state)</tt> (0.9.16) ===
 
-<blockquote>Places a girder with centre points x, y and the chosen state.
-These are the accepted states:
-  * 0: short, horizontal
-  * 1: short, decreasing right
-  * 2: short, vertical
-  * 3: short, increasing right
-  * 4: long, horizontal
-  * 5: long, decreasing right
-  * 6: long, vertical
-  * 7: long, increasing right
-</blockquote>
 
-=== <tt>!GetCurAmmoType()</tt> (0.9.16) ===
-
-<blockquote>Returns the currently selected [AmmoTypes Ammo Type].
-</blockquote>
-
-=== <tt>!SwitchHog(gearUid)</tt> (0.9.16) ===
-
-<blockquote>This function will switch to the hedgehog with the specified Uid.</blockquote>
-
+== Stats functions ==
 === <tt>!SendStat(TStatInfoType, statMessage[, teamName])</tt> (0.9.20) ===
 
 <blockquote>Exposes the uIO SendStat to the lua scripts. Use it to produce custom stat pages.