-
Notifications
You must be signed in to change notification settings - Fork 0
GameJoltAPI
Plugin Version: 1.0
Inherits: HTTPRequest < Node < Object
A simple GameJolt API node.
Credits: Ackens, Piotr Rojewski, Deakcor, and IrønBrandon.
-
private_key: String
Your game's private key.
-
game_id: String
Your game's ID. This is public, just look at your game's URL and copy the numbers.
-
data_path: String(file export)
Optional path to a JSON file containing your game's private_key and game_id. Format:
{
"private_key":"<gamekey>",
"game_id":"<gameid>"
}Useful for open-source games, just add the file to your '.gitignore'.
If you want to make it extra secure, you can also add a [param "trophies"] key with either an Array of trophy IDs.
Look at detected_trophies for more info.
-
auto_batch: bool = true
Merge queued requests in one batch request.
-
auto_auth_in_ready: bool = false
Automatically calls the user_auto_auth() method during ready.
-
verbose: bool = false
Outputs detailed text. Should turn this off in release builds.
-
trophy_ids: PackedInt32Array
Contains trophies loaded from data_path.
-
queue: Array[Request]
The current queue of Requests.
-
current_request: Request
The currently active GameJolt request.
*Untested in Godot 4.
is_busy() -> bool
Returns true if the API has an open request.
get_username() -> String
Returns the username cache.
get_token() -> String
Returns the user token cache.
clear_user() -> void
Clears the username and user token cache.
time_fetch() -> void
Fetches the current time.
Request type is "/time/"
batch_request(requests: Array[Request], parallel: bool = true, break_on_error: bool = false) -> void
Sends multiple Requests as a batch request.
If parallel is true, all sub requests will be handled all at once instead of one at a time.
If all the requests are fetches and won't change anything, this should be true.
- *
user_auto_auth() -> void
Attempts to automatically authenticate the user with the URL of Web builds. Does nothing in regular builds.
When debugging, you can add this to the URL: ?gjapi_username=<yourusername>&gjapi_token=<yourtoken>
Request type is "/users/auth/"
user_auth(username: String, token: String) -> void
Attempts to authenticate a user with the given username and token.
NOTE: The username and token cache are updated here, not after authentication.
Request type is "/users/auth/"
user_fetch(username: String, id: int = 0) -> void
Fetches the info of the the username or user id.
Request type is "/users/"
user_friends_fetch() -> void
Fetches the currently cached user's friends list. Returns as an array of dictionaries: [code]{"friends": [{"friend_id": integer}, ...]}[/code]
Request type is "/friends/"
session_open() -> void
Opens a session (User must be authenticated).
Request type is "/sessions/open/"
session_ping() -> void
Pings an active session (User must be authenticated).
Request type is "/sessions/ping/"
session_close() -> void
Closes the active session (User must be authenticated).
Request type is "/sessions/close/"
session_check() -> void
Checks for an active session (User must be authenticated).
Request type is "/sessions/check/"
scores_fetch(global = false, guest: String = "", limit: int = 10, table_id = null, better_than = null, worse_than = null) -> void
Fetches an Array of scores for the cached user, a guest or globally.
Leave guest empty if you want global or cached user.
Request type is "/scores/"
- *
scores_add(score_string, sort_number, guest: String = "", table_id = null) -> void
Attempts to add a score to the cached user or guest.
Leave guest empty to use the cached user (User must be authenticated).
- *
scores_fetch_rank(sort, table_id = null) -> void
Returns the rank of a score on a table (scoreboard).
table_id of -1 means it will use the primary table
Returns rank (int): The rank of the score on the scoreboard.
Request type is "/scores/get-rank/"
- *
scores_fetch_tables() -> void
Fetches the list of high-score tables (scoreboards).
Request type is "/scores/tables/"
- *
trophy_fetch(trophy_ids: String, achieved: String = '') -> void
Fetches trophies.
If you want a specific trophy or set of trophies, pass them through trophy_ids as '123456,135792' each separated by commas.
If you want only achieved or unachieved trophies, pass achieved as 'true' or 'false'.
Returns: GameJolt Docs.
Request type is "/trophies/"
trophy_add_achieved(trophy_id: int) -> void
Unlocks the trophy with id trophy_id for the authenticated user. (User must be authenticated)
Request type is "/trophies/add-achieved/"
trophy_remove_achieved(trophy_id: int) -> void
Removes the trophy with id trophy_id from the authenticated user. (User must be authenticated)
NOTE: Only for debugging.
Request type is "/trophies/remove-achieved/"
- *
data_fetch(key: String, global: bool = true) -> void
Fetches data from the key of the user or of global.
Request type is "/data-store/".
- *
data_set(key: String, data: String, global: bool = true) -> void
Stores data in the cloud of the user or of global.
If global is true, this is a global key. If false, it will use the cached user.
Request type is "/data-store/set/"
- *
data_update(key: String, operation: String, value: Variant, global: bool = true) -> void
Updates data in the key of the user or of global using an operation.
operation can be "append", "prepend", "divide", "multiply", "add", or "subtract".
For example: data_update("login_count", "add", 1, false) will increase the cached user's "login_count" key by 1.
Request type is "/data-store/update/"
- *
data_remove(key: String, global: bool = true) -> void
Removes the key of the user or of global.
Request type is "/data-store/remove/"
- *
data_fetch_keys(pattern = null, global: bool = true) -> void
Fetches all the keys of either a user's or the global's cloud.
Setting the pattern will only fetch keys with applicable key names.
Request type is "/data-store/get-keys/"