|
uniTM API
|
Public interface which provides access to uniTM features.
Use this to define custom ranking rules and manage player records.
See the USAGE EXAMPLE for a demonstration of how to use it in an example level.
Public Member Functions | |
| void | configureCustomRanking (bool higherIsBetter=true, uint8 recordDisplayFormat=DISPLAYFORMAT::INTEGER, string unitSingular="", string unitPlural="", bool displayTimer=false, int levelCount=0) |
| Initializes custom ranking. Configures how custom records are displayed and ranked. Server should run this once in onLevelLoad(). Has no effect when ran by clients. | |
| void | getRecordByPlayer (jjPLAYER@ player, PlayerRecordCallback@ callback) |
| Retrieves a player's record. | |
| void | getRecordByRank (int rank, RankRecordCallback@ callback) |
| Retrieves an indexed record. | |
| void | getRecordCount (RecordCountCallback@ callback) |
| Retrieves the total number of records. | |
| string | formatRecord (int record) |
| Returns a string representation of a record. Uses the format and units defined in configureCustomRanking(). | |
| bool | practiceModeEnabled () |
| Checks whether practice mode is enabled. | |
| void | disableQuickSuicide () |
| Prevents players from using the "quick suicide" assist tool. | |
Test state management | |
Functions for managing a player's test session. Make sure you understand the 3 player states:
The following methods are used to transition between the 3 states and can be called both as a server or as a client. Note that a client call can only affect local players. | |
| void | initTest (jjPLAYER@ player) |
| Initializes a test session and assigns an [ini] tag to a player. Can be used at any time to stop existing test session and prepare for a new run. Serves as a replacement for text events of ID 100. Both approaches are suitable. | |
| void | beginTest (jjPLAYER@ player, bool recordGhost=true) |
| Begins a test and assigns a level 1 tag [1] to a player. Can only be used on players who are currently wearing an [ini] tag. Serves as a replacement for text events of ID 101. Both approaches are suitable. | |
| void | setLevel (jjPLAYER@ player, uint level) |
| Updates the level number tag. Can only be used on players that are already in a level state (wearing a level number tag). Cannot be used to begin a test from [ini] state. This is a purely visual change which serves as a replacement of text events with ID range of 102-254. | |
| void | finishTest (jjPLAYER@ player, int record, uint8 announceRecord=ANNOUNCERECORD::ALWAYS) |
| Ends the test session, submits a record and assigns a [win] tag to a player. Can only be used on players that are in a level state (wearing a level number tag). If applicable, stops the ghost run recording and determines whether to update the ghost run based on provided record value. | |
| void | submitRecord (jjPLAYER@ player, int record, uint8 announceRecord=ANNOUNCERECORD::NEVER) |
| Submits a record without ending the test session and without assigning a [win] tag to a player. Can only be used on players that are in a level state (wearing a level number tag). Unlike finishTest(), this method should be used when a player reaches a significant milestone in a test, but is still in the game and can continue raising their score. When applicable, the timer will continue running, and ghost run will continue recording. | |
| void configureCustomRanking | ( | bool | higherIsBetter = true, |
| uint8 | recordDisplayFormat = DISPLAYFORMAT::INTEGER, | ||
| string | unitSingular = "", | ||
| string | unitPlural = "", | ||
| bool | displayTimer = false, | ||
| int | levelCount = 0 ) |
Initializes custom ranking. Configures how custom records are displayed and ranked. Server should run this once in onLevelLoad(). Has no effect when ran by clients.
| higherIsBetter | Whether higher record values represent better results. |
| recordDisplayFormat | Format used when displaying records. See DISPLAYFORMAT. |
| unitSingular | Optional, singular unit name (e.g. "point"). |
| unitPlural | Optional, plural unit name (e.g. "points"). |
| displayTimer | Whether to display a timer during the test. |
| levelCount | Number of levels in the test. Leave zero to let uniTM figure it out on its own by scanning the level for text events. |
| void initTest | ( | jjPLAYER@ | player | ) |
Initializes a test session and assigns an [ini] tag to a player. Can be used at any time to stop existing test session and prepare for a new run. Serves as a replacement for text events of ID 100. Both approaches are suitable.
| player | Target player. |
| void beginTest | ( | jjPLAYER@ | player, |
| bool | recordGhost = true ) |
Begins a test and assigns a level 1 tag [1] to a player. Can only be used on players who are currently wearing an [ini] tag. Serves as a replacement for text events of ID 101. Both approaches are suitable.
| player | Target player. |
| recordGhost | Determines whether a ghost run recording should begin. |
| void setLevel | ( | jjPLAYER@ | player, |
| uint | level ) |
Updates the level number tag. Can only be used on players that are already in a level state (wearing a level number tag). Cannot be used to begin a test from [ini] state. This is a purely visual change which serves as a replacement of text events with ID range of 102-254.
| player | Target player. |
| level | Level number. |
| void finishTest | ( | jjPLAYER@ | player, |
| int | record, | ||
| uint8 | announceRecord = ANNOUNCERECORD::ALWAYS ) |
Ends the test session, submits a record and assigns a [win] tag to a player. Can only be used on players that are in a level state (wearing a level number tag). If applicable, stops the ghost run recording and determines whether to update the ghost run based on provided record value.
| player | Target player. |
| record | Record value. |
| announceRecord | Determines when to display a chat alert about a finished test. See ANNOUNCERECORD. |
| void submitRecord | ( | jjPLAYER@ | player, |
| int | record, | ||
| uint8 | announceRecord = ANNOUNCERECORD::NEVER ) |
Submits a record without ending the test session and without assigning a [win] tag to a player. Can only be used on players that are in a level state (wearing a level number tag). Unlike finishTest(), this method should be used when a player reaches a significant milestone in a test, but is still in the game and can continue raising their score. When applicable, the timer will continue running, and ghost run will continue recording.
| player | Target player. |
| record | Record value. |
| announceRecord | Determines when to display a chat alert about a submitted record. See ANNOUNCERECORD. |
| void getRecordByPlayer | ( | jjPLAYER@ | player, |
| PlayerRecordCallback@ | callback ) |
Retrieves a player's record.
Fetches the player's record from the server and invokes the callback once the response has been received.
| player | Player whose record should be retrieved. |
| callback | Function invoked when the server responds. |
| void getRecordByRank | ( | int | rank, |
| RankRecordCallback@ | callback ) |
Retrieves an indexed record.
Fetches a record based by rank number from the server and invokes the callback once the response has been received.
| rank | 1-indexed record number. |
| callback | Function invoked when the server responds. |
| void getRecordCount | ( | RecordCountCallback@ | callback | ) |
Retrieves the total number of records.
Fetches the total number of records from the server and invokes the callback once the response has been received.
| callback | Function invoked when the server responds. |
| string formatRecord | ( | int | record | ) |
Returns a string representation of a record. Uses the format and units defined in configureCustomRanking().
| record | to be formatted |
| bool practiceModeEnabled | ( | ) |
Checks whether practice mode is enabled.
| void disableQuickSuicide | ( | ) |
Prevents players from using the "quick suicide" assist tool.
Must be called by the server. Has no effect when called by a client.