diff --git a/extensions/community/ZokoGames.json b/extensions/community/ZokoGames.json new file mode 100644 index 000000000..ece3aa314 --- /dev/null +++ b/extensions/community/ZokoGames.json @@ -0,0 +1,7654 @@ +{ + "author": "ZokoGames", + "category": "Ads", + "extensionNamespace": "", + "fullName": "ZokoGames", + "gdevelopVersion": "", + "helpPath": "https://zokogames.com/docs/engines/gdevelop", + "iconUrl": "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHJlY3QgeD0iMiIgeT0iMiIgd2lkdGg9IjIwIiBoZWlnaHQ9IjIwIiByeD0iNSIgZmlsbD0iIzViM2RmNSIvPjxwYXRoIGQ9Ik03IDdoMTB2Mi4ybC02LjYgNS42SDE3VjE3SDd2LTIuMmw2LjYtNS42SDd6IiBmaWxsPSIjZmZmIi8+PC9zdmc+", + "name": "ZokoGames", + "previewIconUrl": "", + "shortDescription": "Ads, cloud save, leaderboards, store, achievements and rooms of the ZokoGames portal.", + "version": "1.8.1", + "description": "ZokoGames SDK 1.8.1 for GDevelop 5: every call of the ZokoGames JavaScript SDK as actions, conditions and expressions.\n\nStart with the action Initialize at the beginning of the first scene. Every request takes a tag: On request completed / On request failed (with the same tag) are true during the frame after the request ends, and every request is asynchronous, so actions placed after it can wait for it.\nAds pause and mute the game by themselves while they play. On localhost the SDK runs in its local mode (fake ads, a fake player, a local cloud save and a test store).", + "tags": [ + "ads", + "monetization", + "leaderboard", + "cloud save", + "store", + "multiplayer", + "zokogames" + ], + "authorIds": [], + "dependencies": [], + "globalVariables": [], + "sceneVariables": [], + "eventsFunctions": [ + { + "description": "Installs the ZokoGames runtime (src/runtime.js).", + "fullName": "", + "functionType": "Action", + "name": "onFirstSceneLoaded", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "// ZokoGames extension for GDevelop 5. Plugin version 1.8.1 (JavaScript SDK 1.8.1).", + "//", + "// This file is the code of the extension's \"onFirstSceneLoaded\" lifecycle function: tools/build-extension.mjs puts it in a", + "// JavaScript code event of ZokoGames.json. It runs once per game start, in the generated function", + "// `GDJSInlineCode(runtimeScene, eventsFunctionContext)`, and installs `gdjs._zokoGamesExtension`, the state every action, condition and", + "// expression of the extension reads. GDevelop runs the game on the page's main thread, so the SDK is called directly through", + "// the shared bridge core (between the zoko-core markers, copied from shared/zoko-core.js by tools/sync-core.mjs).", + "//", + "// Frame model. SDK answers and portal events arrive between frames (promises, postMessage). State (settings, user, room,", + "// saved data, results) is applied at once; the matching trigger (\"On request completed\", \"On ad finished\", ...) is queued and", + "// is true during the whole next frame (onScenePreEvents calls deliver(), onScenePostEvents afterEvents()). At most one trigger of each kind (and tag) is", + "// delivered per frame, so two room messages that arrive together are seen in two frames and none is lost.", + "{", + " const SDK_URL = \"https://sdk.zokogames.com/zokogames-sdk-v1.js\";", + " const SDK_VERSION = \"1.8.1\";", + " // The SDK's ERROR_CODES by module (expression ErrorCodes(module)) and ERROR_CODE_DESCRIPTIONS (expression ErrorDescription(code)).", + " const ERROR_CODES = {", + " ad: [\"adsDisabled\", \"unfilled\", \"adblock\", \"adCooldown\", \"other\"],", + " banner: [\"bannersDisabled\", \"unfilled\", \"missingId\", \"notVisible\", \"noAvailableSizes\", \"notCreated\", \"videoAdPlaying\", \"invalidSize\", \"bannerCooldown\", \"maxRefreshReached\", \"other\"],", + " user: [\"userNotAuthenticated\", \"userAlreadySignedIn\", \"userCancelled\", \"showAuthPromptInProgress\", \"showAccountLinkPromptInProgress\", \"rateLimited\", \"requestInProgress\", \"unexpectedError\"],", + " data: [\"dataLimitExceeded\", \"dataModuleDisabled\", \"other\"],", + " store: [\"catalogFetchFailed\", \"inventoryFetchFailed\", \"purchaseInitFailed\", \"purchaseInProgress\", \"purchaseCancelled\", \"consumeItemFailed\", \"itemNotConsumable\", \"itemNotInInventory\", \"insufficientItemQuantity\", \"userNotAuthenticated\", \"invalidArgument\", \"requestInProgress\", \"unexpectedError\", \"other\"],", + " room: [\"notInRoom\", \"notHost\", \"payloadTooLarge\", \"stateTooLarge\", \"unknownMember\", \"rateLimited\", \"roomUnavailable\", \"invalidArgument\"],", + " general: [\"sdkNotInitialized\", \"sdkNotLoaded\", \"sdkDisabled\", \"invalidArgument\", \"timeout\"]", + " };", + " const ERROR_DESCRIPTIONS = {", + " adCooldown: \"An ad was requested too soon after the previous one.\",", + " adblock: \"An ad blocker prevented the ad.\",", + " adsDisabled: \"Ads are switched off for this game or session.\",", + " bannerCooldown: \"The same banner container was refreshed within 30 seconds.\",", + " bannersDisabled: \"Banners are switched off for this game or session.\",", + " catalogFetchFailed: \"The store catalogue could not be loaded.\",", + " consumeItemFailed: \"The provider rejected the consume request.\",", + " dataLimitExceeded: \"Cloud save would exceed 1 MiB.\",", + " dataModuleDisabled: \"Cloud save is not enabled for this game.\",", + " insufficientItemQuantity: \"consumeItem asked for more than the player owns.\",", + " inventoryFetchFailed: \"The player inventory could not be loaded.\",", + " invalidArgument: \"An argument failed validation.\",", + " invalidSize: \"The banner size is not one of the supported sizes.\",", + " itemNotConsumable: \"consumeItem was used on a non-consumable item.\",", + " itemNotInInventory: \"consumeItem named an item the player does not own.\",", + " maxRefreshReached: \"The per-session banner refresh limit was reached.\",", + " missingId: \"A banner container id was empty.\",", + " noAvailableSizes: \"No responsive banner size fits the container.\",", + " notCreated: \"The banner container does not exist.\",", + " notHost: \"Only the room host can change the shared room state.\",", + " notInRoom: \"The player is not in a room; call game.updateRoom() first.\",", + " notVisible: \"The banner container is hidden or off screen.\",", + " other: \"Any other failure; read the message.\",", + " payloadTooLarge: \"A room message or state patch is larger than 8 KB.\",", + " purchaseCancelled: \"The player closed the checkout.\",", + " purchaseInProgress: \"A purchase is already running.\",", + " purchaseInitFailed: \"The checkout could not be opened (for example an unknown item id).\",", + " rateLimited: \"Friends were requested more often than every 250 ms.\",", + " requestInProgress: \"A request of the same kind is already running.\",", + " roomUnavailable: \"The room data channel needs a signed-in player and a portal with realtime enabled.\",", + " sdkDisabled: \"The SDK is disabled where the game is embedded.\",", + " sdkNotInitialized: \"Init has not finished yet.\",", + " sdkNotLoaded: \"The SDK script did not load (offline, blocked or missing script tag).\",", + " showAccountLinkPromptInProgress: \"The account-link prompt is already open.\",", + " showAuthPromptInProgress: \"The login prompt is already open.\",", + " stateTooLarge: \"The shared room state would exceed 64 KB.\",", + " timeout: \"The portal did not answer in time.\",", + " unexpectedError: \"The portal failed unexpectedly.\",", + " unfilled: \"No ad or banner was available.\",", + " unknownMember: \"The recipient of a room message is not in the room.\",", + " unknownMethod: \"The wrapper called a bridge method the page does not know (version mismatch).\",", + " userAlreadySignedIn: \"showAuthPrompt was called while signed in.\",", + " userCancelled: \"The player dismissed a prompt.\",", + " userNotAuthenticated: \"The call needs a signed-in player.\",", + " videoAdPlaying: \"A banner was requested while a video ad plays.\"", + " };", + "", + " // ", + " /*", + " * ZokoGames engine bridge core (ES5, no dependencies).", + " *", + " * Single source of truth. tools/sync-core.mjs copies this function between the", + " * `zoko-core` markers of every bridge file (Unity jslib, Godot shell, GameMaker,", + " * Defold). Do not edit the copies by hand.", + " *", + " * Wire protocol shared by those engines:", + " * call(method, args, onEvent) -> Promise (async methods)", + " * callSync(method, args) -> { ok, result } | { ok:false, error }", + " * setGlobalHandler(fn(name, data)) names: settingsChange, offlineChange, auth, joinRoom, achievementUnlocked,", + " * roomMessage, roomState, roomMembers, roomHost, roomError (SDK 1.3.0 game.room), roomLeft (SDK 1.7.0), screenshotRequest, mirrorError (SDK 1.4.0)", + " * SDK 1.4.0 calls: game.reportChat {report}; game.setScreenshotProvider {enabled} + the global event screenshotRequest, which the", + " * engine answers with game.answerScreenshot {dataUrl} (a data:image/... URL, or null when it cannot capture; the SDK waits 3 s);", + " * data.mirrorLocalStorage {keys?, prefix?, pattern?} (+ data.stopMirrorLocalStorage), failures arrive as the global event mirrorError.", + " * SDK 1.7.0: data.mirrorIndexedDB {databases?} resolves after the restore (+ data.stopMirrorIndexedDB); init snapshot carries gameId.", + " * Errors are always plain { code, message, containerId? } objects.", + " * Banner rectangles arrive as normalised { nx, ny, nw, nh } (0..1, top-left origin,", + " * relative to the game canvas) and are mapped to a fixed-position container
.", + " * Calls that show portal UI over the game (ad.requestAd, user.showAuthPrompt, user.showAccountLinkPrompt, store.buyItem) give", + " * keyboard focus back to the game frame and its canvas when they settle, so key presses reach the engine again.", + " */", + " function zokoCreateCore(root, getCanvas) {", + " var globalHandler = function () {};", + " var hooked = false;", + " var noop = function () {};", + "", + " function sdk() {", + " var z = root.ZokoGames;", + " return z && z.SDK ? z.SDK : null;", + " }", + " function need() {", + " var s = sdk();", + " if (!s) throw { code: 'sdkNotLoaded', message: 'The ZokoGames SDK script is not loaded' };", + " return s;", + " }", + " function plainError(e) {", + " if (e && typeof e.code === 'string') {", + " var o = { code: e.code, message: String(e.message || e.code) };", + " if (typeof e.containerId === 'string') o.containerId = e.containerId;", + " return o;", + " }", + " return { code: 'other', message: e && e.message ? String(e.message) : String(e) };", + " }", + " /** Portal overlays (ads, prompts, checkout) take keyboard focus; hand it back to this frame and the game canvas. */", + " function regainFocus() {", + " try {", + " if (typeof root.focus === 'function') root.focus();", + " var c = getCanvas && getCanvas();", + " if (c && typeof c.focus === 'function') {", + " if (!c.hasAttribute || !c.hasAttribute('tabindex')) c.setAttribute('tabindex', '-1');", + " c.focus({ preventScroll: true });", + " }", + " } catch (e) { /* focus is best effort */ }", + " }", + " function refocus(p) {", + " return p.then(function (v) { regainFocus(); return v; }, function (e) { regainFocus(); throw e; });", + " }", + " function bad(message) {", + " return { code: 'invalidArgument', message: message };", + " }", + " function snapshot(s) {", + " var out = {", + " environment: s.environment,", + " isQaTool: !!s.isQaTool,", + " settings: { disableChat: false, kidsMode: false, muteAudio: false },", + " systemInfo: null,", + " isUserAccountAvailable: false,", + " isInstantMultiplayer: false,", + " isOffline: false,", + " inviteParams: null,", + " storeAvailable: false,", + " gameId: '',", + " sdkVersion: s.version || (root.ZokoGames && root.ZokoGames.SDK_VERSION) || ''", + " };", + " if (s.environment === 'disabled') return out;", + " out.settings = s.game.settings;", + " out.systemInfo = s.user.systemInfo;", + " out.isUserAccountAvailable = s.user.isUserAccountAvailable;", + " out.isInstantMultiplayer = s.game.isInstantMultiplayer;", + " out.isOffline = !!s.game.isOffline;", + " out.inviteParams = s.game.inviteParams;", + " out.storeAvailable = !!(s.store && s.store.isAvailable);", + " // JS SDK 1.6.2+: the read-only game id the portal sends at init ('' on older SDKs and portals).", + " try { out.gameId = typeof s.game.gameId === 'string' ? s.game.gameId : ''; } catch (e) { out.gameId = ''; }", + " return out;", + " }", + " /** getPurchaseToken is the primary name; older SDK builds only have the deprecated getXsollaUserToken. */", + " function purchaseToken(s) {", + " if (s.store && typeof s.store.getPurchaseToken === 'function') return s.store.getPurchaseToken();", + " return s.user.getXsollaUserToken();", + " }", + " function hook(s) {", + " if (hooked || s.environment === 'disabled') return;", + " hooked = true;", + " s.game.addSettingsChangeListener(function (v) { globalHandler('settingsChange', v); });", + " // SDK 1.2.0+; older builds have no offline members and the flag stays false.", + " if (typeof s.game.addOfflineListener === 'function') s.game.addOfflineListener(function (v) { globalHandler('offlineChange', !!v); });", + " s.game.addJoinRoomListener(function (v) { globalHandler('joinRoom', v); });", + " s.user.addAuthListener(function (v) { globalHandler('auth', v); });", + " // Achievements module (SDK builds that have it); the event carries the achievement object.", + " if (s.achievements && typeof s.achievements.onUnlock === 'function') s.achievements.onUnlock(function (v) { globalHandler('achievementUnlocked', v); });", + " // Room data channel (SDK 1.3.0+). Events: roomMessage {data,direct,from,seq,ts}, roomState {state,change:{by?,keys,rev}},", + " // roomMembers [member], roomHost {hostId,isHost}, roomError {code,message}.", + " var r = s.game.room;", + " if (r && typeof r.onMessage === 'function') {", + " r.onMessage(function (m) { globalHandler('roomMessage', m); });", + " r.onState(function (st, change) { globalHandler('roomState', { state: st, change: change }); });", + " r.onMembers(function (m) { globalHandler('roomMembers', m); });", + " r.onHostChange(function (hostId, isHost) { globalHandler('roomHost', { hostId: hostId, isHost: !!isHost }); });", + " r.onError(function (e) { globalHandler('roomError', plainError(e)); });", + " // SDK 1.7.0+: the portal ended our membership without the game asking. roomLeft {reason, roomId?}.", + " if (typeof r.addLeftListener === 'function') r.addLeftListener(function (e) { globalHandler('roomLeft', { reason: e && e.reason, roomId: e && e.roomId }); });", + " }", + " }", + "", + " /* ---- banner containers ---- */", + " function place(id, rect) {", + " if (typeof id !== 'string' || id === '') throw { code: 'missingId', message: 'A container id is required' };", + " if (!rect || typeof rect.nx !== 'number') throw bad('A banner rectangle is required');", + " var doc = root.document;", + " var el = doc.getElementById(id);", + " if (!el) {", + " el = doc.createElement('div');", + " el.id = id;", + " el.setAttribute('data-zoko-banner', '1');", + " el.style.cssText = 'position:fixed;margin:0;padding:0;background:transparent;pointer-events:none;z-index:2147483000;';", + " doc.body.appendChild(el);", + " }", + " var c = getCanvas && getCanvas();", + " var b = c ? c.getBoundingClientRect() : { left: 0, top: 0, width: root.innerWidth, height: root.innerHeight };", + " el.style.left = b.left + rect.nx * b.width + 'px';", + " el.style.top = b.top + rect.ny * b.height + 'px';", + " el.style.width = rect.nw * b.width + 'px';", + " el.style.height = rect.nh * b.height + 'px';", + " return el;", + " }", + " function removeContainer(id) {", + " var el = root.document.getElementById(id);", + " if (el && el.getAttribute('data-zoko-banner')) el.parentNode.removeChild(el);", + " }", + " function hasElement(id) {", + " return typeof id === 'string' && id !== '' && !!root.document.getElementById(id);", + " }", + " /** A container this call created is removed again when the banner request fails, so no empty overlay stays behind. */", + " function dropOnFailure(id, fresh) {", + " return function (e) {", + " if (fresh) removeContainer(id);", + " throw e;", + " };", + " }", + " function removeAllContainers() {", + " var list = root.document.querySelectorAll('[data-zoko-banner]');", + " for (var i = 0; i < list.length; i++) list[i].parentNode.removeChild(list[i]);", + " }", + "", + " /* ---- SDK 1.4.0: screenshot provider and localStorage mirror ---- */", + " var shotStop = null;", + " var shotPending = null;", + " var mirrorStop = null;", + " function settleShot(v) {", + " var p = shotPending;", + " shotPending = null;", + " if (p) p(v);", + " }", + " function setScreenshotProvider(s, enabled) {", + " if (shotStop) { shotStop(); shotStop = null; settleShot(null); }", + " if (!enabled) return;", + " shotStop = s.game.onScreenshotRequest(function () {", + " settleShot(null);", + " return new Promise(function (resolve) {", + " shotPending = resolve;", + " globalHandler('screenshotRequest', null);", + " });", + " });", + " }", + " function stopMirror() {", + " if (mirrorStop) { mirrorStop(); mirrorStop = null; }", + " }", + " var idbStop = null;", + " function stopIdbMirror() {", + " if (idbStop) { idbStop(); idbStop = null; }", + " // The Unity template and the Godot shells start the mirror themselves and keep its stop function here.", + " if (typeof window.zokoStopMirrorIndexedDB === 'function') {", + " window.zokoStopMirrorIndexedDB();", + " window.zokoStopMirrorIndexedDB = null;", + " }", + " }", + "", + " function simple(mod, fn) {", + " return function (a, ev, s) { return s[mod][fn](); };", + " }", + "", + " function since180(mod, name) {", + " if (typeof mod[name] !== 'function') throw { code: 'other', message: name + ' needs ZokoGames SDK 1.8.0 or newer' };", + " return function () { return mod[name].apply(mod, arguments); };", + " }", + " function storeOf(s) {", + " if (!s.store) throw { code: 'other', message: 'This SDK build has no store module' };", + " return s.store;", + " }", + " function achOf(s) {", + " if (!s.achievements) throw { code: 'other', message: 'This SDK build has no achievements module' };", + " return s.achievements;", + " }", + " function roomOf(s) {", + " if (!s.game.room) throw { code: 'other', message: 'This SDK build has no game.room module (needs SDK 1.3.0)' };", + " return s.game.room;", + " }", + " function dataKey(a) {", + " if (typeof a.key !== 'string') throw bad('A text key is required');", + " return a.key;", + " }", + " /** True when an engine left the argument out (Lua nil, GML undefined, JSON null). */", + " function absent(v) {", + " return v === undefined || v === null;", + " }", + " function isArray(v) {", + " return Object.prototype.toString.call(v) === '[object Array]';", + " }", + " function emptyTable(v) {", + " if (!v || typeof v !== 'object') return false;", + " for (var k in v) if (Object.prototype.hasOwnProperty.call(v, k)) return false;", + " return true;", + " }", + " /**", + " * Store page options. A value the engine sends is passed on unchanged, so the SDK rejects a limit of 0 or below, above 50,", + " * a fraction or a negative offset with invalidArgument (until 1.6.2 such a value was dropped and the default page came back).", + " */", + " function pageOf(a) {", + " var p = {};", + " if (!absent(a.limit)) p.limit = a.limit;", + " if (!absent(a.offset)) p.offset = a.offset;", + " return p;", + " }", + "", + " /* ---- async methods ---- */", + " var T = {", + " 'init': function (a, ev) {", + " var s = need();", + " return s.init().then(function () { hook(s); return snapshot(s); });", + " },", + " 'ad.requestAd': function (a, ev, s) {", + " return refocus(s.ad.requestAd(a.type, {", + " adStarted: function () { ev('adStarted', null); },", + " adFinished: function () { regainFocus(); ev('adFinished', null); },", + " adError: function (e) { regainFocus(); ev('adError', plainError(e)); }", + " })).then(noop);", + " },", + " 'ad.hasAdblock': simple('ad', 'hasAdblock'),", + " 'banner.requestBanner': function (a, ev, s) {", + " var fresh = !hasElement(a.id);", + " place(a.id, a.rect);", + " return s.banner.requestBanner({ id: a.id, width: a.width, height: a.height }).then(noop, dropOnFailure(a.id, fresh));", + " },", + " 'banner.requestResponsiveBanner': function (a, ev, s) {", + " var fresh = !hasElement(a.id);", + " place(a.id, a.rect);", + " return s.banner.requestResponsiveBanner(a.id).then(noop, dropOnFailure(a.id, fresh));", + " },", + " 'banner.clearBanner': function (a, ev, s) {", + " return s.banner.clearBanner(a.id).then(function () { removeContainer(a.id); });", + " },", + " 'banner.clearAllBanners': function (a, ev, s) {", + " return s.banner.clearAllBanners().then(removeAllContainers);", + " },", + " // SDK 1.8.0: hide / show every banner without clearing it (the containers stay where they are).", + " 'banner.hideAllBanners': function (a, ev, s) { return since180(s.banner, 'hideAllBanners')(); },", + " 'banner.showAllBanners': function (a, ev, s) { return since180(s.banner, 'showAllBanners')(); },", + " 'game.gameplayStart': simple('game', 'gameplayStart'),", + " 'game.gameplayStop': simple('game', 'gameplayStop'),", + " 'game.loadingStart': simple('game', 'loadingStart'),", + " 'game.loadingStop': simple('game', 'loadingStop'),", + " 'game.loadingProgress': function (a, ev, s) { return s.game.loadingProgress(a.percentage); },", + " 'game.happytime': simple('game', 'happytime'),", + " 'game.leftRoom': simple('game', 'leftRoom'),", + " 'game.reportGameCompletedPercentage': function (a, ev, s) { return s.game.reportGameCompletedPercentage(a.percentage); },", + " 'game.setGameContext': function (a, ev, s) { return s.game.setGameContext(a.context); },", + " 'game.clearGameContext': simple('game', 'clearGameContext'),", + " 'game.showInviteButton': function (a, ev, s) { return s.game.showInviteButton(a.params); },", + " 'game.hideInviteButton': simple('game', 'hideInviteButton'),", + " 'game.reportChat': function (a, ev, s) { return s.game.reportChat(a.report).then(noop); },", + " 'game.updateRoom': function (a, ev, s) { return s.game.updateRoom(a.update); },", + " 'game.inviteLink': function (a, ev, s) { return s.game.inviteLink(a.params); },", + " 'user.getUser': simple('user', 'getUser'),", + " 'user.listFriends': function (a, ev, s) { return s.user.listFriends({ page: a.page, size: a.size }); },", + " 'user.getUserToken': function (a, ev, s) {", + " // '' is the engines' \"default key\" value; anything else goes to the SDK, which rejects an unknown type.", + " return s.user.getUserToken(absent(a.signingKeyType) || a.signingKeyType === '' ? undefined : { signingKeyType: a.signingKeyType });", + " },", + " 'store.getPurchaseToken': function (a, ev, s) { return purchaseToken(s); },", + " 'user.getXsollaUserToken': function (a, ev, s) { return purchaseToken(s); },", + " 'user.showAuthPrompt': function (a, ev, s) { return refocus(s.user.showAuthPrompt()); },", + " 'user.showAccountLinkPrompt': function (a, ev, s) { return refocus(s.user.showAccountLinkPrompt()); },", + " 'user.submitScore': function (a, ev, s) {", + " return s.user.submitScore({ encryptedScore: a.encryptedScore, score: a.score });", + " },", + " // SDK 1.7.0: mirror IndexedDB databases into the cloud save; resolves once the restore finished (await it before the game", + " // reads its saves). Unity and Godot mount their file system at startup: their HTML shells call the SDK before the engine starts.", + " 'data.mirrorIndexedDB': function (a, ev, s) {", + " if (typeof s.data.mirrorIndexedDB !== 'function') throw { code: 'other', message: 'data.mirrorIndexedDB needs ZokoGames SDK 1.7.0 or newer' };", + " stopIdbMirror();", + " var o = { onError: function (e) { globalHandler('mirrorError', plainError(e)); } };", + " if (a.databases && a.databases.length) o.databases = a.databases;", + " return s.data.mirrorIndexedDB(o).then(function (stop) { idbStop = stop; return null; });", + " },", + " // SDK 1.8.0: seal a score with the board key; resolves the base64 payload for submitScore. earnedAt 0 / absent = a live run.", + " 'user.encryptScore': function (a, ev, s) {", + " return since180(s.user, 'encryptScore')(a.score, a.key, absent(a.earnedAt) || a.earnedAt === 0 ? undefined : { earnedAt: a.earnedAt });", + " },", + " // SDK 1.7.0: fire-and-forget; resolves with nothing.", + " 'analytics.track': function (a, ev, s) { s.analytics.track(a.name, absent(a.params) ? undefined : a.params); return Promise.resolve(); },", + " 'analytics.trackOrder': function (a, ev, s) { return s.analytics.trackOrder(a.provider, a.order); },", + " 'store.getCatalogItems': function (a, ev, s) { return storeOf(s).getCatalogItems(pageOf(a)); },", + " 'store.getPlayerInventory': function (a, ev, s) { return storeOf(s).getPlayerInventory(pageOf(a)); },", + " 'store.buyItem': function (a, ev, s) { return refocus(storeOf(s).buyItem(a.itemId)); },", + " 'store.consumeItem': function (a, ev, s) { return storeOf(s).consumeItem(a.sku, a.quantity).then(noop); },", + " 'room.send': function (a, ev, s) {", + " // No `to` (or the engines' '' default) sends to every other member; a `to` that is not a string fails like the SDK.", + " if (!absent(a.to) && typeof a.to !== 'string') throw bad('to must be a member id');", + " return roomOf(s).send(a.data, typeof a.to === 'string' && a.to !== '' ? { to: a.to } : undefined).then(noop);", + " },", + " 'room.setState': function (a, ev, s) {", + " // `remove` is a list of keys to delete (engines whose tables cannot hold null, such as Lua, send it next to `patch`).", + " var patch = a.patch;", + " var k, i;", + " // An empty Lua table arrives as {} or [] whichever it stands for, so an empty one counts as \"nothing\" in both places.", + " if (!absent(a.remove) && !emptyTable(a.remove)) {", + " // A string here used to be walked character by character, deleting one-letter keys.", + " if (!isArray(a.remove)) throw bad('remove must be an array of keys');", + " for (i = 0; i < a.remove.length; i++) if (typeof a.remove[i] !== 'string' && typeof a.remove[i] !== 'number') throw bad('remove must be an array of keys');", + " }", + " if (isArray(a.remove) && a.remove.length) {", + " if (!absent(a.patch) && !emptyTable(a.patch) && (typeof a.patch !== 'object' || isArray(a.patch))) throw bad('patch must be an object');", + " patch = {};", + " if (a.patch && typeof a.patch === 'object') for (k in a.patch) if (Object.prototype.hasOwnProperty.call(a.patch, k)) patch[k] = a.patch[k];", + " for (i = 0; i < a.remove.length; i++) patch[a.remove[i]] = null;", + " }", + " return roomOf(s).setState(patch).then(noop);", + " },", + " 'achievements.list': function (a, ev, s) { return achOf(s).list(); },", + " 'achievements.unlock': function (a, ev, s) { return achOf(s).unlock(a.key); }", + " };", + "", + " /* ---- synchronous methods ---- */", + " var S = {", + " 'game.getSettings': function (a, s) { return s.game.settings; },", + " 'game.isOffline': function (a, s) { return !!s.game.isOffline; },", + " 'game.getInviteParams': function (a, s) { return s.game.inviteParams; },", + " 'game.getInviteParam': function (a, s) { return s.game.getInviteParam(a.key); },", + " // The SDK turns any key into text, so a missing key (malformed argument JSON) would silently address the key \"undefined\".", + " 'data.getItem': function (a, s) { return s.data.getItem(dataKey(a)); },", + " 'data.setItem': function (a, s) {", + " if (a.value === undefined || a.value === null) throw bad('A value is required');", + " s.data.setItem(dataKey(a), a.value);", + " return null;", + " },", + " 'data.removeItem': function (a, s) { s.data.removeItem(dataKey(a)); return null; },", + " 'data.clear': function (a, s) { s.data.clear(); return null; },", + " 'game.setScreenshotProvider': function (a, s) { setScreenshotProvider(s, a.enabled !== false); return null; },", + " 'game.answerScreenshot': function (a, s) {", + " settleShot(typeof a.dataUrl === 'string' && /^data:image\\//i.test(a.dataUrl) ? a.dataUrl : null);", + " return null;", + " },", + " 'data.mirrorLocalStorage': function (a, s) {", + " stopMirror();", + " var o = { onError: function (e) { globalHandler('mirrorError', plainError(e)); } };", + " if (a.keys && a.keys.length) o.keys = a.keys;", + " else if (typeof a.pattern === 'string' && a.pattern !== '') {", + " try { o.keys = new RegExp(a.pattern); } catch (e) { throw bad('pattern is not a valid regular expression'); }", + " }", + " if (typeof a.prefix === 'string' && a.prefix !== '') o.prefix = a.prefix;", + " mirrorStop = s.data.mirrorLocalStorage(o);", + " return null;", + " },", + " 'data.stopMirrorLocalStorage': function (a, s) { stopMirror(); return null; },", + " 'data.stopMirrorIndexedDB': function (a, s) { stopIdbMirror(); return null; },", + " 'room.members': function (a, s) { return roomOf(s).members(); },", + " 'room.getState': function (a, s) { return roomOf(s).getState(); },", + " 'room.isHost': function (a, s) { return !!roomOf(s).isHost(); },", + " 'room.selfId': function (a, s) { return roomOf(s).selfId; },", + " 'store.isAvailable': function (a, s) { return !!(s.store && s.store.isAvailable); },", + " // Like the SDK: only a boolean (0/1, \"true\" or a missing flag used to be turned into one).", + " 'store.setSandbox': function (a, s) {", + " if (typeof a.sandbox !== 'boolean') throw bad('sandbox must be a boolean');", + " storeOf(s).setSandbox(a.sandbox);", + " return null;", + " }", + " };", + "", + " return {", + " setGlobalHandler: function (fn) { globalHandler = typeof fn === 'function' ? fn : noop; },", + " call: function (method, args, onEvent) {", + " try {", + " var s = need();", + " var f = T[method];", + " if (f) return Promise.resolve(f(args || {}, onEvent || noop, s)).then(function (v) { return v === undefined ? null : v; });", + " var g = S[method];", + " if (g) return Promise.resolve(g(args || {}, s));", + " return Promise.reject({ code: 'unknownMethod', message: 'Unknown bridge method ' + method });", + " } catch (e) {", + " return Promise.reject(plainError(e));", + " }", + " },", + " callSync: function (method, args) {", + " try {", + " var g = S[method];", + " if (!g) throw { code: 'unknownMethod', message: 'Unknown sync bridge method ' + method };", + " var v = g(args || {}, need());", + " return { ok: true, result: v === undefined ? null : v };", + " } catch (e) {", + " return { ok: false, error: plainError(e) };", + " }", + " },", + " errorOf: plainError", + " };", + " }", + " // ", + "", + " /** Text and numbers pass through, booleans become \"true\" / \"false\", objects and arrays become JSON, anything missing is \"\". */", + " const text = (v) => {", + " if (typeof v === \"string\") return v;", + " if (typeof v === \"number\" || typeof v === \"boolean\") return String(v);", + " if (v === undefined || v === null) return \"\";", + " return JSON.stringify(v);", + " };", + " const str = (v) => (typeof v === \"string\" ? v : \"\");", + " const num = (v, fallback) => (typeof v === \"number\" && isFinite(v) ? v : fallback);", + " /** A yes/no parameter arrives as a boolean in generated code; \"yes\" / 1 are accepted too. */", + " const yes = (v) => v === true || v === 1 || v === \"yes\" || v === \"true\";", + " const parseJson = (t) => {", + " try {", + " return JSON.parse(t);", + " } catch (err) {", + " return null; // badJson tells invalid text from an intended null", + " }", + " };", + " /** True when `t` is not empty and not valid JSON (an empty or \"null\" text is a deliberate null). */", + " const badJson = (t) => {", + " if (typeof t !== \"string\" || t.trim() === \"\" || t.trim() === \"null\") return false;", + " return parseJson(t) === null;", + " };", + " /** Text that is valid JSON becomes that value, anything else stays text. Numbers pass through. */", + " const looseJson = (v) => {", + " if (typeof v !== \"string\") return v;", + " try {", + " return JSON.parse(v);", + " } catch (err) {", + " return v;", + " }", + " };", + "", + " const createZoko = (game) => {", + " const Z = {", + " version: SDK_VERSION,", + " sdkUrl: SDK_URL,", + " game,", + " core: null,", + " errorCodes: ERROR_CODES,", + " errorDescriptions: ERROR_DESCRIPTIONS,", + " text,", + " str,", + " num,", + " yes,", + " parseJson,", + " badJson,", + " looseJson,", + " // init snapshot", + " initialized: false,", + " environment: \"disabled\",", + " isQaTool: false,", + " settings: { disableChat: false, kidsMode: false, muteAudio: false },", + " systemInfo: {},", + " accountAvailable: false,", + " instantMultiplayer: false,", + " offline: false,", + " inviteParams: null,", + " storeAvailable: false,", + " // results kept for the expressions", + " user: null,", + " token: \"\",", + " encryptedScore: \"\",", + " purchaseToken: \"\",", + " friends: null,", + " cache: new Map(),", + " catalog: [],", + " inventory: [],", + " purchasedItemId: \"\",", + " achievements: [],", + " lastAchievement: null,", + " lastUnlockReason: \"\",", + " roomState: {},", + " roomMembers: [],", + " roomHostId: \"\",", + " roomSelfId: \"\",", + " roomIsHost: false,", + " roomMessage: null,", + " roomChange: null,", + " roomError: null,", + " roomLeft: null,", + " mirrorError: null,", + " adPlaying: false,", + " // the request that the expressions ResultString, ErrorCode ... describe", + " ok: true,", + " tag: \"\",", + " result: null,", + " error: null,", + " // ads: automatic pause and mute (actions \"Pause the game during ads\", \"Mute the game during ads\")", + " pauseDuringAds: true,", + " muteDuringAds: true,", + " followMuteSetting: true,", + " pausedByAd: false,", + " pauseAfterEvents: false,", + " // triggers", + " queue: [],", + " frame: [],", + " shotPending: false,", + " shotTimer: 0", + " };", + "", + " let sdkReady = null;", + " /** Adds the SDK script tag once when the page does not have it (export templates do not need editing). */", + " Z.loadSdk = () => {", + " if (window.ZokoGames && window.ZokoGames.SDK) return Promise.resolve();", + " if (!sdkReady) {", + " sdkReady = new Promise((resolve) => {", + " const s = document.createElement(\"script\");", + " s.src = SDK_URL;", + " s.async = true;", + " s.onload = () => resolve();", + " s.onerror = () => {", + " sdkReady = null; // a later call may try again; this one answers sdkNotLoaded", + " resolve();", + " };", + " document.head.appendChild(s);", + " });", + " }", + " return sdkReady;", + " };", + "", + " Z.canvas = () => {", + " try {", + " const c = Z.game.getRenderer().getCanvas();", + " if (c) return c;", + " } catch (err) {", + " /* no renderer yet */", + " }", + " return document.querySelector(\"canvas\");", + " };", + "", + " /* ---- triggers ---- */", + " /** Queue a trigger for the next frame. `key` groups triggers of one kind; `onDeliver` runs when it becomes current. */", + " Z.push = (key, name, data, onDeliver) => {", + " Z.queue.push({ key, name, data, onDeliver });", + " };", + " /** onScenePreEvents: the queued triggers become this frame's (one per key; later ones wait for the next frame). */", + " Z.deliver = () => {", + " const seen = new Set();", + " const next = [];", + " const frame = [];", + " for (const it of Z.queue) {", + " if (seen.has(it.key)) next.push(it);", + " else {", + " seen.add(it.key);", + " frame.push(it);", + " }", + " }", + " Z.queue = next;", + " Z.frame = frame;", + " for (const it of frame) if (it.onDeliver) it.onDeliver();", + " };", + " /** The trigger `name` (with `tag` for request triggers) of this frame, or null. */", + " Z.fired = (name, tag) => {", + " for (const it of Z.frame) if (it.name === name && (tag === undefined || it.data.tag === tag)) return it;", + " return null;", + " };", + " const select = (rec) => {", + " Z.ok = rec.ok;", + " Z.tag = rec.tag;", + " Z.result = rec.ok ? rec.result : null;", + " Z.error = rec.ok ? null : rec.error;", + " };", + " Z.select = select;", + "", + " /* ---- audio and pause ---- */", + " const muteReasons = new Set();", + " let savedVolume = null;", + " /** Mute for one reason (ad, portal setting); the game is audible again when no reason is left. */", + " Z.setMute = (reason, on) => {", + " let sm = null;", + " try {", + " sm = Z.game.getSoundManager();", + " } catch (err) {", + " return;", + " }", + " if (!sm) return;", + " if (typeof sm.muteEverything === \"function\" && typeof sm.unmuteEverything === \"function\") {", + " if (on) sm.muteEverything(reason);", + " else sm.unmuteEverything(reason);", + " return;", + " }", + " // Older runtimes: global volume 0 while any reason is active, then the volume the game had.", + " if (on) muteReasons.add(reason);", + " else muteReasons.delete(reason);", + " if (muteReasons.size > 0 && savedVolume === null) {", + " savedVolume = sm.getGlobalVolume();", + " sm.setGlobalVolume(0);", + " } else if (muteReasons.size === 0 && savedVolume !== null) {", + " sm.setGlobalVolume(savedVolume);", + " savedVolume = null;", + " }", + " };", + " Z.applySettingsMute = () => {", + " Z.setMute(\"zokogames-settings\", Z.followMuteSetting && !!(Z.settings && Z.settings.muteAudio));", + " };", + " /**", + " * Ads: mute at once; pause after the events of the frame that delivers On ad started (so that trigger still runs), and", + " * resume as soon as the ad ends. Only a pause the extension made is undone.", + " */", + " const adPause = (on) => {", + " if (on) {", + " Z.pauseAfterEvents = Z.pauseDuringAds;", + " if (Z.muteDuringAds) Z.setMute(\"zokogames-ad\", true);", + " } else {", + " Z.pauseAfterEvents = false;", + " if (Z.pausedByAd) {", + " Z.pausedByAd = false;", + " Z.game.pause(false);", + " }", + " Z.setMute(\"zokogames-ad\", false);", + " }", + " };", + " /** onScenePostEvents. */", + " Z.afterEvents = () => {", + " if (!Z.pauseAfterEvents || Z.fired(\"adStarted\") === null) return;", + " Z.pauseAfterEvents = false;", + " const g = Z.game;", + " if (Z.adPlaying && !Z.pausedByAd && typeof g.pause === \"function\" && !(typeof g.isPaused === \"function\" && g.isPaused())) {", + " g.pause(true);", + " Z.pausedByAd = true;", + " }", + " };", + " /** `started` is false for an event of a request whose ad never started (refused while another ad plays). */", + " const onAdEvent = (name, data, started) => {", + " if (name === \"adStarted\") {", + " Z.adPlaying = true;", + " adPause(true);", + " Z.push(\"adStarted\", \"adStarted\", {});", + " } else if (name === \"adFinished\") {", + " if (started) {", + " Z.adPlaying = false;", + " adPause(false);", + " }", + " Z.push(\"adFinished\", \"adFinished\", {});", + " } else if (name === \"adError\") {", + " if (started) {", + " Z.adPlaying = false;", + " adPause(false);", + " }", + " Z.error = data;", + " Z.push(\"adError\", \"adError\", { error: data }, () => {", + " Z.error = data;", + " });", + " }", + " };", + "", + " /* ---- requests ---- */", + " /** Settle `tag`: state at once, the triggers On request completed / failed (+ On any request failed) on the next frame. */", + " Z.settle = (tag, res, apply, revert, adErr) => {", + " const rec = { tag, ok: !!res.ok, result: res.ok ? (res.result === undefined ? null : res.result) : null, error: res.ok ? null : res.error || { code: \"other\", message: \"\" } };", + " // An ad request that raised adError still completes; completing must not clear that error (LastErrorIs / ErrorCode).", + " const sel = (r) => {", + " select(r);", + " if (adErr && r.ok) Z.error = adErr;", + " };", + " sel(rec);", + " if (rec.ok && apply) apply(rec.result);", + " if (!rec.ok && revert) revert();", + " if (rec.ok) Z.push(`completed:${tag}`, \"completed\", rec, () => sel(rec));", + " else {", + " Z.push(`failed:${tag}`, \"failed\", rec, () => select(rec));", + " Z.push(\"anyFailed\", \"anyFailed\", rec);", + " }", + " };", + " /** Fail `tag` without calling the SDK (an argument the wrapper cannot pass on). */", + " Z.fail = (tag, code, message) => {", + " Z.settle(tag, { ok: false, error: { code, message } });", + " return Promise.resolve();", + " };", + " /** Run an SDK method through the bridge core and settle `tag`. Never rejects. */", + " Z.run = (tag, method, args, apply, revert) => {", + " let started = false;", + " let adErr = null;", + " const events = method === \"ad.requestAd\" ? (name, data) => {", + " if (name === \"adStarted\") started = true;", + " if (name === \"adError\") adErr = data;", + " onAdEvent(name, data, started);", + " } : undefined;", + " return Z.loadSdk()", + " .then(() => Z.core.call(method, args || {}, events))", + " .then((result) => ({ ok: true, result }), (err) => ({ ok: false, error: Z.core.errorOf(err) }))", + " .then((res) => Z.settle(tag, res, apply, revert, adErr));", + " };", + " /** Run `fn(sdk)` straight on the SDK (a call whose options the shared bridge core does not carry) and settle `tag`. Never rejects. */", + " Z.runSdk = (tag, fn) =>", + " Z.loadSdk()", + " .then(() => {", + " const z = window.ZokoGames;", + " if (!z || !z.SDK) throw { code: \"sdkNotLoaded\", message: \"The ZokoGames SDK script is not loaded\" };", + " return fn(z.SDK);", + " })", + " .then((result) => ({ ok: true, result }), (err) => ({ ok: false, error: Z.core.errorOf(err) }))", + " .then((res) => Z.settle(tag, res));", + " /** A synchronous SDK read; `fallback` when the SDK is missing, not initialised or refuses. */", + " Z.read = (method, args, fallback) => {", + " const r = Z.core.callSync(method, args || {});", + " return r.ok ? r.result : fallback;", + " };", + "", + " Z.applyInit = (r) => {", + " Z.environment = r.environment || \"disabled\";", + " Z.settings = r.settings || Z.settings;", + " Z.systemInfo = r.systemInfo || {};", + " Z.accountAvailable = !!r.isUserAccountAvailable;", + " Z.instantMultiplayer = !!r.isInstantMultiplayer;", + " Z.offline = !!r.isOffline;", + " Z.inviteParams = r.inviteParams || null;", + " Z.storeAvailable = !!r.storeAvailable;", + " Z.isQaTool = !!r.isQaTool;", + " Z.initialized = true;", + " Z.applySettingsMute();", + " Z.refreshRoom(true); // a room the portal page still holds (SDK 1.3.0+)", + " };", + " /** The read-only id the portal sends at init (SDK 1.6.2); \"\" before init or when the SDK is disabled. */", + " Z.gameId = () => {", + " try {", + " const s = window.ZokoGames && window.ZokoGames.SDK;", + " return s && Z.initialized && s.environment !== \"disabled\" ? str(s.game.gameId) : \"\";", + " } catch (err) {", + " return \"\";", + " }", + " };", + "", + " /** Refresh the room identity (self id, host flag) and, with `full`, the members and the state. */", + " Z.refreshRoom = (full) => {", + " const self = Z.core.callSync(\"room.selfId\", {});", + " if (!self.ok) return;", + " Z.roomSelfId = str(self.result);", + " Z.roomIsHost = !!Z.read(\"room.isHost\", {}, false);", + " if (Z.roomIsHost) Z.roomHostId = Z.roomSelfId;", + " if (!Z.roomSelfId) {", + " Z.roomHostId = \"\";", + " Z.roomIsHost = false;", + " }", + " if (full) {", + " const members = Z.read(\"room.members\", {}, null);", + " if (Array.isArray(members)) Z.roomMembers = members;", + " const st = Z.read(\"room.getState\", {}, null);", + " if (st && typeof st === \"object\") Z.roomState = st;", + " }", + " };", + "", + " /* ---- screenshots (SDK 1.4.0) ---- */", + " /** The game canvas scaled to at most 1280 px as a JPG data URL; null when it cannot be read. */", + " Z.captureCanvas = () => {", + " try {", + " const c = Z.canvas();", + " if (!c || !c.width || !c.height) return null;", + " const k = Math.min(1, 1280 / Math.max(c.width, c.height));", + " const t = document.createElement(\"canvas\");", + " t.width = Math.max(1, Math.round(c.width * k));", + " t.height = Math.max(1, Math.round(c.height * k));", + " const g = t.getContext(\"2d\");", + " if (!g) return null;", + " g.drawImage(c, 0, 0, t.width, t.height);", + " const url = t.toDataURL(\"image/jpeg\", 0.8);", + " return /^data:image\\//.test(url) ? url : null;", + " } catch (err) {", + " return null;", + " }", + " };", + " /** When the game does not answer On screenshot requested within 1.5 s, the canvas answers. */", + " const armScreenshot = () => {", + " Z.shotPending = true;", + " clearTimeout(Z.shotTimer);", + " Z.shotTimer = setTimeout(() => {", + " if (Z.shotPending) {", + " Z.shotPending = false;", + " Z.core.callSync(\"game.answerScreenshot\", { dataUrl: Z.captureCanvas() });", + " }", + " }, 1500);", + " };", + " /** data:image/ URLs pass; blob: URLs are read into a data URL; anything else is \"no picture\". */", + " Z.toDataUrl = (url) => {", + " if (typeof url !== \"string\" || url === \"\") return Promise.resolve(null);", + " if (/^data:image\\//i.test(url)) return Promise.resolve(url);", + " if (!/^blob:/i.test(url)) return Promise.resolve(null);", + " return fetch(url)", + " .then((r) => r.blob())", + " .then((blob) => new Promise((resolve) => {", + " const fr = new FileReader();", + " fr.onload = () => resolve(String(fr.result));", + " fr.onerror = () => resolve(null);", + " fr.readAsDataURL(blob);", + " }))", + " .catch(() => null);", + " };", + " Z.answerScreenshot = (tag, url) => {", + " Z.shotPending = false;", + " clearTimeout(Z.shotTimer);", + " return Z.toDataUrl(url).then((dataUrl) => Z.run(tag, \"game.answerScreenshot\", { dataUrl }));", + " };", + "", + " /* ---- banners: rectangles in game resolution pixels, the core wants fractions of the canvas ---- */", + " Z.rect = (x, y, w, h) => {", + " let gw = 0;", + " let gh = 0;", + " try {", + " gw = Z.game.getGameResolutionWidth();", + " gh = Z.game.getGameResolutionHeight();", + " } catch (err) {", + " /* no resolution: treat the numbers as fractions */", + " }", + " gw = gw || 1;", + " gh = gh || 1;", + " return { nx: x / gw, ny: y / gh, nw: w / gw, nh: h / gh };", + " };", + "", + " /* ---- portal events ---- */", + " const onGlobal = (name, data) => {", + " switch (name) {", + " case \"settingsChange\":", + " Z.settings = data || Z.settings;", + " Z.applySettingsMute();", + " Z.push(\"settingsChange\", \"settingsChange\", {});", + " break;", + " case \"offlineChange\":", + " if (!!data !== Z.offline) {", + " Z.offline = !!data;", + " Z.push(\"offlineChange\", \"offlineChange\", {});", + " }", + " break;", + " case \"auth\":", + " Z.user = data || null;", + " Z.token = \"\";", + " Z.push(\"auth\", \"auth\", {});", + " break;", + " case \"achievementUnlocked\":", + " Z.push(\"achievementUnlocked\", \"achievementUnlocked\", {}, () => {", + " Z.lastAchievement = data;", + " });", + " break;", + " case \"joinRoom\":", + " Z.inviteParams = data || null;", + " Z.push(\"joinRoom\", \"joinRoom\", {});", + " break;", + " case \"roomMessage\":", + " Z.push(\"roomMessage\", \"roomMessage\", {}, () => {", + " Z.roomMessage = data;", + " });", + " break;", + " case \"roomState\":", + " Z.roomState = (data && data.state) || {};", + " Z.push(\"roomState\", \"roomState\", {}, () => {", + " Z.roomChange = (data && data.change) || null;", + " });", + " break;", + " case \"roomMembers\":", + " Z.roomMembers = Array.isArray(data) ? data : [];", + " Z.refreshRoom(false);", + " Z.push(\"roomMembers\", \"roomMembers\", {});", + " break;", + " case \"roomHost\":", + " Z.roomHostId = (data && data.hostId) || \"\";", + " Z.roomIsHost = !!(data && data.isHost);", + " Z.refreshRoom(false);", + " Z.push(\"roomHost\", \"roomHost\", {});", + " break;", + " case \"roomError\":", + " Z.push(\"roomError\", \"roomError\", {}, () => {", + " Z.roomError = data;", + " });", + " break;", + " case \"roomLeft\": // SDK 1.7.0: the portal ended our membership without the game asking", + " Z.roomHostId = \"\";", + " Z.roomIsHost = false;", + " Z.push(\"roomLeft\", \"roomLeft\", {}, () => {", + " Z.roomLeft = data;", + " });", + " break;", + " case \"screenshotRequest\":", + " armScreenshot();", + " Z.push(\"screenshotRequest\", \"screenshotRequest\", {});", + " break;", + " case \"mirrorError\":", + " Z.push(\"mirrorError\", \"mirrorError\", {}, () => {", + " Z.mirrorError = data;", + " });", + " break;", + " }", + " };", + "", + " Z.core = zokoCreateCore(window, Z.canvas);", + " Z.core.setGlobalHandler(onGlobal);", + " /** A new game instance (preview restart) keeps the SDK state and points the extension at the new game. */", + " Z.attach = (g) => {", + " if (Z.game === g) return;", + " // A preview restart mid-ad: undo the ad's mute on the old game (the fallback volume comes back), then forget the ad.", + " Z.setMute(\"zokogames-ad\", false);", + " Z.game = g;", + " Z.pausedByAd = false;", + " Z.pauseAfterEvents = false;", + " Z.adPlaying = false;", + " muteReasons.clear();", + " savedVolume = null;", + " Z.queue = [];", + " Z.frame = [];", + " Z.applySettingsMute();", + " };", + " return Z;", + " };", + "", + " const runningGame = runtimeScene.getGame();", + " if (gdjs._zokoGamesExtension && gdjs._zokoGamesExtension.version === SDK_VERSION) gdjs._zokoGamesExtension.attach(runningGame);", + " else gdjs._zokoGamesExtension = createZoko(runningGame);", + "}" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "Delivers the triggers queued since the previous frame.", + "fullName": "", + "functionType": "Action", + "name": "onScenePreEvents", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "if (gdjs._zokoGamesExtension) gdjs._zokoGamesExtension.deliver();" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "Pauses the game after the frame that delivered On ad started.", + "fullName": "", + "functionType": "Action", + "name": "onScenePostEvents", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "if (gdjs._zokoGamesExtension) gdjs._zokoGamesExtension.afterEvents();" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "Load and initialise the ZokoGames SDK. Run it once, at the beginning of the first scene, before any other action. Loads the SDK script itself when the page does not have it.", + "fullName": "Initialize", + "functionType": "Action", + "group": "Start-up", + "name": "Initialize", + "sentence": "Initialize the ZokoGames SDK (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"init\", {}, (r) => Z.applyInit(r));", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Show a midgame (interstitial) or rewarded ad. The game is paused and muted while the ad plays (see Pause the game during ads / Mute the game during ads). Grant a reward in On ad finished only: an unfilled or refused ad fires On ad error and the request still completes.", + "fullName": "Request ad", + "functionType": "Action", + "group": "Ads", + "name": "RequestAd", + "sentence": "Request a _PARAM2_ ad (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"ad.requestAd\", { type: arg(\"Type\") });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Ad type", + "name": "Type", + "type": "stringWithSelector", + "supplementaryInformation": "[\"midgame\",\"rewarded\"]", + "defaultValue": "\"midgame\"" + } + ], + "objectGroups": [] + }, + { + "description": "Check whether an ad blocker is active. Read ResultNumber (1 = blocked) when the request completes.", + "fullName": "Check ad blocker", + "functionType": "Action", + "group": "Ads", + "name": "HasAdblock", + "sentence": "Check for an ad blocker (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"ad.hasAdblock\", {});", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "When enabled (the default), the game loop is paused from On ad started until the ad ends, and resumes by itself.", + "fullName": "Pause the game during ads", + "functionType": "Action", + "group": "Ads", + "name": "SetPauseDuringAds", + "sentence": "Pause the game during ads: _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "if (!Z) return;", + "Z.pauseDuringAds = Z.yes(arg(\"Enable\"));" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Enable", + "name": "Enable", + "type": "yesorno", + "defaultValue": "yes" + } + ], + "objectGroups": [] + }, + { + "description": "When enabled (the default), all game sounds are muted while an ad plays and come back when it ends.", + "fullName": "Mute the game during ads", + "functionType": "Action", + "group": "Ads", + "name": "SetMuteDuringAds", + "sentence": "Mute the game during ads: _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "if (!Z) return;", + "Z.muteDuringAds = Z.yes(arg(\"Enable\"));" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Enable", + "name": "Enable", + "type": "yesorno", + "defaultValue": "yes" + } + ], + "objectGroups": [] + }, + { + "description": "When enabled (the default), the game is muted while the portal's mute setting is on (game.settings.muteAudio).", + "fullName": "Follow the portal mute setting", + "functionType": "Action", + "group": "Ads", + "name": "SetFollowMuteSetting", + "sentence": "Follow the portal mute setting: _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "if (!Z) return;", + "Z.followMuteSetting = Z.yes(arg(\"Enable\")); Z.applySettingsMute();" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Enable", + "name": "Enable", + "type": "yesorno", + "defaultValue": "yes" + } + ], + "objectGroups": [] + }, + { + "description": "An ad started. The extension has already paused and muted the game. True during one frame.", + "fullName": "On ad started", + "functionType": "Condition", + "group": "Ads", + "name": "OnAdStarted", + "sentence": "An ad started", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return !!Z.fired(\"adStarted\");", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "The ad ended normally; grant a reward here. The game has already resumed. True during one frame.", + "fullName": "On ad finished", + "functionType": "Condition", + "group": "Ads", + "name": "OnAdFinished", + "sentence": "An ad finished", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return !!Z.fired(\"adFinished\");", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "The ad request failed (unfilled, ad blocker, cooldown, ads disabled, ...). Fires instead of On ad finished; read ErrorCode. True during one frame.", + "fullName": "On ad error", + "functionType": "Condition", + "group": "Ads", + "name": "OnAdError", + "sentence": "An ad failed", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const it = Z.fired(\"adError\"); if (it) Z.select({ ok: false, tag: \"\", result: null, error: it.data.error }); return !!it;", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "True from On ad started until the ad ends.", + "fullName": "Is ad playing", + "functionType": "Condition", + "group": "Ads", + "name": "IsAdPlaying", + "sentence": "An ad is playing", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.adPlaying;", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "Show a banner of a fixed size over a rectangle of the game screen, in game resolution pixels (0;0 is the top-left corner, the camera does not move it).", + "fullName": "Request banner", + "functionType": "Action", + "group": "Banners", + "name": "RequestBanner", + "sentence": "Request a _PARAM3_ banner in container _PARAM2_ at _PARAM4_;_PARAM5_ size _PARAM6_x_PARAM7_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " const s = String(arg(\"Size\")).split(\"x\").map(Number);", + " return Z.run(tag, \"banner.requestBanner\", { id: arg(\"Id\"), width: s[0], height: s[1], rect: Z.rect(arg(\"X\"), arg(\"Y\"), arg(\"Width\"), arg(\"Height\")) });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Container id", + "name": "Id", + "type": "string" + }, + { + "description": "Banner size", + "name": "Size", + "type": "stringWithSelector", + "supplementaryInformation": "[\"728x90\",\"300x250\",\"320x50\",\"468x60\",\"320x100\"]", + "defaultValue": "\"728x90\"" + }, + { + "description": "X (game pixels)", + "name": "X", + "type": "expression" + }, + { + "description": "Y (game pixels)", + "name": "Y", + "type": "expression" + }, + { + "description": "Width (game pixels)", + "name": "Width", + "type": "expression" + }, + { + "description": "Height (game pixels)", + "name": "Height", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Show the largest banner that fits a rectangle of the game screen (game resolution pixels).", + "fullName": "Request responsive banner", + "functionType": "Action", + "group": "Banners", + "name": "RequestResponsiveBanner", + "sentence": "Request a responsive banner in container _PARAM2_ at _PARAM3_;_PARAM4_ size _PARAM5_x_PARAM6_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"banner.requestResponsiveBanner\", { id: arg(\"Id\"), rect: Z.rect(arg(\"X\"), arg(\"Y\"), arg(\"Width\"), arg(\"Height\")) });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Container id", + "name": "Id", + "type": "string" + }, + { + "description": "X (game pixels)", + "name": "X", + "type": "expression" + }, + { + "description": "Y (game pixels)", + "name": "Y", + "type": "expression" + }, + { + "description": "Width (game pixels)", + "name": "Width", + "type": "expression" + }, + { + "description": "Height (game pixels)", + "name": "Height", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Remove one banner and its container.", + "fullName": "Clear banner", + "functionType": "Action", + "group": "Banners", + "name": "ClearBanner", + "sentence": "Clear the banner in container _PARAM2_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"banner.clearBanner\", { id: arg(\"Id\") });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Container id", + "name": "Id", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Remove every banner.", + "fullName": "Clear all banners", + "functionType": "Action", + "group": "Banners", + "name": "ClearAllBanners", + "sentence": "Clear all banners (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"banner.clearAllBanners\", {});", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "SDK 1.8.0: hide every banner without clearing it.", + "fullName": "Hide all banners", + "functionType": "Action", + "group": "Banners", + "name": "HideAllBanners", + "sentence": "Hide all banners (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"banner.hideAllBanners\", {});", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "SDK 1.8.0: show the banners hidden by Hide all banners.", + "fullName": "Show all banners", + "functionType": "Action", + "group": "Banners", + "name": "ShowAllBanners", + "sentence": "Show all banners (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"banner.showAllBanners\", {});", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Tell the portal that the player is playing (call it before the first midgame ad).", + "fullName": "Gameplay start", + "functionType": "Action", + "group": "Game", + "name": "GameplayStart", + "sentence": "Gameplay start (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"game.gameplayStart\", {});", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Tell the portal that play stopped (menu, pause, game over).", + "fullName": "Gameplay stop", + "functionType": "Action", + "group": "Game", + "name": "GameplayStop", + "sentence": "Gameplay stop (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"game.gameplayStop\", {});", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Tell the portal that loading started.", + "fullName": "Loading start", + "functionType": "Action", + "group": "Game", + "name": "LoadingStart", + "sentence": "Loading start (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"game.loadingStart\", {});", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Tell the portal that loading finished (the portal hides its loading bar).", + "fullName": "Loading stop", + "functionType": "Action", + "group": "Game", + "name": "LoadingStop", + "sentence": "Loading stop (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"game.loadingStop\", {});", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Report loading progress from 0 to 100.", + "fullName": "Report loading progress", + "functionType": "Action", + "group": "Game", + "name": "LoadingProgress", + "sentence": "Report loading progress _PARAM2_% (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"game.loadingProgress\", { percentage: arg(\"Percentage\") });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Progress (0 to 100)", + "name": "Percentage", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Mark a moment of success (the portal may celebrate it).", + "fullName": "Happytime", + "functionType": "Action", + "group": "Game", + "name": "Happytime", + "sentence": "Happytime (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"game.happytime\", {});", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Report how much of the game the player has completed (0 to 100).", + "fullName": "Report completed percentage", + "functionType": "Action", + "group": "Game", + "name": "ReportCompleted", + "sentence": "Report _PARAM2_% of the game completed (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"game.reportGameCompletedPercentage\", { percentage: arg(\"Percentage\") });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Completed (0 to 100)", + "name": "Percentage", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Describe where the player is (level, mode) as a JSON object.", + "fullName": "Set game context", + "functionType": "Action", + "group": "Game", + "name": "SetGameContext", + "sentence": "Set the game context to _PARAM2_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " const t = arg(\"ContextJSON\");", + " if (Z.badJson(t)) return Z.fail(tag, \"invalidArgument\", \"Game context is not valid JSON\");", + " return Z.run(tag, \"game.setGameContext\", { context: Z.parseJson(t) });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Context (JSON object)", + "name": "ContextJSON", + "longDescription": "JSON text, or empty.", + "type": "string", + "optional": true + } + ], + "objectGroups": [] + }, + { + "description": "Remove the game context.", + "fullName": "Clear game context", + "functionType": "Action", + "group": "Game", + "name": "ClearGameContext", + "sentence": "Clear the game context (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"game.clearGameContext\", {});", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Report an in-game chat message to the portal's moderation (SDK 1.4.0). Optional user id, room id and context JSON (empty to leave out).", + "fullName": "Report chat message", + "functionType": "Action", + "group": "Game", + "name": "ReportChat", + "sentence": "Report chat message _PARAM3_ of _PARAM2_ for _PARAM4_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " const ctx = arg(\"ContextJSON\");", + " if (Z.badJson(ctx)) return Z.fail(tag, \"invalidArgument\", \"Context is not valid JSON\");", + " const reasons = [\"abuse\", \"spam\", \"cheating\", \"other\"];", + " const report = { reportedName: arg(\"ReportedName\"), message: arg(\"Message\"), reason: reasons.indexOf(arg(\"Reason\")) >= 0 ? arg(\"Reason\") : \"other\" };", + " if (arg(\"ReportedUserId\")) report.reportedUserId = arg(\"ReportedUserId\");", + " if (arg(\"RoomId\")) report.roomId = arg(\"RoomId\");", + " if (typeof ctx === \"string\" && ctx.trim() !== \"\") report.context = Z.parseJson(ctx);", + " return Z.run(tag, \"game.reportChat\", { report });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Name of the reported player", + "name": "ReportedName", + "type": "string" + }, + { + "description": "Reported message", + "name": "Message", + "type": "string" + }, + { + "description": "Reason", + "name": "Reason", + "type": "stringWithSelector", + "supplementaryInformation": "[\"abuse\",\"spam\",\"cheating\",\"other\"]", + "defaultValue": "\"abuse\"" + }, + { + "description": "User id of the reported player (optional)", + "name": "ReportedUserId", + "type": "string", + "optional": true + }, + { + "description": "Room id (optional)", + "name": "RoomId", + "type": "string", + "optional": true + }, + { + "description": "Context (JSON, optional)", + "name": "ContextJSON", + "longDescription": "JSON text, or empty.", + "type": "string", + "optional": true + } + ], + "objectGroups": [] + }, + { + "description": "Let the portal ask the game for a screenshot (feedback form, SDK 1.4.0). On screenshot requested fires; answer with Answer screenshot, or the game screen is sent after 1.5 s.", + "fullName": "Set screenshot provider", + "functionType": "Action", + "group": "Game", + "name": "SetScreenshotProvider", + "sentence": "Answer the portal's screenshot requests: _PARAM2_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"game.setScreenshotProvider\", { enabled: Z.yes(arg(\"Enabled\")) });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Enabled", + "name": "Enabled", + "type": "yesorno", + "defaultValue": "yes" + } + ], + "objectGroups": [] + }, + { + "description": "Answer On screenshot requested with an image: a data:image/... URL or a blob: URL. Anything else answers \"no picture\".", + "fullName": "Answer screenshot", + "functionType": "Action", + "group": "Game", + "name": "AnswerScreenshot", + "sentence": "Answer the screenshot request with _PARAM2_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.answerScreenshot(tag, arg(\"ImageUrl\"));", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Image URL (data: or blob:)", + "name": "ImageUrl", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "True once Initialize has completed.", + "fullName": "Is initialized", + "functionType": "Condition", + "group": "Start-up", + "name": "IsInitialized", + "sentence": "The SDK is initialized", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.initialized;", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "True once initialised, unless the SDK is disabled where the game runs.", + "fullName": "Is available", + "functionType": "Condition", + "group": "Start-up", + "name": "IsAvailable", + "sentence": "The SDK is available", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.initialized && Z.environment !== \"disabled\";", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "True when the game runs in the portal's QA tool.", + "fullName": "Is QA tool", + "functionType": "Condition", + "group": "Start-up", + "name": "IsQaTool", + "sentence": "The game runs in the QA tool", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.isQaTool;", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "The player changed a portal setting (mute, chat, kids mode). True during one frame.", + "fullName": "On settings changed", + "functionType": "Condition", + "group": "Settings", + "name": "OnSettingsChanged", + "sentence": "The portal settings changed", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return !!Z.fired(\"settingsChange\");", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "True while the portal's mute setting is on.", + "fullName": "Is mute requested", + "functionType": "Condition", + "group": "Settings", + "name": "IsMuteRequested", + "sentence": "The portal asks for silence", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return !!Z.settings.muteAudio;", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "True when the portal disables chat (hide chat features).", + "fullName": "Is chat disabled", + "functionType": "Condition", + "group": "Settings", + "name": "IsChatDisabled", + "sentence": "Chat is disabled", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return !!Z.settings.disableChat;", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "True in kids mode (SDK 1.5.0): hide chat, rooms, sign-in prompts and shops.", + "fullName": "Is kids mode", + "functionType": "Condition", + "group": "Settings", + "name": "IsKidsMode", + "sentence": "Kids mode is on", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.settings.kidsMode === true;", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "True when the game was opened from an invite to join a room.", + "fullName": "Is instant multiplayer", + "functionType": "Condition", + "group": "Multiplayer", + "name": "IsInstantMultiplayer", + "sentence": "The game was opened to join a room", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.instantMultiplayer;", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "True while the portal reports the player offline.", + "fullName": "Is offline", + "functionType": "Condition", + "group": "Settings", + "name": "IsOffline", + "sentence": "The player is offline", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.offline;", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "The offline state changed; check Is offline. True during one frame.", + "fullName": "On offline changed", + "functionType": "Condition", + "group": "Settings", + "name": "OnOfflineChanged", + "sentence": "The offline state changed", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return !!Z.fired(\"offlineChange\");", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "The portal asks for a screenshot (after Set screenshot provider). True during one frame.", + "fullName": "On screenshot requested", + "functionType": "Condition", + "group": "Game", + "name": "OnScreenshotRequested", + "sentence": "The portal asks for a screenshot", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return !!Z.fired(\"screenshotRequest\");", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "Create, join or change the player's room. An empty room id keeps the current one; invite params is a JSON object or empty.", + "fullName": "Update room", + "functionType": "Action", + "group": "Multiplayer", + "name": "UpdateRoom", + "sentence": "Update room _PARAM2_ (joinable: _PARAM3_, invite params _PARAM4_) (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " const p = arg(\"InviteParamsJSON\");", + " if (Z.badJson(p)) return Z.fail(tag, \"invalidArgument\", \"Invite params is not valid JSON\");", + " const update = {};", + " if (arg(\"RoomId\")) update.roomId = arg(\"RoomId\");", + " if (arg(\"Joinable\") === \"yes\") update.isJoinable = true;", + " if (arg(\"Joinable\") === \"no\") update.isJoinable = false;", + " const params = Z.parseJson(p);", + " if (params && typeof params === \"object\" && Object.keys(params).length) update.inviteParams = params;", + " return Z.run(tag, \"game.updateRoom\", { update });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Room id (empty: unchanged)", + "name": "RoomId", + "type": "string", + "optional": true + }, + { + "description": "Joinable", + "name": "Joinable", + "type": "stringWithSelector", + "supplementaryInformation": "[\"unchanged\",\"yes\",\"no\"]", + "defaultValue": "\"unchanged\"" + }, + { + "description": "Invite params (JSON object, optional)", + "name": "InviteParamsJSON", + "longDescription": "JSON text, or empty.", + "type": "string", + "optional": true + } + ], + "objectGroups": [] + }, + { + "description": "List the room publicly or not (SDK 1.6.0).", + "fullName": "Set room public", + "functionType": "Action", + "group": "Multiplayer", + "name": "SetRoomPublic", + "sentence": "Make the room public: _PARAM2_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"game.updateRoom\", { update: { isPublic: Z.yes(arg(\"Public\")) } });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Public", + "name": "Public", + "type": "yesorno", + "defaultValue": "yes" + } + ], + "objectGroups": [] + }, + { + "description": "Tell the portal the player left the room; ends the room data channel.", + "fullName": "Left room", + "functionType": "Action", + "group": "Multiplayer", + "name": "LeftRoom", + "sentence": "Leave the room (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"game.leftRoom\", {});", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Create a link that opens the game with these invite params. The link is in ResultString.", + "fullName": "Create invite link", + "functionType": "Action", + "group": "Multiplayer", + "name": "InviteLink", + "sentence": "Create an invite link with _PARAM2_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " const p = arg(\"InviteParamsJSON\");", + " if (Z.badJson(p)) return Z.fail(tag, \"invalidArgument\", \"Invite params is not valid JSON\");", + " return Z.run(tag, \"game.inviteLink\", { params: Z.parseJson(p) });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Invite params (JSON object)", + "name": "InviteParamsJSON", + "longDescription": "JSON text, or empty.", + "type": "string", + "optional": true + } + ], + "objectGroups": [] + }, + { + "description": "Deprecated: use Create invite link. The link is in ResultString.", + "fullName": "Show invite button (deprecated)", + "functionType": "Action", + "group": "Multiplayer", + "name": "ShowInviteButton", + "sentence": "Show the invite button with _PARAM2_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " const p = arg(\"InviteParamsJSON\");", + " if (Z.badJson(p)) return Z.fail(tag, \"invalidArgument\", \"Invite params is not valid JSON\");", + " return Z.run(tag, \"game.showInviteButton\", { params: Z.parseJson(p) });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Invite params (JSON object)", + "name": "InviteParamsJSON", + "longDescription": "JSON text, or empty.", + "type": "string", + "optional": true + } + ], + "objectGroups": [] + }, + { + "description": "Deprecated.", + "fullName": "Hide invite button (deprecated)", + "functionType": "Action", + "group": "Multiplayer", + "name": "HideInviteButton", + "sentence": "Hide the invite button (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"game.hideInviteButton\", {});", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "SDK 1.7.0: show the portal's invite button and give the link in ResultString, without making the room joinable (the old Show invite button calls Update room).", + "fullName": "Show invite button (portal only)", + "functionType": "Action", + "group": "Multiplayer", + "name": "ShowInviteButtonPortalOnly", + "sentence": "Show the portal's invite button with _PARAM2_ without touching the room (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " const p = arg(\"InviteParamsJSON\");", + " if (Z.badJson(p)) return Z.fail(tag, \"invalidArgument\", \"Invite params is not valid JSON\");", + " const params = Z.parseJson(p) || {};", + " return Z.runSdk(tag, (sdk) => sdk.game.showInviteButton(params, { portalOnly: true }));", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Invite params (JSON object of text values)", + "name": "InviteParamsJSON", + "longDescription": "JSON text, or empty.", + "type": "string", + "optional": true + } + ], + "objectGroups": [] + }, + { + "description": "SDK 1.7.0: hide the portal's invite button; the room stays joinable as it was.", + "fullName": "Hide invite button (portal only)", + "functionType": "Action", + "group": "Multiplayer", + "name": "HideInviteButtonPortalOnly", + "sentence": "Hide the portal's invite button without touching the room (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.runSdk(tag, (sdk) => sdk.game.hideInviteButton({ portalOnly: true }));", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "The portal asks the game to join a room; read InviteParam(key). True during one frame.", + "fullName": "On join room", + "functionType": "Condition", + "group": "Multiplayer", + "name": "OnJoinRoom", + "sentence": "The player is invited to join a room", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return !!Z.fired(\"joinRoom\");", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "Send a small message to every other player of the room. Text that is valid JSON is sent as that value, anything else as text (8 KB, 20 per second).", + "fullName": "Send room message", + "functionType": "Action", + "group": "Room", + "name": "SendRoomMessage", + "sentence": "Send _PARAM2_ to the room (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"room.send\", { data: Z.looseJson(arg(\"Data\")) });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Data (JSON or text)", + "name": "Data", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Send a small message to one member of the room.", + "fullName": "Send room message to member", + "functionType": "Action", + "group": "Room", + "name": "SendRoomMessageTo", + "sentence": "Send _PARAM3_ to room member _PARAM2_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"room.send\", { data: Z.looseJson(arg(\"Data\")), to: arg(\"MemberId\") });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Member id", + "name": "MemberId", + "type": "string" + }, + { + "description": "Data (JSON or text)", + "name": "Data", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Host only: set one key of the shared room state (value parsed as JSON when valid, otherwise text).", + "fullName": "Set room state key", + "functionType": "Action", + "group": "Room", + "name": "SetRoomStateKey", + "sentence": "Set room state _PARAM2_ to _PARAM3_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " const patch = Object.create(null); patch[arg(\"Key\")] = Z.looseJson(arg(\"Value\"));", + " return Z.run(tag, \"room.setState\", { patch });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "State key", + "name": "Key", + "type": "string" + }, + { + "description": "Value (JSON or text)", + "name": "Value", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Host only: remove one key of the shared room state.", + "fullName": "Remove room state key", + "functionType": "Action", + "group": "Room", + "name": "RemoveRoomStateKey", + "sentence": "Remove room state _PARAM2_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " const patch = Object.create(null); patch[arg(\"Key\")] = null;", + " return Z.run(tag, \"room.setState\", { patch });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "State key", + "name": "Key", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "A message from another room member arrived; read RoomMessageData / RoomMessageValue. True during one frame.", + "fullName": "On room message", + "functionType": "Condition", + "group": "Room", + "name": "OnRoomMessage", + "sentence": "A room message arrived", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return !!Z.fired(\"roomMessage\");", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "The shared room state changed; read RoomStateValue(key). True during one frame.", + "fullName": "On room state changed", + "functionType": "Condition", + "group": "Room", + "name": "OnRoomStateChanged", + "sentence": "The room state changed", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return !!Z.fired(\"roomState\");", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "A player joined or left the room. True during one frame.", + "fullName": "On room members changed", + "functionType": "Condition", + "group": "Room", + "name": "OnRoomMembersChanged", + "sentence": "The room members changed", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return !!Z.fired(\"roomMembers\");", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "The room host changed; check Is room host. True during one frame.", + "fullName": "On room host changed", + "functionType": "Condition", + "group": "Room", + "name": "OnRoomHostChanged", + "sentence": "The room host changed", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return !!Z.fired(\"roomHost\");", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "The portal ended this player's room membership without the game asking (SDK 1.7.0: kicked, room closed, disconnected; also left); read RoomLeftReason / RoomLeftRoomId. True during one frame.", + "fullName": "On room left", + "functionType": "Condition", + "group": "Room", + "name": "OnRoomLeft", + "sentence": "The player left the room", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return !!Z.fired(\"roomLeft\");", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "The room channel reported an error; read RoomErrorCode. True during one frame.", + "fullName": "On room error", + "functionType": "Condition", + "group": "Room", + "name": "OnRoomError", + "sentence": "A room error happened", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return !!Z.fired(\"roomError\");", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "True when this player hosts the room (only the host writes the state).", + "fullName": "Is room host", + "functionType": "Condition", + "group": "Room", + "name": "IsRoomHost", + "sentence": "This player is the room host", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.roomIsHost;", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "Read the signed-in player (UserName, UserId, UserPictureUrl); a guest gives empty values.", + "fullName": "Get user", + "functionType": "Action", + "group": "User", + "name": "GetUser", + "sentence": "Get the signed-in player (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"user.getUser\", {}, (r) => { Z.user = r; });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Read one page of the player's friends (FriendCount, FriendName(i), ...).", + "fullName": "List friends", + "functionType": "Action", + "group": "User", + "name": "ListFriends", + "sentence": "List friends, page _PARAM2_ of _PARAM3_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"user.listFriends\", { page: arg(\"Page\"), size: arg(\"Size\") }, (r) => { Z.friends = r; });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Page (from 1)", + "name": "Page", + "type": "expression", + "defaultValue": "1" + }, + { + "description": "Page size", + "name": "Size", + "type": "expression", + "defaultValue": "20" + } + ], + "objectGroups": [] + }, + { + "description": "A signed token of the player for your server (UserToken).", + "fullName": "Get user token", + "functionType": "Action", + "group": "User", + "name": "GetUserToken", + "sentence": "Get a user token signed with the _PARAM2_ key (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " const k = arg(\"KeyType\");", + " return Z.run(tag, \"user.getUserToken\", { signingKeyType: k === \"default\" ? \"\" : k }, (r) => { Z.token = Z.str(r); });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Signing key", + "name": "KeyType", + "type": "stringWithSelector", + "supplementaryInformation": "[\"default\",\"IN_GAME_AUTH\",\"IN_GAME_AUTH_LEGACY\"]", + "defaultValue": "\"default\"" + } + ], + "objectGroups": [] + }, + { + "description": "Ask a guest to sign in. Cancelled: userCancelled.", + "fullName": "Show login prompt", + "functionType": "Action", + "group": "User", + "name": "ShowAuthPrompt", + "sentence": "Show the login prompt (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"user.showAuthPrompt\", {}, (r) => { Z.user = r; });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Ask the player to link accounts. ResultJSON is {\"response\":\"yes\"|\"no\"}.", + "fullName": "Show account link prompt", + "functionType": "Action", + "group": "User", + "name": "ShowAccountLinkPrompt", + "sentence": "Show the account link prompt (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"user.showAccountLinkPrompt\", {});", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Submit a leaderboard score. Encrypted score may be empty on a board without an encryption key.", + "fullName": "Submit score", + "functionType": "Action", + "group": "User", + "name": "SubmitScore", + "sentence": "Submit score _PARAM3_ (encrypted _PARAM2_) (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"user.submitScore\", { encryptedScore: arg(\"EncryptedScore\"), score: arg(\"Score\") });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Encrypted score (or empty)", + "name": "EncryptedScore", + "type": "string", + "optional": true + }, + { + "description": "Score", + "name": "Score", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "SDK 1.8.0: seal a score with the board key; the payload is in EncryptedScore, to pass to Submit score. userNotAuthenticated for guests, invalidArgument for a bad score or key.", + "fullName": "Encrypt score", + "functionType": "Action", + "group": "User", + "name": "EncryptScore", + "sentence": "Encrypt score _PARAM2_ with key _PARAM3_, earned at _PARAM4_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"user.encryptScore\", { score: arg(\"Score\"), key: arg(\"Key\"), earnedAt: arg(\"EarnedAt\") }, (r) => { Z.encryptedScore = Z.str(r); });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Score", + "name": "Score", + "type": "expression" + }, + { + "description": "Board encryption key", + "name": "Key", + "type": "string" + }, + { + "description": "Earned at (Unix ms; 0 for a live run)", + "name": "EarnedAt", + "type": "expression", + "defaultValue": "0" + } + ], + "objectGroups": [] + }, + { + "description": "Deprecated name of Get purchase token.", + "fullName": "Get payment provider user token (deprecated)", + "functionType": "Action", + "group": "Store", + "name": "GetXsollaUserToken", + "sentence": "Get the payment provider user token (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"user.getXsollaUserToken\", {}, (r) => { Z.purchaseToken = Z.str(r); });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "The player signed in or out; read UserName. True during one frame.", + "fullName": "On auth changed", + "functionType": "Condition", + "group": "User", + "name": "OnAuthChanged", + "sentence": "The player signed in or out", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return !!Z.fired(\"auth\");", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "True when Get user, the login prompt or an auth event gave a player.", + "fullName": "Is logged in", + "functionType": "Condition", + "group": "User", + "name": "IsLoggedIn", + "sentence": "The player is signed in", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return !!Z.user;", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "True when the portal offers player accounts.", + "fullName": "Is account available", + "functionType": "Condition", + "group": "User", + "name": "IsAccountAvailable", + "sentence": "Accounts are available", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.accountAvailable;", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "Read a saved item; the value is in ResultString and SavedItem(key).", + "fullName": "Get saved item", + "functionType": "Action", + "group": "Cloud save", + "name": "GetItem", + "sentence": "Read saved item _PARAM2_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " const k = arg(\"Key\");", + " return Z.run(tag, \"data.getItem\", { key: k }, (r) => { if (r === null) Z.cache.delete(k); else Z.cache.set(k, r); });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Key", + "name": "Key", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Save a text value (cloud save, 1 MiB in total).", + "fullName": "Set saved item", + "functionType": "Action", + "group": "Cloud save", + "name": "SetItem", + "sentence": "Save _PARAM3_ as _PARAM2_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " const k = arg(\"Key\");", + " const had = Z.cache.has(k);", + " const prev = Z.cache.get(k);", + " const v = String(arg(\"Value\"));", + " Z.cache.set(k, v);", + " return Z.run(tag, \"data.setItem\", { key: k, value: v }, null, () => { if (had) Z.cache.set(k, prev); else Z.cache.delete(k); });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Key", + "name": "Key", + "type": "string" + }, + { + "description": "Value", + "name": "Value", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Remove one saved item.", + "fullName": "Remove saved item", + "functionType": "Action", + "group": "Cloud save", + "name": "RemoveItem", + "sentence": "Remove saved item _PARAM2_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " const k = arg(\"Key\");", + " const had = Z.cache.has(k);", + " const prev = Z.cache.get(k);", + " Z.cache.delete(k);", + " return Z.run(tag, \"data.removeItem\", { key: k }, null, () => { if (had) Z.cache.set(k, prev); });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Key", + "name": "Key", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Remove every saved item of this game.", + "fullName": "Clear saved data", + "functionType": "Action", + "group": "Cloud save", + "name": "ClearData", + "sentence": "Clear all saved data (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " const before = new Map(Z.cache);", + " Z.cache.clear();", + " return Z.run(tag, \"data.clear\", {}, null, () => { Z.cache = before; });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Copy localStorage writes to the cloud save (SDK 1.4.0): keys starting with the prefix and the keys listed as a JSON array. Both empty: every key.", + "fullName": "Mirror localStorage to cloud save", + "functionType": "Action", + "group": "Cloud save", + "name": "MirrorLocalStorage", + "sentence": "Mirror localStorage keys with prefix _PARAM2_ and keys _PARAM3_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " const keys = arg(\"KeysJSON\");", + " if (Z.badJson(keys)) return Z.fail(tag, \"invalidArgument\", \"Keys is not valid JSON\");", + " const a = {};", + " if (arg(\"Prefix\")) a.prefix = arg(\"Prefix\");", + " const list = typeof keys === \"string\" && keys.trim() !== \"\" ? Z.parseJson(keys) : null;", + " if (Array.isArray(list)) a.keys = list.map(String);", + " return Z.run(tag, \"data.mirrorLocalStorage\", a);", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Key prefix (optional)", + "name": "Prefix", + "type": "string", + "optional": true + }, + { + "description": "Keys (JSON array, optional)", + "name": "KeysJSON", + "longDescription": "JSON text, or empty.", + "type": "string", + "optional": true + } + ], + "objectGroups": [] + }, + { + "description": "Stop copying localStorage writes.", + "fullName": "Stop mirroring localStorage", + "functionType": "Action", + "group": "Cloud save", + "name": "StopMirrorLocalStorage", + "sentence": "Stop mirroring localStorage (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"data.stopMirrorLocalStorage\", {});", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Restore IndexedDB databases from the cloud save and keep copying their writes into it (SDK 1.7.0). Databases: comma-separated names, empty for all. Run it right after Initialize and wait for On completed before the game reads its saves. Later failures raise On mirror error.", + "fullName": "Mirror IndexedDB to cloud save", + "functionType": "Action", + "group": "Cloud save", + "name": "MirrorIndexedDB", + "sentence": "Mirror IndexedDB databases _PARAM2_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " const a = {};", + " const list = String(arg(\"Databases\") || \"\").split(\",\").map((d) => d.trim()).filter((d) => d !== \"\");", + " if (list.length) a.databases = list;", + " return Z.run(tag, \"data.mirrorIndexedDB\", a);", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Comma-separated database names (empty = all)", + "name": "Databases", + "type": "string", + "optional": true + } + ], + "objectGroups": [] + }, + { + "description": "Stop copying IndexedDB writes.", + "fullName": "Stop mirroring IndexedDB", + "functionType": "Action", + "group": "Cloud save", + "name": "StopMirrorIndexedDB", + "sentence": "Stop mirroring IndexedDB (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"data.stopMirrorIndexedDB\", {});", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "A localStorage write could not be copied; read MirrorErrorCode. True during one frame.", + "fullName": "On mirror error", + "functionType": "Condition", + "group": "Cloud save", + "name": "OnMirrorError", + "sentence": "Mirroring localStorage failed", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return !!Z.fired(\"mirrorError\");", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "SDK 1.7.0, fire and forget: send a named event to the portal's analytics. Name: lowercase letter first, then lowercase letters, digits or underscore, at most 40 characters. Params: optional flat JSON object (at most 10 text, number or yes/no values).", + "fullName": "Track event", + "functionType": "Action", + "group": "Analytics", + "name": "TrackEvent", + "sentence": "Track event _PARAM2_ with params _PARAM3_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " const t = arg(\"ParamsJSON\");", + " if (Z.badJson(t)) return Z.fail(tag, \"invalidArgument\", \"Params is not valid JSON\");", + " const params = Z.parseJson(t);", + " const a = { name: arg(\"Name\") };", + " if (Array.isArray(params)) return Z.fail(tag, \"invalidArgument\", \"Params must be a JSON object\");", + " if (params && typeof params === \"object\") a.params = params;", + " return Z.run(tag, \"analytics.track\", a);", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Event name (for example level_complete)", + "name": "Name", + "type": "string" + }, + { + "description": "Params (flat JSON object, optional)", + "name": "ParamsJSON", + "longDescription": "JSON text, or empty.", + "type": "string", + "optional": true + } + ], + "objectGroups": [] + }, + { + "description": "Report an order of your own payment provider (order as a JSON object).", + "fullName": "Track order", + "functionType": "Action", + "group": "Analytics", + "name": "TrackOrder", + "sentence": "Track order _PARAM3_ of provider _PARAM2_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " const o = arg(\"OrderJSON\");", + " if (Z.badJson(o)) return Z.fail(tag, \"invalidArgument\", \"Order is not valid JSON\");", + " return Z.run(tag, \"analytics.trackOrder\", { provider: arg(\"Provider\"), order: Z.parseJson(o) });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Provider", + "name": "Provider", + "type": "string" + }, + { + "description": "Order (JSON object)", + "name": "OrderJSON", + "longDescription": "JSON text, or empty.", + "type": "string", + "optional": true + } + ], + "objectGroups": [] + }, + { + "description": "Load the store catalogue (StoreItemCount, StoreItemName(i), ...).", + "fullName": "Get catalogue items", + "functionType": "Action", + "group": "Store", + "name": "GetCatalogItems", + "sentence": "Get catalogue items (limit _PARAM2_, offset _PARAM3_) (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"store.getCatalogItems\", { limit: arg(\"Limit\"), offset: arg(\"Offset\") }, (r) => { Z.catalog = Array.isArray(r) ? r : []; });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Limit (1 to 50)", + "name": "Limit", + "type": "expression", + "defaultValue": "50" + }, + { + "description": "Offset", + "name": "Offset", + "type": "expression", + "defaultValue": "0" + } + ], + "objectGroups": [] + }, + { + "description": "Load what the player owns (InventoryCount, InventorySku(i), ...).", + "fullName": "Get player inventory", + "functionType": "Action", + "group": "Store", + "name": "GetPlayerInventory", + "sentence": "Get the player inventory (limit _PARAM2_, offset _PARAM3_) (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"store.getPlayerInventory\", { limit: arg(\"Limit\"), offset: arg(\"Offset\") }, (r) => { Z.inventory = Array.isArray(r) ? r : []; });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Limit (1 to 50)", + "name": "Limit", + "type": "expression", + "defaultValue": "50" + }, + { + "description": "Offset", + "name": "Offset", + "type": "expression", + "defaultValue": "0" + } + ], + "objectGroups": [] + }, + { + "description": "Open the checkout for an item; PurchasedItemId on success. Verify ownership on your server.", + "fullName": "Buy item", + "functionType": "Action", + "group": "Store", + "name": "BuyItem", + "sentence": "Buy item _PARAM2_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"store.buyItem\", { itemId: arg(\"ItemId\") }, (r) => { Z.purchasedItemId = (r && r.itemId) || \"\"; });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Item id (SKU)", + "name": "ItemId", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Use up a consumable item the player owns.", + "fullName": "Consume item", + "functionType": "Action", + "group": "Store", + "name": "ConsumeItem", + "sentence": "Consume _PARAM3_ of item _PARAM2_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"store.consumeItem\", { sku: arg(\"Sku\"), quantity: arg(\"Quantity\") });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Item id (SKU)", + "name": "Sku", + "type": "string" + }, + { + "description": "Quantity", + "name": "Quantity", + "type": "expression", + "defaultValue": "1" + } + ], + "objectGroups": [] + }, + { + "description": "Use the payment sandbox (test purchases).", + "fullName": "Set sandbox", + "functionType": "Action", + "group": "Store", + "name": "SetSandbox", + "sentence": "Use the store sandbox: _PARAM2_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"store.setSandbox\", { sandbox: Z.yes(arg(\"Sandbox\")) });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Sandbox", + "name": "Sandbox", + "type": "yesorno", + "defaultValue": "yes" + } + ], + "objectGroups": [] + }, + { + "description": "A signed token of what the player owns, for your server (PurchaseToken).", + "fullName": "Get purchase token", + "functionType": "Action", + "group": "Store", + "name": "GetPurchaseToken", + "sentence": "Get the purchase token (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"store.getPurchaseToken\", {}, (r) => { Z.purchaseToken = Z.str(r); });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "True when the portal offers the store for this game.", + "fullName": "Is store available", + "functionType": "Condition", + "group": "Store", + "name": "IsStoreAvailable", + "sentence": "The store is available", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.storeAvailable;", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "Unlock an achievement. Guests and unknown keys complete normally with LastUnlockReason guest, not_found, not_live, rate_limited or error.", + "fullName": "Unlock achievement", + "functionType": "Action", + "group": "Achievements", + "name": "UnlockAchievement", + "sentence": "Unlock achievement _PARAM2_ (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"achievements.unlock\", { key: arg(\"Key\") }, (r) => {", + " Z.lastUnlockReason = r && r.ok === false ? r.reason || \"error\" : \"\";", + " if (r && r.ok && r.achievement) Z.lastAchievement = r.achievement;", + " });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + }, + { + "description": "Achievement key", + "name": "Key", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Load the achievements of the game (AchievementCount, AchievementKeyAt(i), ...).", + "fullName": "List achievements", + "functionType": "Action", + "group": "Achievements", + "name": "ListAchievements", + "sentence": "List achievements (tag _PARAM1_)", + "async": true, + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const task = eventsFunctionContext.task;", + "const tag = String(arg(\"Tag\"));", + "if (!Z) {", + " task.resolve();", + " return;", + "}", + "let pending;", + "try {", + " pending = (() => {", + " return Z.run(tag, \"achievements.list\", {}, (r) => { Z.achievements = Array.isArray(r) ? r : []; });", + " })();", + "} catch (err) {", + " pending = Z.fail(tag, \"other\", String((err && err.message) || err));", + "}", + "Promise.resolve(pending).then(() => task.resolve(), () => task.resolve());" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "An achievement was unlocked by the game or the portal; read LastAchievementKey. True during one frame.", + "fullName": "On achievement unlocked", + "functionType": "Condition", + "group": "Achievements", + "name": "OnAchievementUnlocked", + "sentence": "An achievement was unlocked", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return !!Z.fired(\"achievementUnlocked\");", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "The request with this tag completed. The result expressions (ResultString, ResultNumber, ResultJSON) describe it in this event. True during one frame.", + "fullName": "On request completed", + "functionType": "Condition", + "group": "Requests", + "name": "OnRequestCompleted", + "sentence": "Request _PARAM1_ completed", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const it = Z.fired(\"completed\", arg(\"Tag\")); if (it) Z.select(it.data); return !!it;", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "The request with this tag failed; read ErrorCode and ErrorMessage. True during one frame.", + "fullName": "On request failed", + "functionType": "Condition", + "group": "Requests", + "name": "OnRequestFailed", + "sentence": "Request _PARAM1_ failed", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const it = Z.fired(\"failed\", arg(\"Tag\")); if (it) Z.select(it.data); return !!it;", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Tag (names this request in On request completed / failed)", + "name": "Tag", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Any request failed; read ErrorCode. True during one frame.", + "fullName": "On any request failed", + "functionType": "Condition", + "group": "Requests", + "name": "OnAnyRequestFailed", + "sentence": "A request failed", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const it = Z.fired(\"anyFailed\"); if (it) Z.select(it.data); return !!it;", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "Compare the code of the last failure (for example purchaseCancelled).", + "fullName": "Last error is", + "functionType": "Condition", + "group": "Requests", + "name": "LastErrorIs", + "sentence": "The last error is _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return !!Z.error && Z.error.code === arg(\"Code\");", + "})() : false;", + "eventsFunctionContext.returnValue = !!value;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Error code", + "name": "Code", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Where the SDK runs: local, zokogames or disabled.", + "fullName": "Environment", + "functionType": "StringExpression", + "group": "Start-up", + "name": "Environment", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.environment;", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "The JavaScript SDK release this extension was written against.", + "fullName": "SDK version", + "functionType": "StringExpression", + "group": "Start-up", + "name": "SdkVersion", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.version;", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "The read-only game id the portal sends at init (SDK 1.6.2); empty before init.", + "fullName": "Game id", + "functionType": "StringExpression", + "group": "Start-up", + "name": "GameId", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.gameId();", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "The result of the request when it is text (token, link, saved item).", + "fullName": "Result (text)", + "functionType": "StringExpression", + "group": "Requests", + "name": "ResultString", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return typeof Z.result === \"string\" ? Z.result : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "The result of the request as a number (true = 1).", + "fullName": "Result (number)", + "functionType": "Expression", + "group": "Requests", + "name": "ResultNumber", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return typeof Z.result === \"number\" ? Z.result : (Z.result === true ? 1 : 0);", + "})() : 0;", + "eventsFunctionContext.returnValue = typeof value === \"number\" && isFinite(value) ? value : 0;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "The result of the request as JSON.", + "fullName": "Result (JSON)", + "functionType": "StringExpression", + "group": "Requests", + "name": "ResultJSON", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return JSON.stringify(Z.result === undefined ? null : Z.result);", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "The code of the last failure.", + "fullName": "Error code", + "functionType": "StringExpression", + "group": "Requests", + "name": "ErrorCode", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.error ? Z.str(Z.error.code) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "The message of the last failure.", + "fullName": "Error message", + "functionType": "StringExpression", + "group": "Requests", + "name": "ErrorMessage", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.error ? Z.str(Z.error.message) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "The banner container id of the last failure.", + "fullName": "Error container id", + "functionType": "StringExpression", + "group": "Requests", + "name": "ErrorContainerId", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.error && Z.error.containerId ? Z.str(Z.error.containerId) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "The error codes of a module (ad, banner, user, data, store, room, general), comma separated.", + "fullName": "Error codes of a module", + "functionType": "StringExpression", + "group": "Requests", + "name": "ErrorCodes", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return (Z.errorCodes[arg(\"Module\")] || []).join(\",\");", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Module", + "name": "Module", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "A short English description of an error code.", + "fullName": "Error description", + "functionType": "StringExpression", + "group": "Requests", + "name": "ErrorDescription", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Object.prototype.hasOwnProperty.call(Z.errorDescriptions, arg(\"Code\")) ? Z.errorDescriptions[arg(\"Code\")] : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Error code", + "name": "Code", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "1 while the portal asks for silence, else 0.", + "fullName": "Mute setting", + "functionType": "Expression", + "group": "Settings", + "name": "MuteAudio", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.settings.muteAudio ? 1 : 0;", + "})() : 0;", + "eventsFunctionContext.returnValue = typeof value === \"number\" && isFinite(value) ? value : 0;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "1 when chat is disabled, else 0.", + "fullName": "Chat disabled setting", + "functionType": "Expression", + "group": "Settings", + "name": "DisableChat", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.settings.disableChat ? 1 : 0;", + "})() : 0;", + "eventsFunctionContext.returnValue = typeof value === \"number\" && isFinite(value) ? value : 0;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "1 in kids mode, else 0.", + "fullName": "Kids mode setting", + "functionType": "Expression", + "group": "Settings", + "name": "KidsMode", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.settings.kidsMode === true ? 1 : 0;", + "})() : 0;", + "eventsFunctionContext.returnValue = typeof value === \"number\" && isFinite(value) ? value : 0;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "One invite parameter, empty when absent.", + "fullName": "Invite param", + "functionType": "StringExpression", + "group": "Multiplayer", + "name": "InviteParam", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const v = Z.inviteParams ? Z.inviteParams[arg(\"Key\")] : undefined; return typeof v === \"string\" ? v : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Key", + "name": "Key", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "All invite parameters as JSON.", + "fullName": "Invite params (JSON)", + "functionType": "StringExpression", + "group": "Multiplayer", + "name": "InviteParamsJSON", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return JSON.stringify(Z.inviteParams || {});", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "The player's locale (for example en-US).", + "fullName": "Locale", + "functionType": "StringExpression", + "group": "User", + "name": "Locale", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.str(Z.systemInfo.locale);", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "The player's country code.", + "fullName": "Country code", + "functionType": "StringExpression", + "group": "User", + "name": "CountryCode", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.str(Z.systemInfo.countryCode);", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "desktop, mobile or tablet.", + "fullName": "Device type", + "functionType": "StringExpression", + "group": "User", + "name": "DeviceType", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.str(Z.systemInfo.device && Z.systemInfo.device.type);", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "The player's name (empty for a guest).", + "fullName": "User name", + "functionType": "StringExpression", + "group": "User", + "name": "UserName", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.user ? Z.str(Z.user.username) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "The player's picture.", + "fullName": "User picture URL", + "functionType": "StringExpression", + "group": "User", + "name": "UserPictureUrl", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.user ? Z.str(Z.user.profilePictureUrl) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "The player's id. Never trust it on a server: verify a user token.", + "fullName": "User id", + "functionType": "StringExpression", + "group": "User", + "name": "UserId", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.user ? Z.str(Z.user.__dangerousUserId) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "The token of Get user token.", + "fullName": "User token", + "functionType": "StringExpression", + "group": "User", + "name": "UserToken", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.token || \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "The payload of Encrypt score.", + "fullName": "Encrypted score", + "functionType": "StringExpression", + "group": "User", + "name": "EncryptedScore", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.encryptedScore || \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "The token of Get purchase token.", + "fullName": "Purchase token", + "functionType": "StringExpression", + "group": "Store", + "name": "PurchaseToken", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.purchaseToken || \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "Deprecated name of PurchaseToken.", + "fullName": "Payment provider user token (deprecated)", + "functionType": "StringExpression", + "group": "Store", + "name": "XsollaUserToken", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.purchaseToken || \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "Friends on the page read by List friends.", + "fullName": "Friend count", + "functionType": "Expression", + "group": "User", + "name": "FriendCount", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.friends && Array.isArray(Z.friends.friends) ? Z.friends.friends.length : 0;", + "})() : 0;", + "eventsFunctionContext.returnValue = typeof value === \"number\" && isFinite(value) ? value : 0;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "Total number of friends.", + "fullName": "Friends total", + "functionType": "Expression", + "group": "User", + "name": "FriendsTotal", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.friends ? Z.num(Z.friends.total, 0) : 0;", + "})() : 0;", + "eventsFunctionContext.returnValue = typeof value === \"number\" && isFinite(value) ? value : 0;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "1 when there is another page.", + "fullName": "Friends has more", + "functionType": "Expression", + "group": "User", + "name": "FriendsHasMore", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.friends && Z.friends.hasMore ? 1 : 0;", + "})() : 0;", + "eventsFunctionContext.returnValue = typeof value === \"number\" && isFinite(value) ? value : 0;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "Name of a friend on the page.", + "fullName": "Friend name", + "functionType": "StringExpression", + "group": "User", + "name": "FriendName", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const v = (Z.friends ? Z.friends.friends : [])[arg(\"Index\")]; return v ? Z.str(v.username) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Index (from 0)", + "name": "Index", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Id of a friend on the page.", + "fullName": "Friend id", + "functionType": "StringExpression", + "group": "User", + "name": "FriendId", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const v = (Z.friends ? Z.friends.friends : [])[arg(\"Index\")]; return v ? Z.str(v.id) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Index (from 0)", + "name": "Index", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Picture of a friend on the page.", + "fullName": "Friend picture URL", + "functionType": "StringExpression", + "group": "User", + "name": "FriendPictureUrl", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const v = (Z.friends ? Z.friends.friends : [])[arg(\"Index\")]; return v ? Z.str(v.profilePictureUrl) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Index (from 0)", + "name": "Index", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "A saved item, read from the SDK at once (empty when absent or before init).", + "fullName": "Saved item", + "functionType": "StringExpression", + "group": "Cloud save", + "name": "SavedItem", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const k = arg(\"Key\");", + " if (Z.initialized) { const r = Z.core.callSync(\"data.getItem\", { key: k }); if (r.ok) return typeof r.result === \"string\" ? r.result : \"\"; }", + " const v = Z.cache.get(k); return typeof v === \"string\" ? v : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Key", + "name": "Key", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "1 when the item exists, else 0.", + "fullName": "Has saved item", + "functionType": "Expression", + "group": "Cloud save", + "name": "HasSavedItem", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const k = arg(\"Key\");", + " if (Z.initialized) { const r = Z.core.callSync(\"data.getItem\", { key: k }); if (r.ok) return r.result === null || r.result === undefined ? 0 : 1; }", + " return Z.cache.has(k) ? 1 : 0;", + "})() : 0;", + "eventsFunctionContext.returnValue = typeof value === \"number\" && isFinite(value) ? value : 0;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [ + { + "description": "Key", + "name": "Key", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Items read by Get catalogue items.", + "fullName": "Catalogue item count", + "functionType": "Expression", + "group": "Store", + "name": "StoreItemCount", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.catalog.length;", + "})() : 0;", + "eventsFunctionContext.returnValue = typeof value === \"number\" && isFinite(value) ? value : 0;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "SKU of a catalogue item.", + "fullName": "Catalogue item SKU", + "functionType": "StringExpression", + "group": "Store", + "name": "StoreItemSku", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const v = Z.catalog[arg(\"Index\")]; return v ? Z.str(v.sku) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Index (from 0)", + "name": "Index", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Name of a catalogue item.", + "fullName": "Catalogue item name", + "functionType": "StringExpression", + "group": "Store", + "name": "StoreItemName", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const v = Z.catalog[arg(\"Index\")]; return v ? Z.str(v.name) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Index (from 0)", + "name": "Index", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Description of a catalogue item.", + "fullName": "Catalogue item description", + "functionType": "StringExpression", + "group": "Store", + "name": "StoreItemDescription", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const v = Z.catalog[arg(\"Index\")]; return v ? Z.str(v.description) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Index (from 0)", + "name": "Index", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Image of a catalogue item.", + "fullName": "Catalogue item image URL", + "functionType": "StringExpression", + "group": "Store", + "name": "StoreItemImageUrl", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const v = Z.catalog[arg(\"Index\")]; return v ? Z.str(v.imageUrl) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Index (from 0)", + "name": "Index", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Price of a catalogue item, -1 when none.", + "fullName": "Catalogue item price", + "functionType": "Expression", + "group": "Store", + "name": "StoreItemPrice", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const v = Z.catalog[arg(\"Index\")]; return v ? (v.price ? Z.num(v.price.amount, -1) : -1) : -1;", + "})() : 0;", + "eventsFunctionContext.returnValue = typeof value === \"number\" && isFinite(value) ? value : 0;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [ + { + "description": "Index (from 0)", + "name": "Index", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Currency of a catalogue item.", + "fullName": "Catalogue item currency", + "functionType": "StringExpression", + "group": "Store", + "name": "StoreItemCurrency", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const v = Z.catalog[arg(\"Index\")]; return v ? (v.price ? Z.str(v.price.currency) : \"\") : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Index (from 0)", + "name": "Index", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "1 when the item is consumable.", + "fullName": "Catalogue item consumable", + "functionType": "Expression", + "group": "Store", + "name": "StoreItemConsumable", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const v = Z.catalog[arg(\"Index\")]; return v ? (v.consumable ? 1 : 0) : 0;", + "})() : 0;", + "eventsFunctionContext.returnValue = typeof value === \"number\" && isFinite(value) ? value : 0;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [ + { + "description": "Index (from 0)", + "name": "Index", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Items read by Get player inventory.", + "fullName": "Inventory count", + "functionType": "Expression", + "group": "Store", + "name": "InventoryCount", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.inventory.length;", + "})() : 0;", + "eventsFunctionContext.returnValue = typeof value === \"number\" && isFinite(value) ? value : 0;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "SKU of an owned item.", + "fullName": "Inventory item SKU", + "functionType": "StringExpression", + "group": "Store", + "name": "InventorySku", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const v = Z.inventory[arg(\"Index\")]; return v ? Z.str(v.sku) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Index (from 0)", + "name": "Index", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Name of an owned item.", + "fullName": "Inventory item name", + "functionType": "StringExpression", + "group": "Store", + "name": "InventoryName", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const v = Z.inventory[arg(\"Index\")]; return v ? Z.str(v.name) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Index (from 0)", + "name": "Index", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Description of an owned item.", + "fullName": "Inventory item description", + "functionType": "StringExpression", + "group": "Store", + "name": "InventoryDescription", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const v = Z.inventory[arg(\"Index\")]; return v ? Z.str(v.description) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Index (from 0)", + "name": "Index", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Image of an owned item.", + "fullName": "Inventory item image URL", + "functionType": "StringExpression", + "group": "Store", + "name": "InventoryImageUrl", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const v = Z.inventory[arg(\"Index\")]; return v ? Z.str(v.imageUrl) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Index (from 0)", + "name": "Index", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Quantity of an owned item, -1 when not counted.", + "fullName": "Inventory item quantity", + "functionType": "Expression", + "group": "Store", + "name": "InventoryQuantity", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const v = Z.inventory[arg(\"Index\")]; return v ? Z.num(v.quantity, -1) : -1;", + "})() : 0;", + "eventsFunctionContext.returnValue = typeof value === \"number\" && isFinite(value) ? value : 0;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [ + { + "description": "Index (from 0)", + "name": "Index", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "The item of the last Buy item.", + "fullName": "Purchased item id", + "functionType": "StringExpression", + "group": "Store", + "name": "PurchasedItemId", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.purchasedItemId || \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "Achievements read by List achievements.", + "fullName": "Achievement count", + "functionType": "Expression", + "group": "Achievements", + "name": "AchievementCount", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.achievements.length;", + "})() : 0;", + "eventsFunctionContext.returnValue = typeof value === \"number\" && isFinite(value) ? value : 0;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "Key of an achievement.", + "fullName": "Achievement key", + "functionType": "StringExpression", + "group": "Achievements", + "name": "AchievementKeyAt", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const v = Z.achievements[arg(\"Index\")]; return v ? Z.str(v.key) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Index (from 0)", + "name": "Index", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Name of an achievement.", + "fullName": "Achievement name", + "functionType": "StringExpression", + "group": "Achievements", + "name": "AchievementNameAt", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const v = Z.achievements[arg(\"Index\")]; return v ? Z.str(v.name) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Index (from 0)", + "name": "Index", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Description of an achievement.", + "fullName": "Achievement description", + "functionType": "StringExpression", + "group": "Achievements", + "name": "AchievementDescriptionAt", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const v = Z.achievements[arg(\"Index\")]; return v ? Z.str(v.description) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Index (from 0)", + "name": "Index", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Points of an achievement.", + "fullName": "Achievement points", + "functionType": "Expression", + "group": "Achievements", + "name": "AchievementPointsAt", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const v = Z.achievements[arg(\"Index\")]; return v ? Z.num(v.points, 0) : 0;", + "})() : 0;", + "eventsFunctionContext.returnValue = typeof value === \"number\" && isFinite(value) ? value : 0;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [ + { + "description": "Index (from 0)", + "name": "Index", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "When an achievement was unlocked (empty while locked).", + "fullName": "Achievement unlock time", + "functionType": "StringExpression", + "group": "Achievements", + "name": "AchievementUnlockedAt", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const v = Z.achievements[arg(\"Index\")]; return v ? Z.text(v.unlockedAt) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Index (from 0)", + "name": "Index", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "1 when an achievement is unlocked.", + "fullName": "Achievement is unlocked", + "functionType": "Expression", + "group": "Achievements", + "name": "AchievementIsUnlockedAt", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const v = Z.achievements[arg(\"Index\")]; return v ? (v.unlocked ? 1 : 0) : 0;", + "})() : 0;", + "eventsFunctionContext.returnValue = typeof value === \"number\" && isFinite(value) ? value : 0;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [ + { + "description": "Index (from 0)", + "name": "Index", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Why the last Unlock achievement did not unlock (empty when it did).", + "fullName": "Last unlock reason", + "functionType": "StringExpression", + "group": "Achievements", + "name": "LastUnlockReason", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.lastUnlockReason || \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "Key of the last unlocked achievement.", + "fullName": "Last achievement key", + "functionType": "StringExpression", + "group": "Achievements", + "name": "LastAchievementKey", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.lastAchievement ? Z.str(Z.lastAchievement.key) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "Name of the last unlocked achievement.", + "fullName": "Last achievement name", + "functionType": "StringExpression", + "group": "Achievements", + "name": "LastAchievementName", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.lastAchievement ? Z.str(Z.lastAchievement.name) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "Points of the last unlocked achievement.", + "fullName": "Last achievement points", + "functionType": "Expression", + "group": "Achievements", + "name": "LastAchievementPoints", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.lastAchievement ? Z.num(Z.lastAchievement.points, 0) : 0;", + "})() : 0;", + "eventsFunctionContext.returnValue = typeof value === \"number\" && isFinite(value) ? value : 0;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "The received message: text as is, other values as JSON.", + "fullName": "Room message data", + "functionType": "StringExpression", + "group": "Room", + "name": "RoomMessageData", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const m = Z.roomMessage; return m ? Z.text(m.data) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "Member id of the sender.", + "fullName": "Room message sender", + "functionType": "StringExpression", + "group": "Room", + "name": "RoomMessageFrom", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.roomMessage ? Z.str(Z.roomMessage.from) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "1 when the message was sent to this player only.", + "fullName": "Room message is direct", + "functionType": "Expression", + "group": "Room", + "name": "RoomMessageDirect", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.roomMessage && Z.roomMessage.direct ? 1 : 0;", + "})() : 0;", + "eventsFunctionContext.returnValue = typeof value === \"number\" && isFinite(value) ? value : 0;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "Sequence number of the message.", + "fullName": "Room message sequence", + "functionType": "Expression", + "group": "Room", + "name": "RoomMessageSeq", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.roomMessage ? Z.num(Z.roomMessage.seq, 0) : 0;", + "})() : 0;", + "eventsFunctionContext.returnValue = typeof value === \"number\" && isFinite(value) ? value : 0;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "One field of an object message, as text (numbers and booleans as text, objects as JSON).", + "fullName": "Room message field", + "functionType": "StringExpression", + "group": "Room", + "name": "RoomMessageValue", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const d = Z.roomMessage ? Z.roomMessage.data : null;", + " return d && typeof d === \"object\" && !Array.isArray(d) ? Z.text(d[arg(\"Key\")]) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Field", + "name": "Key", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "The shared room state as JSON.", + "fullName": "Room state (JSON)", + "functionType": "StringExpression", + "group": "Room", + "name": "RoomStateJSON", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return JSON.stringify(Z.roomState || {});", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "One key of the room state, as text (objects as JSON).", + "fullName": "Room state value", + "functionType": "StringExpression", + "group": "Room", + "name": "RoomStateValue", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.text((Z.roomState || {})[arg(\"Key\")]);", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "State key", + "name": "Key", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Keys of the last state change, comma separated.", + "fullName": "Room state changed keys", + "functionType": "StringExpression", + "group": "Room", + "name": "RoomStateChangedKeys", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.roomChange && Array.isArray(Z.roomChange.keys) ? Z.roomChange.keys.join(\",\") : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "Member id of the last state writer.", + "fullName": "Room state changed by", + "functionType": "StringExpression", + "group": "Room", + "name": "RoomStateChangedBy", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.roomChange ? Z.str(Z.roomChange.by) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "Revision of the room state.", + "fullName": "Room state revision", + "functionType": "Expression", + "group": "Room", + "name": "RoomStateRev", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.roomChange ? Z.num(Z.roomChange.rev, 0) : 0;", + "})() : 0;", + "eventsFunctionContext.returnValue = typeof value === \"number\" && isFinite(value) ? value : 0;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "Members of the room, this player included.", + "fullName": "Room member count", + "functionType": "Expression", + "group": "Room", + "name": "RoomMemberCount", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.roomMembers.length;", + "})() : 0;", + "eventsFunctionContext.returnValue = typeof value === \"number\" && isFinite(value) ? value : 0;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "Id of a member.", + "fullName": "Room member id", + "functionType": "StringExpression", + "group": "Room", + "name": "RoomMemberIdAt", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const v = Z.roomMembers[arg(\"Index\")]; return v ? Z.str(v.id) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Index (from 0)", + "name": "Index", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Name of a member.", + "fullName": "Room member name", + "functionType": "StringExpression", + "group": "Room", + "name": "RoomMemberNameAt", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const v = Z.roomMembers[arg(\"Index\")]; return v ? Z.str(v.username) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Index (from 0)", + "name": "Index", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Picture of a member.", + "fullName": "Room member picture URL", + "functionType": "StringExpression", + "group": "Room", + "name": "RoomMemberPictureUrlAt", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " const v = Z.roomMembers[arg(\"Index\")]; return v ? Z.str(v.profilePictureUrl) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Index (from 0)", + "name": "Index", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Member id of the host.", + "fullName": "Room host id", + "functionType": "StringExpression", + "group": "Room", + "name": "RoomHostId", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.roomHostId || \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "This player's member id (empty when not in a room).", + "fullName": "Room self id", + "functionType": "StringExpression", + "group": "Room", + "name": "RoomSelfId", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.roomSelfId || \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "Why the last room left event happened: left, kicked, closed or disconnected.", + "fullName": "Room left reason", + "functionType": "StringExpression", + "group": "Room", + "name": "RoomLeftReason", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.roomLeft ? Z.str(Z.roomLeft.reason) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "Id of the room of the last room left event (empty when unknown).", + "fullName": "Room left room id", + "functionType": "StringExpression", + "group": "Room", + "name": "RoomLeftRoomId", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.roomLeft ? Z.str(Z.roomLeft.roomId) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "Code of the last room error.", + "fullName": "Room error code", + "functionType": "StringExpression", + "group": "Room", + "name": "RoomErrorCode", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.roomError ? Z.str(Z.roomError.code) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "Message of the last room error.", + "fullName": "Room error message", + "functionType": "StringExpression", + "group": "Room", + "name": "RoomErrorMessage", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.roomError ? Z.str(Z.roomError.message) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "Code of the last localStorage mirror error.", + "fullName": "Mirror error code", + "functionType": "StringExpression", + "group": "Cloud save", + "name": "MirrorErrorCode", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.mirrorError ? Z.str(Z.mirrorError.code) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "Message of the last localStorage mirror error.", + "fullName": "Mirror error message", + "functionType": "StringExpression", + "group": "Cloud save", + "name": "MirrorErrorMessage", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const Z = gdjs._zokoGamesExtension;", + "const arg = (name) => eventsFunctionContext.getArgument(name);", + "const value = Z ? (() => {", + " return Z.mirrorError ? Z.str(Z.mirrorError.message) : \"\";", + "})() : \"\";", + "eventsFunctionContext.returnValue = typeof value === \"string\" ? value : value === undefined || value === null ? \"\" : String(value);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [], + "objectGroups": [] + } + ], + "eventsBasedBehaviors": [], + "eventsBasedObjects": [] +} diff --git a/scripts/lib/ExtensionsValidatorExceptions.js b/scripts/lib/ExtensionsValidatorExceptions.js index 489407e92..b170abf3c 100644 --- a/scripts/lib/ExtensionsValidatorExceptions.js +++ b/scripts/lib/ExtensionsValidatorExceptions.js @@ -123,6 +123,12 @@ const extensionsAllowedProperties = { }, /** @type {Record}} */ extensionSpecificAllowance: { + ZokoGames: { + gdjsAllowedProperties: ['_zokoGamesExtension'], + gdjsEvtToolsAllowedProperties: [], + runtimeSceneAllowedProperties: [], + javaScriptObjectAllowedProperties: [], + }, A3F: { gdjsAllowedProperties: ['_A3F'], gdjsEvtToolsAllowedProperties: ['object', 'tween'],