PlayDeck is a Telegram-native gaming marketplace that empowers game developers to showcase their games on one of the fastest-growing social platforms. With PlayDeck toolkit solutions, you can launch Web2 and Web3 games on Telegram and use all the benefits of social and referral mechanics to boost traffic and revenue.
Official Integration Guide(JS)
You can use the playdeck extension in your own project by adding this project as a Defold library dependency. Open your game.project file and in the dependencies field under project add:
https://github.com/d954mas/defold-playdeck/archive/refs/tags/1.0.1.zip
-
Look at official integration guide Official Integration Guide(JS)
-
Loding message will be send automatically.
// We auto-report progress based on the engine loading, if your game needs additional time to load assets,
// you can comment this out and report progress manually so the game does not start before it's ready.
Progress.addListener(val => {
window.parent.window.postMessage({ playdeck: { method: "loading", value: val } }, "*");
});
- When your game is loaded register callback
playdeck.register_callback(function(self, data)
pprint(data) -- log received data
if data.method == "loaded" then
elseif data.method == "getData" then
elseif data.method == "play" then
elseif (data.method == "rewardedAd") then
elseif (data.method == "errAd") then
elseif (data.method == "skipAd") then
elseif (data.method == "notFoundAd") then
elseif (data.method == "startAd") then
...
end)
For details look in Official Integration Guide(JS)
- Register Callback
playdeck.register_callback(function(self, data)
pprint(data) -- log received data
...
- Loaiding
Loading is send autocaticaly. If you need you can remove Progress.addListener from playdeck\manifests\web\engine_template.html and send progress manualy
playdeck.loading(progress)
- GetUserProfile
playdeck.get_user_profile()
--callback
if data.method == "getUserProfile" then
print(data.value)
end
- GetData/SetData
playdeck.get_data("storage")
playdeck.set_data("storage", json.encode(lua_table)) --string
playdeck.set_data("score", 100) --number
playdeck.set_data("is_happy", true) --boolean
--callback
if data.method == "getData" then
if data.value.data then
local lua_table = JSON.decode(data.value.data)
else
print("no data")
end
end
- CustomShare.
playdeck.custom_share(lua_table)
- GetShareLink.
playdeck.get_share_link(lua_table)
--callback
if data.method == "getShareLink" then
print(data.value)
end
- OpenTelegramLink.
playdeck.open_telegram_link(url)
- GetPlaydeckState.
playdeck.get_playdeck_state()
--callback
if data.method == "getPlaydeckState" then
local isPlayDeckOpened = playdeck.value
end
- GameEnd.
playdeck.game_end()
- SendGameProgress.
playdeck.send_game_progress(lua_table)
- SendAnalyticNewSession.
playdeck.send_analytic_new_session()
- SendAnalytics.
playdeck.send_analytics(lua_table)
- RequestPayment.
playdeck.request_payment(lua_table)
--callback
if data.method == "requestPayment" then
pprint(data.value) -- { url: 'https://t.me/$XIVLvBpfOEsBBwAARs....' } // payment link
--How to open links is described in the chapter Sharing and opening links.
playdeck.open_telegram_link(data.value.url)
elseif (data.method == 'invoiceClosed') {
pprint(playdeck.value) -- { status: 'paid' | 'cancelled' | 'failed' | 'pending' }
end
- GetPaymentInfo.
playdeck.get_payment_info(lua_table)
--callback
if data.method == "getPaymentInfo" then
pprint(data.value) -- { status: 'paid' | 'cancelled' | 'failed' | 'pending' }
end
- GetToken.
playdeck.get_token()
--callback
if data.method == "getToken" then
pprint(data.value) -- token { token: '123456789...' }
end
- ShowAd.
playdeck.show_ad()
--callback
if data.method == "startAd" then
pprint(data.value) --user has been started watching ad
elseif data.method == "rewardedAd" then
pprint(data.value) --user has been watched ad
elseif data.method == "errAd" then
pprint(data.value) --something went wrong at advert provider
elseif data.method == "skipAd" then
pprint(data.value) --user has been skip ad
elseif data.method == "notFoundAd" then
pprint(data.value) --advert provider doesn't return any ad
end