{"id":15722618,"url":"https://github.com/indiesoftby/defold-yagames","last_synced_at":"2025-04-10T02:26:32.715Z","repository":{"id":44908925,"uuid":"281693261","full_name":"indiesoftby/defold-yagames","owner":"indiesoftby","description":"YaGames is the Yandex.Games SDK implementation for the Defold game engine.","archived":false,"fork":false,"pushed_at":"2025-03-23T10:11:01.000Z","size":94504,"stargazers_count":64,"open_issues_count":6,"forks_count":8,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-03T00:06:39.693Z","etag":null,"topics":["browser-games","defold","defold-game-engine","defold-library","defold-native-extension","game-development","gamedev","html5-game-development","yandex-games"],"latest_commit_sha":null,"homepage":"https://defold.com/2021/04/21/Releasing-games-on-Yandex/","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/indiesoftby.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-22T14:01:29.000Z","updated_at":"2025-03-23T10:10:16.000Z","dependencies_parsed_at":"2023-12-11T16:25:32.151Z","dependency_job_id":"ad3fc343-e811-47ec-9aeb-f5de26bb8bf1","html_url":"https://github.com/indiesoftby/defold-yagames","commit_stats":{"total_commits":168,"total_committers":2,"mean_commits":84.0,"dds":0.005952380952380931,"last_synced_commit":"ee2573e95deeb7d094b4958d6b42fbd4f437a839"},"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indiesoftby%2Fdefold-yagames","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indiesoftby%2Fdefold-yagames/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indiesoftby%2Fdefold-yagames/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indiesoftby%2Fdefold-yagames/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/indiesoftby","download_url":"https://codeload.github.com/indiesoftby/defold-yagames/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248143718,"owners_count":21054829,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browser-games","defold","defold-game-engine","defold-library","defold-native-extension","game-development","gamedev","html5-game-development","yandex-games"],"created_at":"2024-10-03T22:08:39.266Z","updated_at":"2025-04-10T02:26:32.688Z","avatar_url":"https://github.com/indiesoftby.png","language":"Lua","funding_links":[],"categories":["Libraries"],"sub_categories":["Programming Language"],"readme":"[![YaGames Logo](cover.png)](https://github.com/indiesoftby/defold-yagames)\n\n# YaGames - Yandex.Games for Defold\n\n*This is an open-source project, and it's not affiliated with Yandex LLC.*\n\nYaGames is the Yandex.Games SDK native extension for the [Defold](https://www.defold.com/) game engine. [Yandex.Games](https://yandex.com/games/) is a collection of browser HTML5 games for smartphones, computers, tablets, and TVs. The games are available in Yandex Browser and the Yandex app. Games from the catalog are displayed in Yandex recommendation systems, which have a total audience of more than 50 million users per month.\n\n## Installation\n\nYou can use it in your own project by adding this project as a [Defold library dependency](http://www.defold.com/manuals/libraries/). Open your `game.project` file and in the dependencies field add **a link to the ZIP file of a [specific release](https://github.com/indiesoftby/defold-yagames/releases).**\n\n\u003e [!CAUTION]\n\u003e For Yandex.Games use only WASM variant when creating HTML5 build of your game. Asm.js variant won't work at all because of [polyfills](https://github.com/emscripten-core/emscripten/blob/10cb9d46cdd17e7a96de68137c9649d9a630fbc7/src/shell.js#L45), which are necessary to support older browsers and which break the Yandex.Games SDK.\n\n## Getting Started\n\n* **[🎓 Tutorial: \"Releasing HTML5 games on Yandex.Games\"](https://defold.com/2021/04/21/Releasing-games-on-Yandex/) - How to add the Yandex.Games SDK to a Defold game and how to submit your game to the Yandex.Games catalog.**\n* [📚 The official documentation](https://yandex.ru/dev/games/doc/dg/concepts/about.html?lang=en).\n* [💬 The official Telegram chat](https://t.me/yagamedev) where you can talk with representatives from Yandex. Feel free to ask questions in English!\n* [💬 The Telegram chat about Defold](https://t.me/DefoldEngine) for Russian-speaking users.\n* [💬 The Defold forum topic](https://forum.defold.com/t/yagames-yandex-games-sdk-for-defold/66810) about the YaGames extension.\n\n### Checklist For Releasing Game\n\n1. [Sign up as a developer](https://yandex.ru/dev/games/doc/dg/concepts/about.html?lang=en).\n2. Translate your game to the Russian language (*tip:* translate your game title into Russian too!). English and Turkish are optional [(more info)](https://yandex.ru/dev/games/doc/dg/concepts/languages-and-domains.html?lang=en).\n3. Prepare assets for the catalogue:\n    - Icon 512 x 512 px.\n    - Cover 800 x 470 px.\n    - Screenshots.\n    - *(Optional)* Videos and GIF.\n4. Add [the extension](https://github.com/indiesoftby/defold-yagames/archive/master.zip) as a Defold library dependency to your project. \n5. Enable monetization and earn revenue from placing ad blocks in your game. Ad blocks are available in the following formats:\n    - **Interstitial blocks**: ad blocks that completely cover the app background and show up at certain points (for example, when accessing the next game level). *Important: Mute sounds before showing the ad!*\n    - **Rewarded videos**: blocks with video ads that the user can choose to view and earn a reward or in-game currency. *Important: Mute sounds before showing the ad!*\n    - **Sticky banners**: banner ads, super easy to setup.\n    - **In-game purchases**: earn revenue by providing paid services to your users.\n5. You can [publish your game on Yandex.Games](https://games.yandex.ru/console/) from this moment. It fully meets [the requirements](https://yandex.ru/dev/games/doc/dg/concepts/requirements.html?lang=en).\n\n### Best Practices \u0026 Tips\n\n1. The YaGames extension imitates a real API on *non-HTML5* platforms. The idea is to allow to you quickly implement API on your favourite platform (macOS, Windows, Linux) and don't spend time on slowly rebuilding/uploading the game to the Yandex.\n2. The code from `yagames/manifests/web/engine_template.html` is always added to your HTML5 template. This behaviour can't be disabled. Tip: use Git-branching for every platform and do not mix platform-specific code between them.\n3. You don't need to set up any cache-busting techniques, since Yandex.Games hosts each version of your game in separate paths.\n\n## Code Examples\n\nTake a look at the demo project inside `example` directory. It has quite a few buttons to test all APIs. You can use it in your game as a debug screen or simply [download/upload a pre-built .zip archive](https://github.com/indiesoftby/defold-yagames/blob/gh-pages/demo_no-sw_no-native-cache.zip?raw=true) to make sure that you implemented SDK in the right way.\n\n![YaGames Demo](screenshot.png)\n\n### 1. Initialization\n\nTo get started, you need to initialize the SDK using the `init` method.\n\n```lua\nlocal yagames = require(\"yagames.yagames\")\n\nlocal function init_handler(self, err)\n    if err then\n        print(\"Something bad happened :(\", err)\n    else\n        --\n        -- SDK is ready!\n        -- From this moment, you can use all available functions, i.e. invoke ads, get player data, etc.\n        --\n\n        -- For example, signal that the game has loaded all resources and is ready for user interaction:\n        yagames.features_loadingapi_ready()\n\n        -- Do something else!\n    end\nend\n\nfunction init(self)\n    yagames.init(init_handler)\nend\n```\n\n### 2. Interstitial Ad\n\nInterstitial ads are ad blocks that completely cover the app background and show up before a user gets the data requested (for example, accessing the next game level).\n\n***Note:** Yandex.Games [recommends that developers call the display of full-screen ads in the game as often as possible](https://yandex.ru/blog/gamesfordevelopers/obnovlenie-algoritmov-pokaza-fulskrinov) but in suitable places in the game — so that the user understands that this is not a part of the game, but an ad unit. Do this in logical pauses in the game, for example: before starting the game, when moving to the next level, after losing.For example, inserting an ad unit is appropriate after going to the next level by pressing a button, and not appropriate in the middle of a level, when an ad suddenly appears under the playerʼs finger.*\n\n* `open` - Called when an ad is opened successfully.\n* `close` - Called when an ad is closed, an error occurred, or on ad failed to open due to too frequent calls. Used with the `was_shown` argument (type `boolean`), the value of which indicates whether an ad was shown.\n* `offline` - Called when the network connection is lost (when offline mode is enabled).\n* `error` - Called when an error occurrs. The error object is passed to the callback function.\n\n**The `close` callback is called in any situation, even if there was an error.**\n\n```lua\nlocal yagames = require(\"yagames.yagames\")\n\nlocal function adv_open(self)\n    -- You should switch off all sounds!\nend\n\nlocal function adv_close(self, was_shown)\n    -- You can switch sounds back!\nend\n\nlocal function adv_offline(self)\n    -- Internet is offline\nend\n\nlocal function adv_error(self, err)\n    -- Something wrong happened :(\nend\n\nfunction on_message(self, message_id, message)\n    if message_id == hash(\"show_fullscreen_adv\") then\n        yagames.adv_show_fullscreen_adv({\n            open = adv_open,\n            close = adv_close,\n            offline = adv_offline,\n            error = adv_error\n        })\n    end\nend\n```\n\n### 3. Rewarded Videos\n\nRewarded videos are video ad blocks used to monetize games and earn a reward or in-game currency.\n\n* `open` - Called when a video ad is displayed on the screen.\n* `rewarded` - Called when a video ad impression is counted. Use this function to specify a reward for viewing the video ad. \n* `close` - Called when a user closes a video ad or an error happens.\n* `error` - Called when an error occurrs. The error object is passed to the callback function.\n\n**The `close` callback is called in any situation, even if there was an error.** The `rewarded` callback is called before `close`, and you should update your in-game UI only after `close`.\n\n```lua\nlocal yagames = require(\"yagames.yagames\")\n\nlocal function rewarded_open(self)\n    -- You should switch off all sounds!\nend\n\nlocal function rewarded_rewarded(self)\n    -- Add coins!\nend\n\nlocal function rewarded_close(self)\n    -- You can switch sounds back!\nend\n\nlocal function rewarded_error(self, err)\n    -- Something wrong happened :(\nend\n\nfunction on_message(self, message_id, message)\n    if message_id == hash(\"show_rewarded_video\") then\n        yagames.adv_show_rewarded_video({\n            open = rewarded_open,\n            rewarded = rewarded_rewarded,\n            close = rewarded_close,\n            error = rewarded_error\n        })\n    end\nend\n```\n\n### Misc\n\n\u003e [!TIP]\n\u003e We don't use thes features in our games as we don't see any improvements in our games metrics, and the complexity of its integration and support is quite high.\n\n#### Native Cache How-To\n\nYandex's [Native Cache](https://yandex.ru/dev/games/doc/dg/concepts/native-cache-settings.html?lang=en) lets users use games offline. Currently, it's available only in Yandex Browser or the Yandex app on smartphones.\n\n1. Set the path to the file `yandex-manifest.json` in the `game.project` settings.\n2. Copy the `yagames/manifests/web/yandex-manifest.json` file to the root directory of your release build.\n3. Edit the list of all game files inside your `yandex-manifest.json`, and update the path to the icon. Omit `sw.js` and `yandex-manifest.json`.\n\n#### Service Worker How-To\n\nYandex dropped the Service Worker description page in their docs, but it still allows to integrate Service Worker into your game to be able to run both offline and online. \n\n1. Set the path to the file `sw.js` in the `game.project` settings.\n2. Copy the `yagames/manifests/web/sw.js` file to the root directory of your release build.\n3. Edit the list of all game files inside your `sw.js`. Omit `sw.js` and `yandex-manifest.json`.\n4. You should increment the version inside `sw.js` on every update of your game on Yandex.Games.\n\n## The `game.project` Settings (Optional!)\n\n```ini\n[yagames]\nsdk_url = /sdk.js\nsdk_init_options = {}\nsdk_init_snippet = console.log(\"Yandex Games SDK is ready!\");\nservice_worker_url = sw.js\nmanifest_url = yandex-manifest.json\n```\n\n* `sdk_url` - Sets the URL of the Yandex.Games SDK. In July 2024 the platform changed the URL of its SDK and now it can be of two kinds. First is the local `/sdk.js` for games you upload as an archive (default, **suitable for 99% of games**). The second is for iFrame games - `https://sdk.games.s3.yandex.net/sdk.js`.\n* `sdk_init_options` - JavaScript Object that is passed as-is into the Yandex Games SDK initialization options for [the JS `YaGames.init` function](https://yandex.ru/dev/games/doc/dg/sdk/sdk-about.html?lang=en). Example: `{ orientation: { value: \"landscape\", lock: true } }`.\n* `sdk_init_snippet` - JavaScript code that is passed as-is and called when the `ysdk` variable becomes available. Example: `console.log(ysdk);`. **Use with care, and don't forget to put a semicolon `;` at the end.**\n* `service_worker_url` - Relative URL to the Service Worker file. Usually it's `sw.js`. Set the URL to enable Service Worker.\n* `manifest_url` - URL to the Web App Manifest file. Set the URL to enable support of Yandex Native Cache.\n\n## Lua API\n\nYandex.Games JavaScript SDK uses ES6 Promise for asynchronous operations. For Lua API promises were replaced with callback functions with arguments `(self, err, result)`, where\n\n- `self` \u003ckbd\u003euserdata\u003c/kbd\u003e - Script self reference.\n- `err` \u003ckbd\u003estring\u003c/kbd\u003e - Error code if something went wrong.\n- `result` - Data if the operation should return something.\n\n### Lua \u003c-\u003e JS\n\nThe best way to integrate SDK into your game is to read [the official documentation](https://yandex.ru/dev/games/doc/dg/concepts/about.html?lang=en) and to use corresponding Lua API functions. \n\nAnd it's also a good idea to upload a demo build of YaGames to your game's draft and click on the buttons to understand what the arguments are and what each function returns.\n\n| Yandex.Games JS SDK | YaGames Lua API |\n| ------------------- | --------------- |\n| `YaGames.init(options)` | `yagames.init(callback)`\u003cbr\u003eThe `options` is a JavaScript object `{}`, and it can be set in the `yagames.sdk_init_options` setting. |\n| `ysdk.isAvailableMethod(name)` | `yagames.is_available_method(name, callback)` [\u003ckbd\u003eExample\u003c/kbd\u003e](https://github.com/indiesoftby/defold-yagames/blob/master/example/ysdkdebug/pg_methods.lua) |\n| **Advertisement** [(docs)](https://yandex.ru/dev/games/doc/en/sdk/sdk-adv) |  |\n| `ysdk.adv.showFullscreenAdv({callbacks:{}})` | `yagames.adv_show_fullscreen_adv(callbacks)` [\u003ckbd\u003eExample\u003c/kbd\u003e](#2-interstitial-ad) |\n| `ysdk.adv.showRewardedVideo({callbacks:{}})` | `yagames.adv_show_rewarded_video(callbacks)` [\u003ckbd\u003eExample\u003c/kbd\u003e](#3-rewarded-videos) |\n| **Advertisement - Sticky Banners** [(docs)](https://yandex.ru/dev/games/doc/en/sdk/sdk-adv#sticky-banner) |  |\n| `ysdk.adv.getBannerAdvStatus()` | `yagames.adv_get_banner_adv_status(callback)` |\n| `ysdk.adv.showBannerAdv()` | `yagames.adv_show_banner_adv([callback])` |\n| `ysdk.adv.hideBannerAdv()` | `yagames.adv_hide_banner_adv([callback])` |\n| **Authentication + Player** [(docs)](https://yandex.ru/dev/games/doc/en/sdk/sdk-player) |  |\n| `ysdk.auth.openAuthDialog()` | `yagames.auth_open_auth_dialog(callback)` |\n| `ysdk.getPlayer(options)` | `yagames.player_init(options, callback)`\u003cbr\u003eThe argument `options` is a Lua table `{ signed = boolean, scopes = boolean }`. |\n| `player._personalInfo` | `yagames.player_get_personal_info()`\u003cbr\u003eThe result is `table` or `nil` if the `_personalInfo` object is not available. |\n| `player.signature` | `yagames.player_get_signature()`\u003cbr\u003eThe result is string if player's object is initialized with `options.signed = true`. Otherwise, `nil`. |\n| `player.setData(data, flush)` | `yagames.player_set_data(data, flush, callback)` |\n| `player.getData(keys)` | `yagames.player_get_data(keys, callback)` |\n| `player.setStats(stats)` | `yagames.player_set_stats(stats, callback)` |\n| `player.incrementStats(increments)` | `yagames.player_increment_stats(increments, callback)` |\n| `player.getStats(keys)` | `yagames.player_get_stats(keys, callback)` |\n| ~~`player.getID()`~~ \u003ckbd\u003eDeprecated\u003c/kbd\u003e | ~~`yagames.player_get_id()`~~ \u003ckbd\u003eDeprecated\u003c/kbd\u003e |\n| `player.getUniqueID()` | `yagames.player_get_unique_id()` |\n| `player.getIDsPerGame()` | `yagames.player_get_ids_per_game(callback)` |\n| `player.getMode()` | `yagames.player_get_mode()`\u003cbr\u003e[(more info)](https://yandex.ru/blog/gamesfordevelopers/novye-vozmozhnosti-dlya-neavtorizovannykh-polzovateley) |\n| `player.getName()` | `yagames.player_get_name()` |\n| `player.getPhoto(size)` | `yagames.player_get_photo(size)` |\n| `player.getPayingStatus()` | `yagames.player_get_paying_status()` |\n| **In-Game Purchases** [(docs)](https://yandex.ru/dev/games/doc/en/sdk/sdk-purchases) |  |\n| `ysdk.getPayments(options)` | `yagames.payments_init(options, callback)` |\n| `payments.purchase(options)` | `yagames.payments_purchase(options, callback)` |\n| `payments.getPurchases()` | `yagames.payments_get_purchases(callback)`\u003cbr\u003eThe result has the format `{ purchases = { ... }, signature = \"...\" }` |\n| `payments.getCatalog()` | `yagames.payments_get_catalog([options], callback)`\u003cbr\u003eThe argument `options` is an optional Lua table `{ getPriceCurrencyImage = \"size\" }`, where `size` (string) can be `medium`, `small` and `svg`, the currency image url will be injected to the `getPriceCurrencyImage` field of each product. |\n| `payments.consumePurchase(purchaseToken)` | `yagames.payments_consume_purchase(purchase_token, callback)` |\n| **Leaderboards** [(docs)](https://yandex.ru/dev/games/doc/en/sdk/sdk-leaderboard) |  |\n| `ysdk.getLeaderboards()` | `yagames.leaderboards_init(callback)` |\n| `lb.getLeaderboardDescription(leaderboardName)` | `yagames.leaderboards_get_description(leaderboard_name, callback)` |\n| `lb.getLeaderboardPlayerEntry(leaderboardName)` | `yagames.leaderboards_get_player_entry(leaderboard_name, [options], callback)`\u003cbr\u003eIf the player doesn't have any score, you get the error `FetchError: Player is not present in leaderboard`.\u003cbr\u003eThe argument `options` is an optional Lua table `{ getAvatarSrc = \"size\", getAvatarSrcSet = \"size\" }`, where `size` (string) can be `small`, `medium`, `large`. |\n| `lb.getLeaderboardEntries(leaderboardName, options)` | `yagames.leaderboards_get_entries(leaderboard_name, [options], callback)`\u003cbr\u003eThe argument `options` is an optional Lua table `{ includeUser = boolean, quantityAround = number, quantityTop = number, getAvatarSrc = \"size\", getAvatarSrcSet = \"size\" }`, where `size` (string) can be `small`, `medium`, `large`. |\n| `lb.setLeaderboardScore(leaderboardName, score, extraData)` | `yagames.leaderboards_set_score(leaderboard_name, score, [extra_data], [callback])` |\n| **Features** [(docs)](https://yandex.com/dev/games/doc/en/sdk/sdk-game-events) |  |\n| `ysdk.features.LoadingAPI?.ready()` | `yagames.features_loadingapi_ready()` |\n| `ysdk.features.GameplayAPI?.start()` | `yagames.features_gameplayapi_start()` |\n| `ysdk.features.GameplayAPI?.stop()` | `yagames.features_gameplayapi_stop()` |\n| `ysdk.features.GamesAPI?.getAllGames()` | `yagames.features_gamesapi_get_all_games(callback)`\u003cbr\u003eThe callback result is a table `{ games = { ... }, developerURL = \"string\" }` |\n| `ysdk.features.GamesAPI?.getGameByID(appID)` | `yagames.features_gamesapi_get_game_by_id(app_id, callback)`\u003cbr\u003eThe callback result is a table `{ isAvailable = true/false, game = { appID = \"string\", title = \"string\", url = \"string\", coverURL = \"string\", iconURL = \"string\" } }` |\n| **Feedback** [(docs)](https://yandex.ru/dev/games/doc/en/sdk/sdk-review) |  |\n| `ysdk.feedback.canReview()` | `yagames.feedback_can_review(callback)`\u003cbr\u003eThe callback result is a table `{ value = true/false, reason = \"string\" }` |\n| `ysdk.feedback.requestReview()` | `yagames.feedback_request_review(callback)`\u003cbr\u003eThe callback result is a table `{ feedbackSent = true/false }` |\n| **Clipboard** [(docs)](https://yandex.ru/dev/games/doc/en/sdk/sdk-params) |  |\n| `ysdk.clipboard.writeText(text)` | `yagames.clipboard_write_text(text, [callback])` |\n| **Device Info** [(docs)](https://yandex.ru/dev/games/doc/en/sdk/sdk-params) |  |\n| `ysdk.deviceInfo.type` | `yagames.device_info_type()`\u003cbr\u003eReturns `\"desktop\"`, `\"mobile\"`, `\"tablet\"` or `\"tv\"` |\n| `ysdk.deviceInfo.isDesktop()` | `yagames.device_info_is_desktop()` |\n| `ysdk.deviceInfo.isMobile()` | `yagames.device_info_is_mobile()` |\n| `ysdk.deviceInfo.isTablet()` | `yagames.device_info_is_tablet()` |\n| `ysdk.deviceInfo.isTV()` | `yagames.device_info_is_tv()` |\n| **Environment** [(docs)](https://yandex.ru/dev/games/doc/en/sdk/sdk-environment) |  |\n| `ysdk.environment` | `yagames.environment()`\u003cbr\u003eReturns Lua table `{ app = { id = ... }, ... }` |\n| **Screen** [(docs)](https://yandex.ru/dev/games/doc/en/sdk/sdk-params) |  |\n| `ysdk.screen.fullscreen.status` | `yagames.screen_fullscreen_status()`\u003cbr\u003eReturns `\"on\"` or `\"off\"` |\n| `ysdk.screen.fullscreen.request()` | `yagames.screen_fullscreen_request([callback])` |\n| `ysdk.screen.fullscreen.exit()` | `yagames.screen_fullscreen_exit([callback])` |\n| **Shortcuts** [(docs)](https://yandex.ru/dev/games/doc/ru/sdk/sdk-shortcut) |  |\n| `ysdk.shortcut.canShowPrompt()` | `yagames.shortcut_can_show_prompt(callback)`\u003cbr\u003eThe callback result is a table `{ canShow = boolean }` |\n| `ysdk.shortcut.showPrompt()` | `yagames.shortcut_show_prompt(callback)`\u003cbr\u003eThe callback result is a table `{ outcome = \"string\" }` |\n| **Safe Storage** [(docs)](https://yandex.ru/dev/games/doc/en/sdk/sdk-player#progress-loss) | *Note: `key` and `value` should be valid UTF-8 strings. Storing strings with zero bytes aren't supported.* |\n| `ysdk.getStorage()` | `yagames.storage_init(callback)` |\n| - `safeStorage.getItem(key)` | `yagames.storage_get_item(key)`\u003cbr\u003eReturns that key's value or `nil`. |\n| - `safeStorage.setItem(key, value)` | `yagames.storage_set_item(key, value)`\u003cbr\u003eAdds that key to the storage, or update that key's value if it already exists. |\n| - `safeStorage.removeItem(key)` | `yagames.storage_remove_item(key)`\u003cbr\u003eRemoves that key from the storage. |\n| - `safeStorage.clear()` | `yagames.storage_clear()`\u003cbr\u003eEmpties all keys out of the storage. |\n| - `safeStorage.key(n)` | `yagames.storage_key(n)`\u003cbr\u003eReturns the name of the nth key in the storage or `nil`. *Note: the n index is zero-based.* |\n| - `safeStorage.length` | `yagames.storage_length()`\u003cbr\u003eReturns the number of data items stored in the storage. |\n| **Events** [(docs)](https://yandex.ru/dev/games/doc/en/sdk/sdk-events) |  |\n| `ysdk.onEvent(eventName, listener)` | `yagames.event_on(event_name, listener)` |\n| `ysdk.dispatchEvent(eventName)` | `yagames.event_dispatch(event_name)` |\n| **Remote Config** [(docs)](https://yandex.ru/dev/games/doc/en/sdk/sdk-config) |  |\n| `ysdk.getFlags(options)` | `yagames.flags_get(options, callback)`\u003cbr\u003eOptions is optional. The callback result is a table like `{ flagName = \"value\" }` |\n| **Sitelock** [(docs)](#sitelock) |  |\n|  | `sitelock.add_domain(domain)` |\n|  | `sitelock.verify_domain()` |\n|  | `sitelock.get_current_domain()` |\n|  | `sitelock.is_release_build()` |\n\n## Sitelock\n\nIt's a good idea to protect your HTML5 game from simple copy-pasting to another website. The YaGames extension has Sitelock API for that purpose. It's simple, but it's better than nothing.\n\nBy default, it checks hostnames `yandex.net` (CDN of the Yandex.Games) and `localhost` (for local debugging).\n\n```lua\nlocal sitelock = require(\"yagames.sitelock\")\n\n-- Also you can add your domains:\n-- sitelock.add_domain(\"yourdomainname.com\")\n\nfunction init(self)\n    if html5 and sitelock.is_release_build() then\n        if not sitelock.verify_domain() then\n            -- Show warning and pause the game\n        end\n    end\nend\n```\n\n\n## Credits\n\nArtsiom Trubchyk ([@aglitchman](https://github.com/aglitchman)) is the current YaGames owner within Indiesoft and is responsible for the open source repository.\n\nThis project uses the source code of [JsToDef](https://github.com/AGulev/jstodef).\n\n### License\n\nMIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findiesoftby%2Fdefold-yagames","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Findiesoftby%2Fdefold-yagames","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findiesoftby%2Fdefold-yagames/lists"}