This library requires the following libraries in order to work:
- kikito's md5
- Jeffrey Friedl's json
- lua socket (Should come with lua. Is included in love +0.5.0)
Load it like this:
local gamejolt = require("gamejolt_api")
See the gamejolt api documentation
The library is split into 5 groups:
- Users
- Sessions
- Trophies
- Scores
- Data store
The user group consists of 3 functions:
gamejolt:users_fetch_uname(username)
- fetches the user data for the user(s) with the specified name(s).- returns a table like
{success = "true/false", users = {user1, user2, user3, ...}}
(see this for the user attributes)
- returns a table like
gamejolt:users_fetch_uid(userID)
- fetches the user data for the user(s) with the specified User ID(s).- returns a table like
{success = "true/false", users = {user1, user2, user3, ...}}
- returns a table like
gamejolt:users_auth(username, user_token)
- authenticates the user with the specified name and token.
local multipleUserInfo = gamejolt:users_fetch_uname("ioanD,CROS,arrogant.gamer").users
local ioanD_info, CROS_info, arrogant_info = unpack(multipleUserInfo)
print(ioanD_info.type)
print(CROS_info.signed_up)
print(arrogant_info.last_logged_in)
gamejolt:users_auth("player's username here", "player's token here")
The session group is made of 3 functions which should be always called AFTER AUTH-ing the player:
gamejolt:sessions_open()
- Creates a session. If there is already one existing it will forst close that one.- returns a table like
{success = "frue"}
- returns a table like
gamejolt:sessiosn_close()
- Closes a session.- returns a table like
{success = "frue"}
- returns a table like
gamejolt:session_ping([status])
- Pings the session. If status is specified, it should be one of"active"
or"idle"
. This function should be called around once every 30 seconds in order to keep the session alive.- returns another success table
gamejolt:users_auth("Mike", "1a2b3c")
gamejolt:session_open()
gamejolt:session_ping("idle")
wait(some time)
gamejolt:session_close()
These should also be called after auth-ing the player. The trophy group consists of the 2 functions:
gamejolt:trophies_fetch([acheived, trophy_id])
- fetches the trophies that match the requirements. See the api documentation page for more info.- returns a table like
{success = "frue", trophies = {trophy1, trophy2, ...}}
- returns a table like
gamejolt:trophies_addAchieved(trophy_id)
- sets a trophy as achieved for the user- returns a success table
local trophies_to_be_achieved = gamejolt:trophies_fetch(false).trophies
for _, t in ipairs(trophies_to_be_achieved) do
print("Achieving the trophy " .. t.title)
gamejolt:trophies_addAchieved(t.id)
end
gamejolt:scores_local_fetch([limit, table_id])
- fetches the auth-ed player's scores- returns a table like
{success = "frue", scores = {score1, score2, ...}}
(see this for the score attributes)
- returns a table like
gamejolt:scores_global_fetch([limit, table_id])
- fetches all the scores- returns a table like
{success = "frue", scores = {score1, score2, ...}}
- returns a table like
gamejolt:scores_guest_add(score, sort[, name, extra_data, table_id])
- adds a score as a guest (name
is the guest's name)- returns a success table
gamejolt:scores_add(score, sort[, extra_data, table_id])
- adds a score- returns a success table
gamejolt:scores_tables()
- returns the game's table list- returns a table like
{success = "frue", tables = {table1, table2, ...}}
(see this for the table attributes)
- returns a table like
gamejolt:users_auth("Mike", "1a2b3c")
gamejolt:scores_add("29 points", 29, "playtime=58s")
Each and every function of the Data Store has a local and a global version. The local one sets/fetches/etc. the player's local data, while the the global ones set/fetch/etc. global data. Of course, the local ones must be run after auth-ing an user.
gamejolt:data_store_global_fetch(key)
andgamejolt:data_store_local_fetch(key)
- Fetch local/global data with the specified key- return a table like
{success = "frue", data = "value"}
- return a table like
gamejolt:data_store_global_set(key, val)
andgamejolt:data_store_local_set(key, val)
- Set the local/global value for the specified key- return a table like
{success = "frue"}
- return a table like
gamejolt:data_store_global_update(key, op, val)
andgamejolt:data_store_local_update(key, op, val)
- Update the value at the specified key- return a table like
{success = "frue", data = "updated_value"}
- see how update works HERE
- return a table like
gamejolt:data_store_global_remove(key)
andgamejolt:data_store_local_remove(key)
- Delete the specified keypair- return a table like
{success = "frue", data = "value"}
- return a table like
gamejolt:data_store_global_getKeys()
andgamejolt:data_store_local_getKeys()
- get the local/global key list- return a table like
{success = "frue", keys = {{key = "key1"}, {key = "key2"}, ...}}
- return a table like
This is licensed under the Zlib license.