Achievement Functions - Jamiras/RATools GitHub Wiki

achievement(title, description, points, trigger, id=0, published="", modified="", badge="0", type="", set=0)

Defines a new achievement with the specified title (string), description (string), points (integer), and trigger.

trigger is an expression with one or more comparisons. These may be modified by trigger functions.

if id is provided when calling the achievement function, the script will generate a local achievement definition that the toolkit will merge into the existing achievement instead of putting as a separate local achievement.

badge can be used to specify the image associated to the achievement. The value is the ID of the badge (already on the server). RATools will not upload a badge for you.

published and modified are unused parameters that are populated when generating a script from existing achievements.

type specifies the classification of the achievement. Valid values are:

value type
"" Standard (unflagged)
"missable" Missable
"progression" Progression
"win_condition" Win condition

set specifies the unique identifier of the achievement set the achievement should be partitioned into.

Example

function current_board() => byte(0x0088)
function current_player() => byte(0x008C)
function trigger_win_game() => current_board() == 0x8B && current_player() == 0

achievement(
    title = "Score!", description = "Win a game with at least 600 points", points = 25,
    trigger = trigger_win_game() && byte(0x0573) >= 0xF6 // 0x0573 is hundreds place of score
)

First, a couple of helper functions are defined to make the code easier to read. Because all functions are inlined and evaluated on use, this expands to:

trigger = byte(0x0088) == 0x8B && byte(0x008C) == 0 && byte(0x0573) >= 0xF6

achievement_set(title, type="BONUS", id=0, game_id=0)

Defines a new achievement set (subset) with the specified title.

type defines how the subset is associated to the base set. Valid values are BONUS, SPECIALTY, and EXCLUSIVE.

id is the achievement set id. This should match the set= parameter from the game's subset page.

game_id is the legacy game ID for subsets created before sets were merged into the base game.

The return value is the unique identifier of the set to be passed to the achievement/leaderboard functions. If id is provided, it will be returned, otherwise a local value will be generated.

Example

bonus_set = achievement_set("Bonus")
achievement("Impossible", "Complete the game without dying", 100, set=bonus_set,
    trigger = complete_game() && never(lives() < prev(lives))