Copy-editing on the entire page.
authoralmikes@aol.com
Sun, 21 Dec 2014 01:27:45 +0000
changeset 528 88cc64932e78
parent 527 908428bf4a03
child 529 f3e3229af8bf
Copy-editing on the entire page.
LuaLibraries.wiki
--- a/LuaLibraries.wiki	Sun Dec 21 01:08:03 2014 +0000
+++ b/LuaLibraries.wiki	Sun Dec 21 01:27:45 2014 +0000
@@ -20,35 +20,34 @@
 This library allows you to translate string and should be used whenever a script has text. It loads the appropriate locale file and check automatically.
 
 === lang(text) ===
-<blockquote>
+
 Returns the localised string of text or if it is not found it returns text.
-</blockquote>
+
 
 
 = Utils =
 
 This library includes miscellaneous functions to use, they are all independent of each other and can be used everywhere.
 
-=== gearIsInBox(gear, x, y, w, h) ===
-<blockquote>
+=== `gearIsInBox(gear, x, y, w, h)` ===
+
 Returns whether the gear is inside (centre point of the gear) a box with x and y as the top left corner and having the width and height of w and h respectively.
-</blockquote>
+
 
-=== gearIsInCircle(gear, x, y, r, useRadius) ===
-<blockquote>
+=== `gearIsInCircle(gear, x, y, r, useRadius)` ===
+
 Returns whether the gear is inside a circle with x and y being the centre point and r being the radius of the circle. The boolean useRadius determine whether only the centre point of the gear will be used or the radius of the gear will be checked too.
-</blockquote>
+
 
 
 = Tracker =
 
 This library is intended to be used if you need to keep track of gears. It can also keep track of teams and clans and as an extra functionality it can also store variables for a gear, team or clan.
 
-To set it up you need to add some hooks in different events. The hooks trackGear and trackDeletion to onGearAdd and onGearDelete respectively. It is strongly recommended to only track the gears you are interested in as, especially with snow on, the amount of gears can go up high and that will slow down the script. To keep track of teams you need to keep track of gtHedgehog and gtResurrector (if resurrection might be used) and add trackTeams to onGameStart.
+To set it up you need to add some hooks in different events. The hooks `trackGear` and `trackDeletion` to `onGearAdd` and `onGearDelete` respectively. It is strongly recommended to only track the gears you are interested in as, especially with snow on, the amount of gears can go up high and that will slow down the script. To keep track of teams you need to keep track of `gtHedgehog` and `gtResurrector` (if resurrection might be used) and add `trackTeams` to `onGameStart`.
 
-If you want to call a function on a couple of gears you will have to call the "runOn" functions. To these you will pass the function you want to be run as a variable to the function. The function must take a gear as a parameter, nothing else, for example:
-<code language="lua">
-function killall(gear)
+If you want to call a function on a couple of gears you will have to call the “`runOn`” functions. To these you will pass the function you want to be run as a variable to the function. The function must take a gear as a parameter, nothing else, for example:
+<code language="lua">function killall(gear)
     SetHealth(gear, 0)
 end
 
@@ -56,98 +55,97 @@
     if GetGearType(gear) == gtTarget then
         runOnHogs(killall)
     end
-end
-</code>
+end</code>
 This will kill all hogs if a target is destroyed.
 
 To see a commented example of the tracker in use by a script you can look at
-[http://code.google.com/p/hedgewars/source/browse/share/hedgewars/Data/Scripts/Multiplayer/Random_Weapon.lua Random Weapons]
+[http://code.google.com/p/hedgewars/source/browse/share/hedgewars/Data/Scripts/Multiplayer/Random_Weapon.lua Random Weapons].
 
 == Tracking functions ==
 
-=== trackGear(gear) ===
-<blockquote>
+=== `trackGear(gear)` ===
+
 Will keep track of the gear.
-</blockquote>
+
+
+=== `trackDeletion(gear)` ===
 
-=== trackDeletion(gear) ===
-<blockquote>
 Will stop keeping track of the gear (gears not tracked will be ignored).
-</blockquote>
+
 
-=== trackTeams() ===
-<blockquote>
+=== `trackTeams()` ===
+
 Will start the tracking of teams, clans and hedgehogs (hogs can be tracked without this).
-</blockquote>
+
 
-== "runOn" functions ==
+== “`runOn`” functions ==
 
-=== runOnGears(func) ===
-<blockquote>
-Runs the function func on all gears.
-</blockquote>
+=== `runOnGears(func)` ===
+
+Runs the function `func` on all gears.
+
 
-=== runOnHogs(func) ===
-<blockquote>
-Runs the function func on all hedgehogs.
-</blockquote>
+=== `runOnHogs(func)` ===
+
+Runs the function `func` on all hedgehogs.
+
 
-=== runOnHogsInTeam(func, team) ===
-<blockquote>
-Runs the function func on all hedgehogs in the specified team.
-</blockquote>
+=== `runOnHogsInTeam(func, team)` ===
+
+Runs the function `func` on all hedgehogs in the specified team.
+
 
 === runOnHogsInOtherTeams(func, team) ===
-<blockquote>
-Runs the function func on all hedgehogs but those in the specified team.
-</blockquote>
+
+Runs the function `func` on all hedgehogs but those in the specified team.
+
+
+=== `runOnHogsInClan(func, clan)` ===
 
-=== runOnHogsInClan(func, clan) ===
-<blockquote>
-Runs the function func on all hedgehogs in the specified clan.
-</blockquote>
+Runs the function `func` on all hedgehogs in the specified clan.
+
 
-=== runOnHogsInOtherClans(func, clan) ===
-<blockquote>
-Runs the function func on all hedgehogs but those in the specified clan.
-</blockquote>
+=== `runOnHogsInOtherClans(func, clan)` ===
+
+Runs the function `func` on all hedgehogs but those in the specified clan.
+
 
 == Variable functions ==
 
-to be continued...
+_To be continued …_
 
 
 = Animate =
 
 This library provides functions that aid cinematic/cut-scene creation and functions for handling events. 
 
-In order to use it's full potential, the following lines need to be at the beginning of onGameTick.
+In order to use its full potential, the following lines need to be at the beginning of `onGameTick`.
 
 <code language="lua">function onGameTick()
-    !AnimUnWait()
-    if !ShowAnimation() == false then
+    AnimUnWait()
+    if ShowAnimation() == false then
         return
     end
-    !ExecuteAfterAnimations()
-    !CheckEvents()
+    ExecuteAfterAnimations()
+    CheckEvents()
 end</code>
 
-Also, !AnimInit() needs to be called in !onGameInit().
+Also, `AnimInit()` needs to be called in `onGameInit()`.
 Each of these functions will be explained below.
 
 == Cinematic Handling ==
 
-=== !ShowAnimation() ===
-<blockquote>Performs the current action in the cinematic and returns true if finished, otherwise false. It needs to be used in onGameTick. Cut-scenes need to be added with !AddAnim(steps).</blockquote>
+=== `ShowAnimation()` ===
+Performs the current action in the cinematic and returns `true` if finished, otherwise `false`. It needs to be used in `onGameTick`. Cut-scenes need to be added with `AddAnim(steps)`.
 
-=== !AddAnim(steps) ===
-<blockquote>Adds steps to the array of animations, where steps is a table with numbers as keys and elements of the following form. Each step is a table having the following keys: func, args, swh.
+=== `AddAnim(steps)` ===
+Adds `steps` to the array of animations, where `steps` is a table with numbers as keys and elements of the following form. Each step is a table having the following keys: `func`, `args`, `swh`.
 
-  * _func_ is the function to be executed. It can be any function that returns false when it needs to be called again in following game ticks (e.g. !AnimMove). It can be one of the cinematic functions. 
+  * `func` is the function to be executed. It can be any function that returns false when it needs to be called again in following game ticks (e.g. `AnimMove`). It can be one of the cinematic functions. 
 
-  * _args_ is a table containing the arguments that need to be passed to the function given
+  * `args` is a table containing the arguments that need to be passed to the function given
 
-  * _swh_ is an optional boolean value that defaults to true and denotes whether the current hedgehog should be switched to the hog given as argument.</blockquote>
+  * `swh` is an optional boolean value that defaults to `true` and denotes whether the current hedgehog should be switched to the hog given as argument.
 Example:
 <code language="lua">cinem = {
     {func = AnimSay, args = {myHog, "Snails! SNAILS!", SAY_SAY, 3000}},
@@ -156,94 +154,98 @@
     }
 AddAnim(cinem)</code>
 
-=== !RemoveAnim(steps) ===
-<blockquote>Removes steps from the animations array.</blockquote>
+=== `RemoveAnim(steps)` ===
+Removes `steps` from the animations array.
 
-=== !AddSkipFunction(anim, func, args) ===
-<blockquote>Adds _func_ to the array of functions used to skip animations, associating it with _anim_. When the animation is skipped (see below), the function is called with _args_ as arguments.</blockquote>
+=== `AddSkipFunction(anim, func, args)` ===
+Adds `func` to the array of functions used to skip animations, associating it with `anim`. When the animation is skipped (see below), the function is called with `args` as arguments.
 Example:
 <code language="lua">AddSkipFunc(cinem, SkipCinem, {})</code>
 
-=== !RemoveSkipFunction(anim) ===
-<blockquote> Removes the skip function associated with _anim_.</blockquote>
+=== `RemoveSkipFunction(anim)` ===
+Removes the skip function associated with `anim`.
 
-=== !SetAnimSkip(bool) ===
-<blockquote> Sets the state of animation skipping to _bool_. It is useful in case the player is allowed to skip the animation.</blockquote>
+=== `SetAnimSkip(bool)` ===
+Sets the state of animation skipping to `bool`. It is useful in case the player is allowed to skip the animation.
+
 Example:
 <code language="lua">function onPrecise()
-    if !AnimInProgress() then
+    if AnimInProgress() then
         SetAnimSkip(true)
     end
 end</code>
 
-=== !AnimInProgress() ===
-<blockquote> Returns true if a cinematic is currently taking place, false otherwise.</blockquote>
+=== `AnimInProgress()` ===
+Returns `true` if a cinematic is currently taking place, `false` otherwise.
 
-=== !ExecuteAfterAnimations() ===
-<blockquote> Calls the functions (added with !AddFunction) that need to be executed after the cinematic. The best location for this function call is in onGameTick.</blockquote>
+=== `ExecuteAfterAnimations()` ===
+Calls the functions (added with `AddFunction`) that need to be executed after the cinematic. The best location for this function call is in `onGameTick`.
 
-=== !AddFunction(element) ===
-<blockquote> Adds _element_ to the functions array that are to be called after the cinematic. _element_ is a table with the keys: func, args.</blockquote>
+=== `AddFunction(element)` ===
+Adds `element` to the functions array that are to be called after the cinematic. `element` is a table with the keys: `func`, `args`.
+
 Example:
 <code language="lua">AddFunction({func = AfterCinem, args = {2}})</code>
 
-=== !RemoveFunction() ===
-<blockquote> Removes the first function from the aforementioned list.</blockquote>
+=== `RemoveFunction()` ===
+Removes the first function from the aforementioned list.
 
-=== !AnimInit() ===
-<blockquote> Initializes variables used by the other functions. Needs to be called in onGameInit.</blockquote>
+=== `AnimInit()` ===
+Initializes variables used by the other functions. Needs to be called in `onGameInit`.
 
 === !AnimUnWait() ===
-<blockquote> Decreases the wait time used by cinematics. It is best called in onGameTick</blockquote>
+Decreases the wait time used by cinematics. It is best called in `onGameTick`.
 
 == Cinematic Functions ==
 
-=== !AnimSwitchHog(gear) ===
-<blockquote> Switches to _gear_ and follows it. </blockquote>
+=== `AnimSwitchHog(gear)` ===
+Switches to `gear` and follows it.
 
-=== !AnimWait(gear, time) ===
-<blockquote> Increases the wait time by _time_. _gear_ is just for compatibility with !ShowAnimation.</blockquote>
+=== `AnimWait(gear, time)` ===
+Increases the wait time by `time`. `gear` is just for compatibility with `ShowAnimation`.
 
-=== !AnimSay(gear, text, manner, time) ===
-<blockquote> Calls HogSay with the first three arguments and increses the wait time by _time_.</blockquote>
+=== `AnimSay(gear, text, manner, time` ===
+Calls `HogSay` with the first three arguments and increses the wait time by `time`.
+
 Example:
 <code language="lua">cinem = {
     {func = AnimSay, args = {gear1, "You're so defensive!", SAY_SAY, 2500}},
     {func = AnimSay, args = {gear2, "No, I'm not!", SAY_SAY, 2000}}
    }</code>
 
-=== !AnimSound(gear, sound, time) ===
-<blockquote> Plays the sound _sound_ and increases the wait time by _time_.</blockquote>
+=== `AnimSound(gear, sound, time)` ===
+Plays the sound `sound` and increases the wait time by `time`.
 
-=== !AnimTurn(hog, dir) ===
-<blockquote> Makes _hog_ face in direction _dir_, where _dir_ is either "Right" or "Left".</blockquote>
+=== `AnimTurn(hog, dir)` ===
+Makes `hog` face in direction `dir`, where `dir` equals either `"Right"` or `"Left"`.
 
-=== !AnimMove(hog, dir, x, y) ===
-<blockquote> Makes _hog_ move in direction _dir_ until either his horizontal coordinate is _x_ or his vertical coordinate is _y_.</blockquote>
+=== `AnimMove(hog, dir, x, y)` ===
+Makes `hog` move in direction `dir` until either his horizontal coordinate is `x` or his vertical coordinate is `y`.
 
-=== !AnimJump(hog, jumpType) ===
-<blockquote> Makes _hog_ perform a jump of type _jumpType_, where _jumpType_ is either "long", "high" or "back".</blockquote>
+=== `AnimJump(hog, jumpType)` ===
+Makes `hog` perform a jump of type `jumpType`, where `jumpType` equals either `"long"`, `"high"` or `"back"`.
 
-=== !AnimSetGearPosition(gear, x, y, fall) ===
-<blockquote> Sets the position of _gear_ to (x, y). If the optional argument _fall_ is not false then the gear is given a small falling velocity in order to get around exact positioning.</blockquote>
+=== `AnimSetGearPosition(gear, x, y, fall)` ===
+Sets the position of `gear` to (`x`, `y`). If the optional argument `fall` does not equal `false` then the gear is given a small falling velocity in order to get around exact positioning.
 
-=== !AnimDisappear(gear, x, y) ===
-<blockquote> Teleports the gear to (x, y), adding some effects at the previous position and sounds. Doesn't follow the gear.</blockquote>
+=== `AnimDisappear(gear, x, y)` ===
+Teleports the gear to (`x`, `y`), adding some effects at the previous position and sounds. Doesn’t follow the gear.
 
-=== !AnimOutOfNowhere(gear, x, y) ===
-<blockquote> Teleports the gear to (x, y), adding effects and sounds at the final position. Follows gear.</blockquote>
+=== `AnimOutOfNowhere(gear, x, y)` ===
+Teleports the gear to (`x`, `y`), adding effects and sounds at the final position. Follows gear.
 
-=== !AnimTeleportGear(gear, x, y) ===
-<blockquote> Teleports the gear to (x, y), adding effects and sounds both at the starting position and the final position. Follows gear.</blockquote>
+=== `AnimTeleportGear(gear, x, y)` ===
+Teleports the gear to (`x`, `y`), adding effects and sounds both at the starting position and the final position. Follows gear.
 
-=== !AnimVisualGear(gear, x, y, vgType, state, critical, follow) ===
-<blockquote> Calls AddVisualGear with arguments second to sixth. If the optional argument _follow_ is true then the gear is followed. _gear_ is for compatibility only.</blockquote>
+=== `AnimVisualGear(gear, x, y, vgType, state, critical, follow)` ===
+Calls `AddVisualGear` with arguments second to sixth. If the optional argument `follow` equals `true` then the gear is followed. `gear` is for compatibility only.
 
-=== !AnimCaption(gear, text, time) ===
-<blockquote> Adds _text_ as caption and increases wait time by _time_.</blockquote>
+=== `AnimCaption(gear, text, time)` ===
+Adds `text` as caption and increases wait time by `time`.
 
-=== !AnimCustomFunction(gear, func, args) ===
-<blockquote> Calls the function _func_ with _args_ as arguments. This function is useful, for instance, when the cinematic uses the position of a gear at the moment of execution. If _func_ needs to be called in following game ticks then it should return false.</blockquote>
+=== `AnimCustomFunction(gear, func, args)` ===
+Calls the function `func` with `args` as arguments. This function is useful, for instance, when the cinematic uses the position of a gear at the moment of execution. If `func` needs to be called in following game ticks then it should return false.
+
 Example:
 <code language="lua">function NeedToTurn(hog1, hog2)
    if GetX(hog1) < GetX(hog2) then
@@ -257,8 +259,9 @@
 
 cinem = {{func = AnimCustomFunction, args = {hog1, NeedToTurn, {hog1, hg2}}}}</code>
 
-=== !AnimInsertStepNext(step) ===
-<blockquote> Inserts _step_ after the current step (read: action) in the cinematic array. Useful when an action depends on variables (e.g. positoins). It can be used mostly with !AnimCustomFunction. Note: In case of multiple consecutive calls, steps need to be added in reverse order.</blockquote>
+=== `AnimInsertStepNext(step)` ===
+Inserts `step` after the current step (read: action) in the cinematic array. Useful when an action depends on variables (e.g. positoins). It can be used mostly with `AnimCustomFunction`. Note: In case of multiple consecutive calls, steps need to be added in reverse order.
+
 Example:
 <code language="lua">function BlowHog(deadHog)
   AnimInsertStepNext({func = DeleteGear, args = {deadHog}, swh = false}) 
@@ -276,10 +279,11 @@
 
 == Event Handling ==
 
-Events are pairs of functions that are used to check for various conditions. One of them is for verification and, if it returns true, the second function is called.
+Events are pairs of functions that are used to check for various conditions. One of them is for verification and, if it returns `true`, the second function is called.
 
-=== !AddEvent(condFunc, condArgs, doFunc, doArgs, evType) ===
-<blockquote> Adds the functions _condFunc_ and _doFunc_ to the events list. They get called with the respective args (_condArgs_ and _doArgs_). _condFunc_ will get called in every game tick until it returns true or is removed. Once it returns true, doFunc is called and they are or are not removed from the list, depending on _evType_ (0 for removal, 1 for keeping). An _evType_ of 1 is useful for repeating actions (e.g. every time a hog gets damaged, do something).</blockquote>
+=== `AddEvent(condFunc, condArgs, doFunc, doArgs, evType)` ===
+Adds the functions `condFunc` and `doFunc` to the events list. They get called with the respective args (`condArgs` and `doArgs`). `condFunc` will get called in every game tick until it returns `true` or is removed. Once it returns `true`, `doFunc` is called and they are or are not removed from the list, depending on `evType` (`0` for removal, `1` for keeping). An `evType` of `1` is useful for repeating actions (e.g. every time a hog gets damaged, do something).
+
 Example:
 <code language="lua">function CheckPos()
    return GetX(myHog) > 1500
@@ -296,11 +300,12 @@
 AddEvent(CheckPos, {}, DoPos, {}, 0) -- Add event that gets removed on completion
 AddEvent(CheckAmmo, {}, DoAmmo, {}, 1) -- Add repeating event</code>
 
-=== !AddNewEvent(condFunc, condArgs, doFunc, doArgs, evType) ===
-<blockquote> Does the same as !AddEvent, but first checks if the event is already in the list so that it isn't added twice.</blockquote>
+=== `AddNewEvent(condFunc, condArgs, doFunc, doArgs, evType)` ===
+Does the same as `AddEvent`, but first checks if the event is already in the list so that it isn’t added twice.
 
-=== !RemoveEventFunc(cFunc, cArgs) ===
-<blockquote> Removes the event(s) that have _cFunc_ as the condition checking function. If _cArgs_ is not nil then only those events get removed that have _cArgs_ as arguments for _cFunc_, too.</blockquote>
+=== `RemoveEventFunc(cFunc, cArgs)` ===
+Removes the event or events that have `cFunc` as the condition checking function. If `cArgs` does not equal `nil` then only those events get removed that have `cArgs` as arguments for `cFunc`, too.
+
 Example:
 <code language="lua">AddEvent(condFunc1, condArgs1, doFunc, doArgs)
 AddEvent(condFunc1, condArgs2, doFunc, doArgs)
@@ -310,8 +315,8 @@
 RemoveEventFunc(condFunc1) --Removes all three events that have condFunc1
 RemoveEventFunc(condFunc2, condArgs1) --Removes a single event</code>
 
-=== !CheckEvents ===
-<blockquote> Verifies all the condition functions in the events list and calls the respective 'action' functions if the conditions are met. If the evType of a completed event is 0 then it is removed from the list. This function is best placed in onGameTick.</blockquote>
+=== `CheckEvents` ===
+<blockquote> Verifies all the condition functions in the events list and calls the respective ‘action’ functions if the conditions are met. If the `evType` of a completed event equals `0` then it is removed from the list. This function is best placed in `onGameTick`.
 
 
 = Params =
@@ -326,18 +331,17 @@
 
 Using this library is by no means neccessary.
 
-== `parseParams()` ==
+=== `parseParams()` ===
 Parses `ScriptParam` and writes the result into the global table `params`. The table will follow the `key=value` pattern. Both keys and pairs are stored as string.
 
-=== Example  ===
+==== Example  ====
 <code language="lua">
 function onParameters()
     parseParams()
     if params["myparam1"] == "hello" then
         WriteLnToConsole("Hello World!")
     end
-end
-</code>
+end</code>
 
 If the key-value pair `myparam1=hello` is present, this script writes “Hello World!” in the console. All these inputs would trigger the event: