Use this skill when working with Playgama Bridge SDK for Defold games. Activates for game development involving cross-platform publishing, advertisements, in-app purchases, leaderboards, or social features using Playgama Bridge in Defold/Lua.
Provides Playgama Bridge SDK integration for Defold games, enabling cross-platform publishing across 20+ platforms. Activates when developing HTML5 games with ads, IAP, leaderboards, or social features in Defold/Lua projects.
/plugin marketplace add Playgama/bridge-claude-plugins/plugin install playgama-bridge-defold@playgama-bridge-claude-pluginsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Playgama Bridge is a cross-platform SDK for publishing Defold HTML5 games across 20+ platforms including Playgama, YouTube, Yandex Games, Crazy Games, Poki, Facebook, Telegram, Xiaomi, and more.
Source code.zip link from the GitHub releases pagegame.project file)Project -> Fetch Libraries to download the SDKplaygama-bridge-config.json file from the GitHub releasesres/web folder/res directory is added to Bundle Resources in project settingsWhen building for HTML5, select the appropriate index template provided by the SDK to ensure proper initialization.
Once the game is loaded, the plugin is already initialized. No additional actions are required. Access all modules through the bridge module:
local bridge = require("bridge.bridge")
bridge.platform
bridge.player
bridge.device
bridge.storage
bridge.advertisement
bridge.payments
bridge.leaderboards
bridge.social
bridge.achievements
After game is fully loaded, send the game ready message:
bridge.platform.send_message("game_ready")
local bridge = require("bridge.bridge")
-- Device type: 'mobile', 'tablet', 'desktop', 'tv'
local device_type = bridge.device.type()
local bridge = require("bridge.bridge")
-- Platform ID: 'playgama', 'vk', 'yandex', 'crazy_games', etc.
local platform_id = bridge.platform.id()
-- User language (ISO 639-1): 'en', 'ru', etc.
local language = bridge.platform.language()
-- Top-level domain: 'com', 'ru', or nil
local tld = bridge.platform.tld()
-- URL payload (auxiliary information from game URL)
local payload = bridge.platform.payload()
local bridge = require("bridge.bridge")
function init(self)
bridge.platform.get_server_time(function (_, data)
print("Server time: ", data)
end, function ()
-- error
end)
end
bridge.platform.send_message("game_ready")
bridge.platform.send_message("gameplay_started")
bridge.platform.send_message("gameplay_stopped")
bridge.platform.send_message("in_game_loading_started")
bridge.platform.send_message("in_game_loading_stopped")
bridge.platform.send_message("player_got_achievement")
local bridge = require("bridge.bridge")
function init(self)
bridge.platform.on("audio_state_changed", function (_, is_enabled)
print("Is audio enabled: ", is_enabled)
-- Mute/unmute game audio based on is_enabled
end)
end
local bridge = require("bridge.bridge")
function init(self)
bridge.platform.on("pause_state_changed", function (_, is_paused)
print("Is paused: ", is_paused)
-- Pause/resume game based on is_paused
end)
end
local bridge = require("bridge.bridge")
-- Check authorization support
local is_auth_supported = bridge.player.is_authorization_supported()
-- Check if player is authorized
local is_authorized = bridge.player.is_authorized()
-- Player ID (nil if not authorized)
local player_id = bridge.player.id()
-- Player name (nil if unavailable)
local player_name = bridge.player.name()
-- Player photos (array of URLs sorted by resolution, or empty array)
local photos = bridge.player.photos()
-- Platform-specific player data
local extra = bridge.player.extra()
local bridge = require("bridge.bridge")
function init(self)
local options = {}
bridge.player.authorize(
options,
function ()
-- success
print("Authorized: ", bridge.player.id())
end,
function ()
-- error
print("Authorization failed")
end)
end
local bridge = require("bridge.bridge")
function init(self)
bridge.storage.get(
{ "coins", "level" },
function (_, data)
if data.coins then
print("Coins: ", data.coins)
end
if data.level then
print("Level: ", data.level)
end
end,
function ()
-- error
end
)
end
local bridge = require("bridge.bridge")
function init(self)
bridge.storage.set(
{ coins = 42, level = "dungeon" },
function (_)
-- success
print("Data saved")
end,
function (_)
-- error
end
)
end
local bridge = require("bridge.bridge")
function init(self)
bridge.storage.delete(
{ "coins", "level" },
function ()
-- success
end,
function ()
-- error
end
)
end
local bridge = require("bridge.bridge")
-- Check support
local is_supported = bridge.advertisement.is_banner_supported()
-- Show banner
function init(self)
local position = "bottom" -- 'top' or 'bottom', default = 'bottom'
local placement = "menu" -- optional
bridge.advertisement.show_banner(position, placement)
end
-- Hide banner
bridge.advertisement.hide_banner()
local bridge = require("bridge.bridge")
function init(self)
bridge.advertisement.on("banner_state_changed", function (_, state)
-- States: 'loading', 'shown', 'hidden', 'failed'
print("Banner state changed: ", state)
end)
end
local bridge = require("bridge.bridge")
-- Check support
local is_supported = bridge.advertisement.is_interstitial_supported()
-- Get current state: 'loading', 'opened', 'closed', 'failed'
local state = bridge.advertisement.interstitial_state()
-- Get/set minimum delay between ads (default: 60 seconds)
local delay = bridge.advertisement.minimum_delay_between_interstitial()
bridge.advertisement.set_minimum_delay_between_interstitial(30)
-- Show interstitial
local placement = "level_complete" -- optional
bridge.advertisement.show_interstitial(placement)
local bridge = require("bridge.bridge")
function init(self)
bridge.advertisement.on("interstitial_state_changed", function (_, state)
-- States: 'loading', 'opened', 'closed', 'failed'
print("Interstitial state changed: ", state)
if state == "opened" then
-- Your logic
elseif state == "closed" or state == "failed" then
-- Your logic
end
end)
end
Note: Do not call show_interstitial() at game start. On platforms where this is allowed, ads will be shown automatically.
local bridge = require("bridge.bridge")
-- Check support
local is_supported = bridge.advertisement.is_rewarded_supported()
-- Get current state: 'loading', 'opened', 'closed', 'rewarded', 'failed'
local state = bridge.advertisement.rewarded_state()
-- Get current placement
local placement = bridge.advertisement.rewarded_placement()
-- Show rewarded ad
local placement = "double_coins" -- optional
bridge.advertisement.show_rewarded(placement)
local bridge = require("bridge.bridge")
function init(self)
bridge.advertisement.on("rewarded_state_changed", function (_, state)
-- States: 'loading', 'opened', 'closed', 'rewarded', 'failed'
print("Rewarded state changed: ", state)
if state == "opened" then
-- Your logic
elseif state == "rewarded" then
-- Grant reward to player
elseif state == "closed" or state == "failed" then
-- Your logic
end
end)
end
Important: Only grant rewards when state is rewarded.
local bridge = require("bridge.bridge")
-- Check support
local is_supported = bridge.payments.is_supported()
local bridge = require("bridge.bridge")
function init(self)
local id = "coins_100"
bridge.payments.purchase(id, function (_, purchase)
-- success
print("Purchased: ", purchase.id)
end, function (_, error)
-- error
end)
end
local bridge = require("bridge.bridge")
function init(self)
local id = "coins_100"
bridge.payments.consume_purchase(id, function (_, purchase)
-- success
end, function ()
-- error
end)
end
local bridge = require("bridge.bridge")
function init(self)
bridge.payments.get_catalog(function (_, catalog)
for key, value in pairs(catalog) do
local id = value.id
local price = value.price
local priceCurrencyCode = value.priceCurrencyCode
local priceValue = value.priceValue
print("Product: ", id, " Price: ", price)
end
end, function ()
-- error
end)
end
local bridge = require("bridge.bridge")
function init(self)
bridge.payments.get_purchases(function (_, purchases)
for key, value in pairs(purchases) do
local id = value.id
print("Owned: ", id)
end
end, function ()
-- error
end)
end
local bridge = require("bridge.bridge")
-- Leaderboard type: 'not_available', 'in_game', 'native', 'native_popup'
local leaderboard_type = bridge.leaderboards.type
local bridge = require("bridge.bridge")
function init(self)
local leaderboardId = "high_score"
local score = 1000
bridge.leaderboards.set_score(leaderboardId, score, function ()
-- success
end, function ()
-- error
end)
end
Works only when bridge.leaderboards.type equals in_game:
local bridge = require("bridge.bridge")
function init(self)
local leaderboardId = "high_score"
local options = {}
bridge.leaderboards.get_entries(options, function (_, data)
for key, value in pairs(data) do
print("ID: ", value.id)
print("Name: ", value.name)
print("Photo: ", value.photo)
print("Score: ", value.score)
print("Rank: ", value.rank)
end
end, function ()
-- error
end)
end
Works only when bridge.leaderboards.type equals native_popup:
local bridge = require("bridge.bridge")
function init(self)
local leaderboardId = "high_score"
bridge.leaderboards.show_native_popup(leaderboardId, function ()
-- success
end, function ()
-- error
end)
end
local bridge = require("bridge.bridge")
function init(self)
-- Check support
local is_supported = bridge.social.is_share_supported()
local options = {
vk = {
link = "YOUR_LINK"
},
facebook = {
image = "A base64 encoded image to be shared",
text = "A text message to be shared."
},
msn = {
title = "A title to display",
image = "A base64 encoded image or image URL to be shared",
text = "A text message to be shared."
}
}
bridge.social.share(options, function ()
-- success
end, function ()
-- error
end)
end
local bridge = require("bridge.bridge")
function init(self)
local options = {
vk = {
text = "Hello World!"
},
facebook = {
image = "A base64 encoded image to be shared",
text = "A text message"
}
}
bridge.social.invite_friends(options, function ()
-- success
end, function ()
-- error
end)
end
local bridge = require("bridge.bridge")
function init(self)
local options = {
vk = {
groupId = "YOUR_GROUP_ID"
},
ok = {
groupId = "YOUR_GROUP_ID"
},
facebook = {
isPage = true
}
}
bridge.social.join_community(options, function ()
-- success
end, function ()
-- error
end)
end
local bridge = require("bridge.bridge")
function init(self)
local options = {
ok = {
media = {
{
type = "text",
text = "Hello World!"
},
{
type = "link",
url = "https://apiok.ru"
},
{
type = "poll",
question = "Do you like our game?",
answers = {
{ text = "Yes" },
{ text = "No" }
},
options = "SingleChoice,AnonymousVoting"
}
}
}
}
bridge.social.create_post(options, function ()
-- success
end, function ()
-- error
end)
end
bridge.social.add_to_favorites(function ()
-- success
end, function ()
-- error
end)
bridge.social.add_to_home_screen(function ()
-- success
end, function ()
-- error
end)
bridge.social.rate(function ()
-- success
end, function ()
-- error
end)
local bridge = require("bridge.bridge")
-- Check support
local is_supported = bridge.achievements.is_supported()
local is_get_list_supported = bridge.achievements.is_get_list_supported()
local is_native_popup_supported = bridge.achievements.is_native_popup_supported()
local bridge = require("bridge.bridge")
function init(self)
local options = {
y8 = {
achievement = "ACHIEVEMENT_NAME",
achievementkey = "ACHIEVEMENT_KEY"
},
lagged = {
achievement = "ACHIEVEMENT_ID"
}
}
bridge.achievements.unlock(options, function ()
-- success
end, function ()
-- error
end)
end
local bridge = require("bridge.bridge")
function init(self)
local options = {}
bridge.achievements.get_list(options, function (_, data)
for key, value in pairs(data) do
print("Achievement: ", value)
end
end, function ()
-- error
end)
end
local bridge = require("bridge.bridge")
function init(self)
local options = {}
bridge.achievements.show_native_popup(options, function ()
-- success
end, function ()
-- error
end)
end
bridge.platform.send_message("game_ready") when game is fully loadedaudio_state_changed and mute/unmute game audio accordinglypause_state_changed and pause/resume game accordinglyis_supported methods before using platform-specific featuresrewardedbridge.platform.id()show_interstitial() at game start - it will be shown automatically where allowed