LuaLibraryUtils: Add four upcoming 1.0.0 functions
Fri, 19 Apr 2019 15:47:17 +0100
changeset 1826 24b348e89a57
parent 1825 1d2aeacbdd8e
child 1827 b7cdb01850c5
LuaLibraryUtils: Add four upcoming 1.0.0 functions
--- a/	Fri Apr 19 15:16:14 2019 +0100
+++ b/	Fri Apr 19 15:47:17 2019 +0100
@@ -19,6 +19,34 @@
 == `eraseMap([flush])` ==
 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`.
+== `updateChallengeRecord(recordType, value[, stat])` (1.0.0) ==
+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.
+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.
+ * `recordType`: Type of record (see [ConfigurationFiles#[Mission%20<MISSION_NAME>]] for a list)
+ * `value`: Value that has been achieved by the team
+ * `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.
+== `getReadableChallengeRecord(recordType)` (1.0.0) ==
+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#[Mission%20<MISSION_NAME>]]. This can be useful to display something in `ShowMission`.
+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.
+For example, for `"TimeRecord"`, the returned string is something like `"Team's best time: 14.340s"`.
+<code lang="lua">
+ShowMission("MegaRace", "Race Challenge", "Try to finish the race as fast you can!\n" .. getReadableChallengeRecord("TimeRecord"))
+-- Shows the mission panel and the current time record.
+== `integerSqrt(num)` (1.0.0) ==
+Calculates the square root of `num`, but rounded to an integer. This function is desync-safe.
+== `integerHypotenuse(x, y)` (1.0.0) ==
+Calculates the hypotenuse of a triangle with legs x, y, but rounded to an integer. This function is desync-safe.
 == Standardized land tint colors ==
 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: