[Code Library] Modded Achievements v0.1.1

Discuss and distribute tools and methods for modding.
Lemonymous
Posts: 94
Joined: Fri Mar 09, 2018 3:29 am

[Code Library] Modded Achievements v0.1.1

Postby Lemonymous » Thu May 09, 2019 9:52 pm

Modded Achievements v0.1.1
    This library attempts to make it an easy task to add achievements to any mod, and have them all be displayed neatly in the same window without conflict.

    Example Mod - a working mod (using achievements v0.1.0) providing examples on how to use library.

How to add to your mod
    Place the extracted folder into your mod so it looks like this:
    /ITB/mods/.../scripts/achievements/

How to use
    Request library:

    Code: Select all

    local achvApi = require(self.scriptPath .."achievements/api")

    Must be requested at least once at init, and can then be requested and used at any time later in other files.


Most likely to be used functions: (see achievements/api for more functions)

    Code: Select all

    achvApi:AddChievo(chievo)
    =========================
    adds an achievement for your mod.
    chievo is a table with the following fields:


    field     | type   | description
    ----------+--------+---------------------------------------------------------
    id        | string | identifier within your mod.
    name      | string | display title.
    tip       | string | tooltip text. (see example mod)
    img       | string | path to image.
    objective | table  | optional field for multipart chievos. (see example mod)
    ----------+--------+---------------------------------------------------------

    achvApi:TriggerChievo(chievoId, objectives)
    ===========================================
    modifies an achievement's progress.
    objectives = nil -> completed
    objectives = true -> completed
    objectives = false -> incomplete
    objective is a table -> sets progress according to progress table.

    field       | type    | description
    ------------+---------+--------------------
    objectives  | boolean | true, false or nil
    objectives  | table   | progress table
    ------------+---------+--------------------