# HG changeset patch # User almikes@aol.com # Date 1417574367 0 # Node ID 37d44392ad2b2f49924aa36010e0a7d953b8e51a # Parent 7642806ce7b9ec68465f4f3ab3c2db9fbd41feb2 Reorganize the section “other functions” into several logical subunits. diff -r 7642806ce7b9 -r 37d44392ad2b 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 - + == Introduction == @@ -674,33 +674,133 @@
Set pos of specified gear to specified value.
-== Other Functions == + +== Gameplay functions == -=== !ClearGameFlags() === +=== `GameFlags` === + +==== !ClearGameFlags() ====
Disables *all* !GameFlags
-=== !DisableGameFlags(gameflag, ...) === +==== !DisableGameFlags(gameflag, ...) ====
Disables the listed !GameFlags, without changing the status of other !GameFlags
-=== !EnableGameFlags(gameflag, ...) === +==== !EnableGameFlags(gameflag, ...) ====
Enables the listed !GameFlags, without changing the status of other !GameFlags
-=== !GetGameFlag(gameflag) === +==== !GetGameFlag(gameflag) ====
Returns true if the specified gameflag is enabled, otherwise false
-=== !EndGame() === +=== Environment === + +==== !SetGravity(percent) ==== + +
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. +
+ +==== !GetGravity() ==== + +
Returns the current gravity in percent +
+ +==== !SetWaterLine(waterline) ==== + +
Sets the water level to the specified y-coordinate +
+ +==== !SetWind(windSpeed) ==== + +
Sets the current wind in the range of -100 to 100. Use together with gfDisableWind for full control. +
+ +==== !EndGame() ====
Makes the game end.
+=== Map === +==== !MapHasBorder() ==== + +
Returns true/false if the map has a border or not. +
+ +==== !TestRectForObstacle(x1, y1, x2, y2, landOnly) (0.9.16) ==== +
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.) +
+ +==== !PlaceGirder(x, y, state) (0.9.16) ==== + +
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 +
+ +=== Current hedgehog === + +==== !GetCurAmmoType() (0.9.16) ==== + +
Returns the currently selected [AmmoTypes Ammo Type]. +
+ +==== !SwitchHog(gearUid) (0.9.16) ==== + +
This function will switch to the hedgehog with the specified Uid.
+ +==== !SetInputMask(mask) ==== + +
Masks specified player input. +
+Example: + -- masks the long and high jump commands +SetInputMask(band(0xFFFFFFFF, bnot(gmLJump + gmHJump))) + -- clears input mask, allowing player to take actions + SetInputMask(0xFFFFFFFF) + +Note: Using the input mask is an effective way to script uninterrupted cinematics, or create modes such as No Jumping. + + +=== Randomness === +==== !GetRandom(number) ==== + +
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. +
+ +=== Clans === +==== !GetClanColor(clan) ==== + +
Returns the colour of the chosen clan by its number. +
+==== !SetClanColor(clan, color) ==== + +
Sets the colour of the chosen clan by its number. +
+ + + + +== Functions affecting the GUI == + +=== !AddCaption(text) === + +
Display event text in the upper part of the screen. +
+ === !ShowMission(caption, subcaption, text, icon, time) ===
Use to tell the player what he is supposed to do. @@ -719,21 +819,17 @@
Hides the mission. This function is currently bugged somehow and will completely ruin your life, and your script should you happen to use it.
-=== !AddCaption(text) === +=== !SetZoom(zoomLevel) === -
Display event text in the upper part of the screen. +
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
-=== !MapHasBorder() === +=== !GetZoom() === -
Returns true/false if the map has a border or not. +
Returns the current zoom level
-=== !TestRectForObstacle(x1, y1, x2, y2, landOnly) (0.9.16) === - -
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.) -
- +== Sound functions == === !PlaySound(soundId) ===
Plays the specified sound. @@ -744,55 +840,8 @@
Plays the specified sound for the chosen hedgehog's team.
-=== !SetInputMask(mask) === -
Masks specified player input. -
-Example: - -- masks the long and high jump commands -SetInputMask(band(0xFFFFFFFF, bnot(gmLJump + gmHJump))) - -- clears input mask, allowing player to take actions - SetInputMask(0xFFFFFFFF) - -Note: Using the input mask is an effective way to script uninterrupted cinematics, or create modes such as No Jumping. - - -=== !SetGravity(percent) === - -
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. -
- -=== !GetGravity() === - -
Returns the current gravity in percent -
- -=== !SetWaterLine(waterline) === - -
Sets the water level to the specified y-coordinate -
- -=== !SetZoom(zoomLevel) === - -
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 -
- -=== !GetZoom() === - -
Returns the current zoom level -
- -=== !GetRandom(number) === - -
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. -
- -=== !SetWind(windSpeed) === - -
Sets the current wind in the range of -100 to 100. Use together with gfDisableWind for full control. -
- +== File system functions == === !GetDataPath() ===
Returns the path to the data directory, used when adding libraries. @@ -803,38 +852,10 @@
Returns the path to the user data directory, used when adding libraries.
-=== !GetClanColor(clan) === -
Returns the colour of the chosen clan by its number. -
-=== !SetClanColor(clan, color) === - -
Sets the colour of the chosen clan by its number. -
- -=== !PlaceGirder(x, y, state) (0.9.16) === -
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 -
-=== !GetCurAmmoType() (0.9.16) === - -
Returns the currently selected [AmmoTypes Ammo Type]. -
- -=== !SwitchHog(gearUid) (0.9.16) === - -
This function will switch to the hedgehog with the specified Uid.
- +== Stats functions == === !SendStat(TStatInfoType, statMessage[, teamName]) (0.9.20) ===
Exposes the uIO SendStat to the lua scripts. Use it to produce custom stat pages.