author | Wuzzy |
Fri, 19 Apr 2019 16:00:29 +0100 | |
changeset 1828 | 3c796552dfd1 |
parent 1827 | b7cdb01850c5 |
child 1829 | d92951dbb8b6 |
permissions | -rw-r--r-- |
1373 | 1 |
#summary Lua library documentation of Utils; contains assorted helper functions |
1345 | 2 |
#labels !LuaLibrary |
1331 | 3 |
= Lua library: `Utils` = |
1329
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
4 |
|
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
5 |
This library includes miscellaneous functions to use, they are all independent of each other and can be used everywhere. |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
6 |
|
1331 | 7 |
== `gearIsInBox(gear, x, y, w, h)` == |
1329
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
8 |
|
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
9 |
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. |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
10 |
|
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
11 |
|
1331 | 12 |
== `gearIsInCircle(gear, x, y, r, useRadius)` == |
1329
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
13 |
|
1358 | 14 |
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. |
15 |
||
1394 | 16 |
== `fillMap([flush])` == |
1358 | 17 |
Completely fill the current map with land. Requires `MapGen` to be set to `mgDrawn`. `FlushPoints()` will be called at the end, unless `flush` is set to `false`. |
18 |
||
1394 | 19 |
== `eraseMap([flush])` == |
1651 | 20 |
Completely erase all land from current map. Requires `MapGen` to be set to `mgDrawn`. `FlushPoints()` will be called at the end, unless `flush` is set to `false`. |
21 |
||
1826 | 22 |
== `updateChallengeRecord(recordType, value[, stat])` (1.0.0) == |
23 |
Report a new team record attempt in a [Missions mission] (preferably challenge missions). In missions, the team file of the mission team (see `AddMissionTeam` for more infos) can store several records (such as highscores) which will be shown in the frontend when the mission is selected. Note this only works for non-campaign missions so far. |
|
24 |
||
25 |
Calling this function means the team has made a record attempt of a given record type (e.g. fastest time or highscore) with a given `value`. If the team's own record has been beaten, or is has set the first record, the team file is being updated. |
|
26 |
||
1827 | 27 |
* `recordType`: Type of record (see [ConfigurationFiles#[Mission%2520<%5BMISSION_NAME>%5D] for a list) |
1826 | 28 |
* `value`: Value that has been achieved by the team |
29 |
* `stat`: If `true` (default), will also write a message in the stats screen (whether record has been beaten, or current record if not). Otherwise, this writes nothing. |
|
30 |
||
31 |
== `getReadableChallengeRecord(recordType)` (1.0.0) == |
|
1828
3c796552dfd1
LuaLibraryUtils: Fix configurationfiles link for real
Wuzzy
parents:
1827
diff
changeset
|
32 |
Returns a human-readable description of a team record of the mission team (see also: `AddMissionTeam`) for the current challenge [Missions mission]. Team records are read from the team file. `recordType` is a record type. Possible record types are listed in [ConfigurationFiles#%5BMission%2520%3CMISSION_NAME%3E%5D]. This can be useful to display something in `ShowMission`. |
1826 | 33 |
|
34 |
If the team does not have a record for the given record type yet, the empty string is returned. If the record type is invalid, `nil` is returned. |
|
35 |
||
36 |
For example, for `"TimeRecord"`, the returned string is something like `"Team's best time: 14.340s"`. |
|
37 |
||
38 |
Example: |
|
39 |
<code lang="lua"> |
|
40 |
ShowMission("MegaRace", "Race Challenge", "Try to finish the race as fast you can!\n" .. getReadableChallengeRecord("TimeRecord")) |
|
41 |
-- Shows the mission panel and the current time record. |
|
42 |
</code> |
|
43 |
||
44 |
== `integerSqrt(num)` (1.0.0) == |
|
45 |
Calculates the square root of `num`, but rounded to an integer. This function is desync-safe. |
|
46 |
||
47 |
== `integerHypotenuse(x, y)` (1.0.0) == |
|
48 |
Calculates the hypotenuse of a triangle with legs x, y, but rounded to an integer. This function is desync-safe. |
|
49 |
||
1651 | 50 |
== Standardized land tint colors == |
51 |
There are some “standard” tint colors for placed girders and other sprites which are defined to allow more consistency, if it is desired. These values are used in !TechRacer, !HedgeEditor and the basic movement training to colorize girders consistently: |
|
52 |
||
1652 | 53 |
* `U_LAND_TINT_NORMAL`: Normal land |
54 |
* `U_LAND_TINT_ICE`: Icy land |
|
55 |
* `U_LAND_TINT_INDESTRUCTIBLE`: Indestructible land |
|
56 |
* `U_LAND_TINT_BOUNCY`: Bouncy land |