You can use this extension by adding this project as a Defold library dependency. Open you game.project file and in the dependencies field under project add:
https://github.com/miniclip/mci-defold/archive/master.zip
Or point to the ZIP file of specific release.
In the index.html of you project include the mcinstant.js script.
This extension wraps the MCInstant SDK in a Lua interface.
Initialize the MCInstant SDK.
PARAMETERS
config(string) - JSON encoded object containing sdk configuration (refer to the MCInstant Configuration Options)callback(function) - Function to call when the SDK is initialized
Retrieve the list of existing challenges
PARAMETERS
callback(function) - Function to call with the list of challenges
The callback function is expected to accept the following values:
self(userdata) - Script self referencechallenges(string) - JSON encoded array of challenge information
Get the challenge information of a specific challenge
PARAMETERS
challenge_id(string) - Id of the challenge to fetchcallback(function) - Function to call with the challenge information
The callback function is expected to accept the following values:
self(userdata) - Script self referencesuccess(boolean) - Indicates if found the challenge or notchallenges(string) - JSON encoded object with the challenge information (refer to the Challenge Class accessors)
Create a new challenge
PARAMETERS
score(integer) - The score of the current playerduration(integer) - For how many seconds the challenge should be runcallback(function) - Function to call when the challenge has been created
The callback function is expected to accept the following values:
self(userdata) - Script self referencesuccess(boolean) - Indicates if the operation was successful or not
Updates the score of the current user for a specific challenge
PARAMETERS
challenge_id(integer) - Id of the challenge to updatescore(integer) - The new score of the usercallback(function) - Function to call when the score has been updated
The callback function is expected to accept the following values:
self(userdata) - Script self referencesuccess(boolean) - Indicates if the operation was successful or not
Get the user wallet info
PARAMETERS
callback(function) - Function to call with the wallet information
The callback function is expected to accept the following values:
self(userdata) - Script self referencebalance(string) - JSON encoded array with the balance for each type of currency
Subscribe to an SDK event
PARAMETERS
event_name(string) - Name of the event to subscribe tocallback(function) - Function to call when the event is triggered
The callback function is expected to accept the following values:
self(userdata) - Script self referencepayload(string) - JSON encoded array with the event payload