LuaGears.wiki
changeset 1783 b25684cd9837
parent 1782 503aa47f3aaf
child 1784 b08f6f71bfbd
--- a/LuaGears.wiki	Wed Apr 17 13:34:00 2019 +0100
+++ b/LuaGears.wiki	Wed Apr 17 13:42:49 2019 +0100
@@ -37,6 +37,41 @@
     local vgear = AddVisualGear(1000, 1000, vgtExplosion, 0, false) 
 </code>
 
+=== <tt>!AddHog(hogname, botlevel, health, hat)</tt> ===
+Adds a new hedgehog for current team (last created one with the `AddTeam` function), with a bot level, an initial health and a hat.
+
+`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. Note that mixing human-controlled and computer-controlled hedgehogs in the same team is not permitted, but it is permitted to use different computer difficulty levels in the same team.
+
+Returns the gear ID.
+
+*Warning*: This only works in singleplayer mode (e.g. missions). Also, Hedgewars only supports up to 64 hedgehogs in a game.
+
+Example:
+
+<code language="lua">    local player = AddHog("HH 1", 0, 100, "NoHat") -- botlevel 0 means human player
+    SetGearPosition(player, 1500, 1000)
+    -- hint: If you don't call `SetGearPosition`, the hog spawns randomly</code>
+
+=== <tt>!AddMissionHog(health)</tt> (0.9.25) ===
+Add a hedgehog for the current team, using the player-chosen team identity when playing in singleplayer missions. The “current team” is the last team that was added with `AddMissionTeam` or `AddTeam`.
+
+The name and hat match the player's team definition. The hog is also always player-controlled.
+
+Examples:
+<code language="lua">-- Add player team with 3 hogs
+AddMissionTeam(-1)
+AddMissionHog(100)
+AddMissionHog(100)
+AddMissionHog(100)</code>
+
+<code language="lua">-- You can also mix mission hogs with “hardcoded” hogs.
+-- This adds a player team with 2 hogs taken from the player team and 1 hog with a hardcoded name, botlevel and hat.
+AddMissionTeam(-2)
+AddMissionHog(100)
+AddMissionHog(100)
+AddHog("My Hardcoded Hog", 0, 100, "NoHat")
+</code>
+
 === <tt>!SpawnHealthCrate(x, y, [, health])</tt> ===
 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. Do not use a negative value for `health`.
 
@@ -80,41 +115,6 @@
 === <tt>!SpawnFakeUtilityCrate(x, y, explode, poison) </tt> ===
 Same as `SpawnFakeAmmoCrate`, except the crate will look like an utility crate.
 
-=== <tt>!AddHog(hogname, botlevel, health, hat)</tt> ===
-Adds a new hedgehog for current team (last created one with the `AddTeam` function), with a bot level, an initial health and a hat.
-
-`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. Note that mixing human-controlled and computer-controlled hedgehogs in the same team is not permitted, but it is permitted to use different computer difficulty levels in the same team.
-
-Returns the gear ID.
-
-*Warning*: This only works in singleplayer mode (e.g. missions). Also, Hedgewars only supports up to 64 hedgehogs in a game.
-
-Example:
-
-<code language="lua">    local player = AddHog("HH 1", 0, 100, "NoHat") -- botlevel 0 means human player
-    SetGearPosition(player, 1500, 1000)
-    -- hint: If you don't call `SetGearPosition`, the hog spawns randomly</code>
-
-=== <tt>!AddMissionHog(health)</tt> (0.9.25) ===
-Add a hedgehog for the current team, using the player-chosen team identity when playing in singleplayer missions. The “current team” is the last team that was added with `AddMissionTeam` or `AddTeam`.
-
-The name and hat match the player's team definition. The hog is also always player-controlled.
-
-Examples:
-<code language="lua">-- Add player team with 3 hogs
-AddMissionTeam(-1)
-AddMissionHog(100)
-AddMissionHog(100)
-AddMissionHog(100)</code>
-
-<code language="lua">-- You can also mix mission hogs with “hardcoded” hogs.
--- This adds a player team with 2 hogs taken from the player team and 1 hog with a hardcoded name, botlevel and hat.
-AddMissionTeam(-2)
-AddMissionHog(100)
-AddMissionHog(100)
-AddHog("My Hardcoded Hog", 0, 100, "NoHat")
-</code>
-
 == Functions to get gear properties ==
 
 === <tt>!GetGearType(gearUid)</tt> ===
@@ -310,25 +310,25 @@
 local X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint, Scale = GetVisualGearValues(vgUid)
 </code>
 
-== Functions to modify gears ==
+== Functions to change position and velocity ==
+=== <tt>!SetGearPosition(gearUid, x, y)</tt> ===
+Places the specified gear exactly at the position (`x`,`y`). Not to be confused with `SetGearPos`.
+
+=== <tt>!SetGearVelocity(gearUid, dx, dy)</tt> ===
+Gives the specified gear the velocity of `dx`, `dy`.
 
-=== <tt>!HideHog(gearUid)</tt> ===
-Removes a hedgehog from the map. The hidden hedgehog can be restored with `RestoreHog(gearUid)`. Since 0.9.23, returns `true` on success and `false` on failure (if gear does not exist / hog is already hidden).
+=== <tt>CopyPV(gearUid, gearUid)</tt> ===
+This sets the position and velocity of the second gear to the first one.
 
-Example: 
+=== <tt>!FindPlace(gearUid, fall, left, right[, tryHarder])</tt> ===
+Finds a place for the specified gear between x=`left` and x=`right` and places it there. `tryHarder` is optional, setting it to `true`/`false` will determine whether the engine attempts to make additional passes, even attempting to place gears on top of each other.
+
+Example:
 
 <code language="lua">    gear = AddGear(...)
-     HideHog(gear) -- Hide the newly created gear.</code>
-
-=== <tt>!RestoreHog(gearUid)</tt> ===
-Restores a previously hidden hedgehog.  Nothing happens if the hedgehog does not exist or is not hidden.
+    FindPlace(gear, true, 0, LAND_WIDTH) -- places the gear randomly between 0 and LAND_WIDTH</code>
 
-Example: 
-
-<code language="lua">    gear = AddGear(...)
-     HideHog(gear) -- Hide the newly created gear.
-     RestoreHog(gear) -- Restore the newly hidden gear.</code>
-
+== Functions to modify gears ==
 === <tt>!SetGearValues(gearUid, Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, ImpactSounds, Tint, Damage, Boom)</tt> ===
 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. If `gearUid` is invalid or the gear does not exist, nothing happens.
 
@@ -379,46 +379,6 @@
 <code language="lua">  -- set the tint of a visual gear to bright red.
     SetVisualGearValues(circleUid, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0xff0000ff)</code>
 
-
-=== <tt>!FindPlace(gearUid, fall, left, right[, tryHarder])</tt> ===
-Finds a place for the specified gear between x=`left` and x=`right` and places it there. `tryHarder` is optional, setting it to `true`/`false` will determine whether the engine attempts to make additional passes, even attempting to place gears on top of each other.
-
-Example:
-
-<code language="lua">    gear = AddGear(...)
-    FindPlace(gear, true, 0, LAND_WIDTH) -- places the gear randomly between 0 and LAND_WIDTH</code>
-=== <tt>HogSay(gearUid, text, manner [,vgState])</tt> ===
-Makes the specified gear say, think, or shout some text in a comic-style speech or thought bubble. `gearUid` is _not_ limited to hedgehogs, altough the function name suggests otherwise.
-
-The `manner` parameter specifies the type of the bubble and can have one of these values:
-
-|| *Value of `manner`* || *Looks* ||
-|| `SAY_THINK` || Thought bubble ||
-|| `SAY_SAY` || Speech bubble ||
-|| `SAY_SHOUT` || Exclamatory bubble (denotes shouting) ||
-
-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.
-
-|| *Value of `vgState`* || *Effect* ||
-|| `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. ||
-|| `1` || The bubble is drawn translucent. ||
-|| `2` || The bubble is drawn fully opaque. ||
-
-Examples:
-
-<code language="lua">HogSay(CurrentHedgehog, "I wonder what to do …", SAY_THINK) -- thought bubble with text “I wonder what to do …”</code>
-<code language="lua">HogSay(CurrentHedgehog, "I'm hungry.", SAY_SAY) -- speech bubble with text “I’m hungry.”</code>
-<code language="lua">HogSay(CurrentHedgehog, "I smell CAKE!", SAY_SHOUT) -- exclamatory bubble with text “I smell CAKE!”</code>
-=== <tt>!HogTurnLeft(gearUid, boolean)</tt> ===
-Faces the specified hog left or right.
-
-Example:
-
-<code language="lua">    HogTurnLeft(CurrentHedgehog, true) -- turns CurrentHedgehog left 
-    HogTurnLeft(CurrentHedgehog, false) -- turns CurrentHedgehog right</code>
-=== <tt>!SetGearPosition(gearUid, x, y)</tt> ===
-Places the specified gear exactly at the position (`x`,`y`). Not to be confused with `SetGearPos`.
-
 === <tt>SetGearCollisionMask(gearUid, mask)</tt> ===
 Set the collision mask of the given gear with `gearUid`.
 The collision mask defines with which gears and terrain types the gear can collide.
@@ -451,9 +411,6 @@
 
 [https://hg.hedgewars.org/hedgewars/file/default/hedgewars/uConsts.pas#l112]
 
-=== <tt>!SetGearVelocity(gearUid, dx, dy)</tt> ===
-Gives the specified gear the velocity of `dx`, `dy`.
-
 === <tt>!SetFlightTime(gearUid, flighttime)</tt> ===
 Sets the `FlightTime` of the given gear to `flighttime`. The meaning of `FlightTime` is explained in the section `GetFlightTime`.
 
@@ -526,12 +483,6 @@
         end
     end</code>
 
-=== <tt>CopyPV(gearUid, gearUid)</tt> ===
-This sets the position and velocity of the second gear to the first one.
-
-=== <tt>!FollowGear(gearUid)</tt> ===
-Makes the game client follow the specifiec gear (if it exists). Does not work for visual gears.
-
 === <tt>!SetHogName(gearUid, name)</tt> ===
 Sets the name of the specified hedgehog gear.
 
@@ -541,6 +492,14 @@
 === <tt>!SetHogHat(gearUid, hat)</tt> ===
 Sets the hat of the specified hedgehog gear.
 
+=== <tt>!HogTurnLeft(gearUid, boolean)</tt> ===
+Faces the specified hog left or right.
+
+Example:
+
+<code language="lua">    HogTurnLeft(CurrentHedgehog, true) -- turns CurrentHedgehog left 
+    HogTurnLeft(CurrentHedgehog, false) -- turns CurrentHedgehog right</code>
+
 === <tt>!SetGearTarget(gearUid, x, y)</tt> ===
 Sets the x and y coordinate of target-based weapons/utilities.
 *Note*: This can’t be used in onGearAdd() but must be called after gear creation.
@@ -605,6 +564,50 @@
 === <tt>!SetGearPos(gearUid, value)</tt> ===
 Sets the `Pos` value (not the position!) of the specified gear to specified value. See `GetGearPos` for more information.
 
+=== <tt>!HideHog(gearUid)</tt> ===
+Removes a hedgehog from the map. The hidden hedgehog can be restored with `RestoreHog(gearUid)`. Since 0.9.23, returns `true` on success and `false` on failure (if gear does not exist / hog is already hidden).
+
+Example: 
+
+<code language="lua">    gear = AddGear(...)
+     HideHog(gear) -- Hide the newly created gear.</code>
+
+=== <tt>!RestoreHog(gearUid)</tt> ===
+Restores a previously hidden hedgehog.  Nothing happens if the hedgehog does not exist or is not hidden.
+
+Example: 
+
+<code language="lua">    gear = AddGear(...)
+     HideHog(gear) -- Hide the newly created gear.
+     RestoreHog(gear) -- Restore the newly hidden gear.</code>
+
+== Functions for gear actions ==
+=== <tt>HogSay(gearUid, text, manner [,vgState])</tt> ===
+Makes the specified gear say, think, or shout some text in a comic-style speech or thought bubble. `gearUid` is _not_ limited to hedgehogs, altough the function name suggests otherwise.
+
+The `manner` parameter specifies the type of the bubble and can have one of these values:
+
+|| *Value of `manner`* || *Looks* ||
+|| `SAY_THINK` || Thought bubble ||
+|| `SAY_SAY` || Speech bubble ||
+|| `SAY_SHOUT` || Exclamatory bubble (denotes shouting) ||
+
+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.
+
+|| *Value of `vgState`* || *Effect* ||
+|| `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. ||
+|| `1` || The bubble is drawn translucent. ||
+|| `2` || The bubble is drawn fully opaque. ||
+
+Examples:
+
+<code language="lua">HogSay(CurrentHedgehog, "I wonder what to do …", SAY_THINK) -- thought bubble with text “I wonder what to do …”</code>
+<code language="lua">HogSay(CurrentHedgehog, "I'm hungry.", SAY_SAY) -- speech bubble with text “I’m hungry.”</code>
+<code language="lua">HogSay(CurrentHedgehog, "I smell CAKE!", SAY_SHOUT) -- exclamatory bubble with text “I smell CAKE!”</code>
+
+=== <tt>!FollowGear(gearUid)</tt> ===
+Makes the game client follow the specifiec gear (if it exists). Does not work for visual gears.
+
 == Functions to delete gears ==
 === <tt>!DeleteGear(gearUid)</tt> ===
 Deletes a gear.  If the specified gear did not exist, nothing happens.