Skip to content

Wortal SDK for Defold


Add Wortal SDK as a Defold library dependency

How to Use


API Reference

Interstitial ads can be shown at various points in the game such as a level end, restart or a timed interval in games with longer levels.

-- Player reached the next level.
wortal.ads_show_interstitial("next", "NextLevel", pause_game, resume_game)

-- Player paused the game.
wortal.ads_show_interstitial("pause", "PausedGame", pause_game, resume_game)

-- Player opened the IAP shop.
wortal.ads_show_interstitial("browse", "BrowseShop", pause_audio, resume_audio)

Rewarded ads can be shown too. These are longer, optional ads that the player can earn a reward for watching. The player must be notified of the ad and give permission to show before it can be shown.

-- This example shows the game flow independent of the outcome of the ad.
-- Ex: Player gets bonus coins for watching the ad, but the game continues regardless of the outcome.
wortal.ads_show_rewarded("BonusCoins", pause_game, resume_game, skip_bonus, add_bonus_coins)

-- This example shows the game flow depending on the outcome of the ad.
-- Ex: Player dies and can revive by watching an ad, but if they skip the ad they lose the level.
wortal.ads_show_rewarded("ReviveAndContinue", pause_audio, resume_audio, end_game, continue_game)

NOTE: Players should only be rewarded in the adViewed callback.


API Reference

The Analytics API can be used to track game events that can help better understand how players are interacting with the game. This data will be available for viewing in the Wortal dashboard.

-- Logs the start of the level.
wortal.analytics_log_level_start("Level 3")

-- Logs the end of the level. Will track the time spent playing the level if the name matches
-- the name of the last logLevelStart() call.
wortal.analytics_log_level_end("Level 3", "100", 1)

-- Logs a choice the player made in the game. This can be useful for balancing the game
-- and seeing what content your players interact with the most.
wortal.analytics_log_game_choice("Character", "Blue")


API Reference

The Context API is used to connect players and allow them to interact in the game session, share their content and send messages to each other.

-- Invite a friend to play the game.
local payload = {
    image = 'data:base64image',
    text = 'Invite text',
    cta = 'Play',
    data = { exampleData: 'yourData' },

wortal.context_invite(json.encode(payload), function(self, success, error)
    popup.success_check(success, "Success!", "Error")

-- Share your game activity with friends.
local payload = {
    image = 'data:base64image',
    text = 'Share text',
    cta = 'Play',
    data = { exampleData: 'yourData' },

wortal.context_share(json.encode(payload), function(self, shareResult, error)
    popup.success_check(shareResult, shareResult, "Error")

In-App Purchases

API Reference

The In-App Purchases (IAP) API is used to provide an interface for in-game transactions on the platforms. This process will differ based on what platform the game is being played on, but the API remains the same.

-- Get the catalog of products the player can purchase.
wortal.iap_get_catalog(function(self, catalog, error)
    popup.success_check(catalog, prettify(json.decode(catalog)), "Catalog failed")

-- Purchase a product.
local purchaseConfig = {
    productID = ""

wortal.iap_make_purchase(json.encode(purchaseConfig), function(self, purchase, error)
    popup.success_check(purchase, prettify(json.decode(purchase)), "Purchase failed")


API Reference

The Leaderboard API gives the game access to the platform's leaderboard functionality. This is where you can track player's scores and compare them to other players.

-- Get the top 10 entries on the global leaderboard.
wortal.leaderboard_get_entries("global", 10, 0, function(self, entries, error)
    popup.success_check(entries, prettify(json.decode(entries)), "Leaderboard get entries failed")

-- Add the player's score to the leaderboard.
wortal.leaderboard_send_entry("global", 250, "details", function(self, entry, error)
    popup.success_check(entry, prettify(json.decode(entry)), "Leaderboard add failed")


API Reference

The Notifications API is used to send notifications to the player. These can be used to notify the player of an event in the game or to remind them to come back and play.

-- Schedule a notification to send to the player.
local payload = {
    title = "Your energy is full!",
    body = "Come back and play again.",
    mediaURL: "",
    label: "resources-full",
    scheduleInterval: 300 

wortal.notifications_schedule(json.encode(payload), function(self, result, error)
    popup.success_check(result, prettify(json.decode(result)), "Notification schedule failed")

-- Cancel a scheduled notification.
wortal.notifications_cancel("notification-123", function(self, success, error)


API Reference

You can find details about the current player via the Player API.

-- Get the player's name.
local name = wortal.player_get_name()

-- Get a list of the player's friends who have also played this game.
local payload = {
    filter = "ALL",
    size = 20,
    hoursSinceInvitation = 4,

wortal.player_get_connected_players(json.encode(payload), function(self, players, error)
    popup.success_check(players, prettify(json.decode(players)), "Error")


API Reference

Details about the current session can be accessed in the Session API.

-- Get the entry point of where the game started from.
wortal.session_get_entry_point(function(self, entryPoint, error)
    popup.success_check(entryPoint, entryPoint, "Error")


API Reference

The Tournament API is used to create and manage tournaments for your game.

-- Create a tournament.
local payload = {
    initialScore: 100,
    config: {
        title: "Level 1 Tournament",
    data: {
        level: 1,

wortal.tournament_create(json.encode(payload)), function(self, tournament, error)
    popup.success_check(tournament, prettify(json.decode(tournament)), "Error")

-- Post a score to a tournament.
wortal.tournament_post_score(200), function(self, success, error)
    popup.success_check(success, "Success!", "Error")