### Get Device Type and Adapt UI (GDScript) Source: https://context7.com/playgama/bridge-godot-4/llms.txt This snippet demonstrates how to retrieve the user's device type (desktop, mobile, tablet, or TV) using the Bridge SDK and adapt the game's UI and controls accordingly. It includes functions for setting up different control schemes based on the detected device. ```gdscript extends Node func _ready(): # Get device type: "desktop", "mobile", "tablet", or "tv" var device_type = Bridge.device.type print("Device Type: " + device_type) # Adapt UI based on device match device_type: Bridge.DeviceType.DESKTOP: setup_desktop_controls() Bridge.DeviceType.MOBILE: setup_touch_controls() Bridge.DeviceType.TABLET: setup_touch_controls() scale_ui_for_tablet() Bridge.DeviceType.TV: setup_gamepad_controls() func setup_desktop_controls(): print("Using keyboard/mouse controls") func setup_touch_controls(): print("Enabling touch input and virtual joystick") func scale_ui_for_tablet(): print("Scaling UI for larger touch targets") func setup_gamepad_controls(): print("Using gamepad navigation") ``` -------------------------------- ### Implement Advertisement Module Source: https://context7.com/playgama/bridge-godot-4/llms.txt Provides methods to initialize, display, and handle state changes for banner, interstitial, and rewarded ads. Includes logic for pausing the game during ad playback and checking for ad blockers. ```GDScript func _ready(): Bridge.advertisement.connect("banner_state_changed", Callable(self, "_on_banner_state_changed")) Bridge.advertisement.connect("interstitial_state_changed", Callable(self, "_on_interstitial_state_changed")) Bridge.advertisement.connect("rewarded_state_changed", Callable(self, "_on_rewarded_state_changed")) func show_banner_ad(): Bridge.advertisement.show_banner(Bridge.BannerPosition.BOTTOM) func _on_interstitial_state_changed(state: String): match state: Bridge.InterstitialState.OPENED: get_tree().paused = true Bridge.InterstitialState.CLOSED: get_tree().paused = false func show_rewarded_ad(): Bridge.advertisement.show_rewarded() func check_for_adblock(): Bridge.advertisement.check_adblock(Callable(self, "_on_adblock_check")) ``` -------------------------------- ### Constants and Enums Source: https://context7.com/playgama/bridge-godot-4/llms.txt Reference for all available constants and enums used throughout the SDK. ```APIDOC ## Constants and Enums Reference for all available constants and enums used throughout the SDK. ### Device Types - `Bridge.DeviceType.DESKTOP` # "desktop" - `Bridge.DeviceType.MOBILE` # "mobile" - `Bridge.DeviceType.TABLET` # "tablet" - `Bridge.DeviceType.TV` # "tv" ### Visibility States - `Bridge.VisibilityState.VISIBLE` # "visible" - `Bridge.VisibilityState.HIDDEN` # "hidden" ``` -------------------------------- ### Initialize Playgama Bridge for Godot Source: https://github.com/playgama/bridge-godot-4/blob/main/addons/playgama_bridge/template/index.html Handles the asynchronous loading of the Playgama bridge script with a CDN fallback to a local file. It initializes the bridge and hooks into the Godot Engine loading progress events. ```javascript const ENGINE = new Engine(GODOT_CONFIG); const CANVAS = document.getElementById('canvas'); function initializeBridge() { bridge.engine = 'godot-4'; bridge.initialize().then(() => { bridge.game.setLoadingProgress(0); ENGINE.startGame({ onProgress: function (current, total) { bridge.game.setLoadingProgress((current / total) * 100); }, }).then(() => { CANVAS.focus(); }); }); } const bridgeScript = document.createElement('script'); bridgeScript.src = 'https://bridge.playgama.com/v1/stable/playgama-bridge.js'; bridgeScript.onload = initializeBridge; bridgeScript.onerror = addLocalBridge; document.head.appendChild(bridgeScript); ``` -------------------------------- ### Remote Config Module: Load and Apply Configuration Source: https://context7.com/playgama/bridge-godot-4/llms.txt Fetches configuration values from the platform's remote configuration service. It checks if remote config is supported, loads the configuration (with platform-specific options for A/B testing), and applies the received settings or default values if loading fails. This allows for dynamic adjustments to game parameters like difficulty and feature flags. ```gdscript extends Node func _ready(): print("Remote Config Supported: " + str(Bridge.remote_config.is_supported)) if Bridge.remote_config.is_supported: load_remote_config() func load_remote_config(): var options = null # Yandex supports client features for A/B testing match Bridge.platform.id: "yandex": options = { "clientFeatures": [ { "name": "player_coins", "value": "42" }, { "name": "player_level", "value": "dungeon_123" } ] } Bridge.remote_config.get(options, Callable(self, "_on_config_loaded")) func _on_config_loaded(success: bool, data): if success: print("Remote config loaded") # Access configuration values if data is Dictionary: for key in data: print("Config: " + key + " = " + str(data[key])) # Apply configuration apply_config(data) else: print("Failed to load remote config - using defaults") apply_default_config() func apply_config(config: Dictionary): # Example: Apply difficulty settings if config.has("difficulty_multiplier"): var multiplier = float(config.difficulty_multiplier) set_difficulty(multiplier) # Example: Feature flags if config.has("new_feature_enabled"): var enabled = config.new_feature_enabled == "true" toggle_new_feature(enabled) func apply_default_config(): set_difficulty(1.0) toggle_new_feature(false) func set_difficulty(multiplier: float): print("Setting difficulty multiplier: " + str(multiplier)) func toggle_new_feature(enabled: bool): print("New feature enabled: " + str(enabled)) ``` -------------------------------- ### Manage Game Data Storage with Bridge SDK Source: https://context7.com/playgama/bridge-godot-4/llms.txt Demonstrates how to perform asynchronous read and delete operations on game data using the Bridge.storage interface. It handles multiple keys simultaneously and uses callbacks to process results. ```GDScript func load_game_data(): var keys = ["coins_count", "level_id", "is_tutorial_completed"] Bridge.storage.get(keys, Callable(self, "_on_game_data_loaded")) func _on_game_data_loaded(success: bool, data: Array): if success: var coins = 0 if data[0] == null else int(data[0]) var level = 1 if data[1] == null else int(data[1]) var tutorial = false if data[2] == null else data[2].to_lower() == "true" print("Coins: " + str(coins)) print("Level: " + str(level)) print("Tutorial completed: " + str(tutorial)) func delete_game_data(): var keys = ["coins_count", "level_id", "is_tutorial_completed"] Bridge.storage.delete(keys, Callable(self, "_on_delete_completed")) func _on_delete_completed(success: bool): if success: print("Game data deleted") func save_to_cloud(key: String, value: String): Bridge.storage.set(key, value, Callable(self, "_on_cloud_save"), Bridge.StorageType.PLATFORM_INTERNAL) ``` -------------------------------- ### Handle In-App Purchases and Product Catalogs (GDScript) Source: https://context7.com/playgama/bridge-godot-4/llms.txt This GDScript snippet covers the functionality for handling in-app purchases, including loading the product catalog, initiating purchases, consuming consumable items, and checking for pending purchases. It relies on the Bridge.payments object and provides callbacks for purchase completion. ```gdscript extends Node func _ready(): print("Payments Supported: " + str(Bridge.payments.is_supported)) if Bridge.payments.is_supported: # Load available products on startup load_product_catalog() check_pending_purchases() # Load product catalog func load_product_catalog(): Bridge.payments.get_catalog(Callable(self, "_on_catalog_loaded")) func _on_catalog_loaded(success: bool, catalog: Array): if success: print("Loaded " + str(catalog.size()) + " products") for item in catalog: print("Product ID: " + str(item.id)) print(" Price: " + str(item.price)) print(" Currency: " + str(item.priceCurrencyCode)) print(" Value: " + str(item.priceValue)) else: print("Failed to load catalog") # Make a purchase func purchase_item(product_id: String): Bridge.payments.purchase(product_id, null, Callable(self, "_on_purchase_completed")) func purchase_item_with_options(product_id: String, developer_payload: String): var options = { "developerPayload": developer_payload } Bridge.payments.purchase(product_id, options, Callable(self, "_on_purchase_completed")) func _on_purchase_completed(success: bool, purchase): if success: print("Purchase successful!") print("Purchase details: " + str(purchase)) # Grant the purchased item grant_purchased_item(purchase) else: print("Purchase failed or cancelled") func grant_purchased_item(purchase): # Handle different product types match purchase.id: "coins_100": add_coins(100) # Consume the purchase for consumable items consume_purchase(purchase.id) "no_ads": remove_ads_permanently() # Don't consume non-consumable items # Consume a purchase (for consumable items like coins) func consume_purchase(product_id: String): Bridge.payments.consume_purchase(product_id, Callable(self, "_on_consume_completed")) func _on_consume_completed(success: bool, details): if success: print("Purchase consumed successfully") else: print("Failed to consume purchase") # Check for pending/unclaimed purchases func check_pending_purchases(): Bridge.payments.get_purchases(Callable(self, "_on_purchases_loaded")) func _on_purchases_loaded(success: bool, purchases: Array): if success: for purchase in purchases: print("Pending purchase: " + str(purchase.id)) # Restore or consume pending purchases grant_purchased_item(purchase) func add_coins(amount: int): print("Added " + str(amount) + " coins") func remove_ads_permanently(): print("Ads removed permanently") ``` -------------------------------- ### Game Module API Source: https://context7.com/playgama/bridge-godot-4/llms.txt Handles game state management related to application visibility, pausing and resuming gameplay. ```APIDOC ## Game Module ### Description The game module handles visibility state changes for pausing/resuming gameplay when the browser tab loses focus. ### Method Connect to `visibility_state_changed` signal. ### Endpoint `Bridge.game.visibility_state` ### Parameters #### Query Parameters - **None** #### Request Body - **None** ### Request Example ```gdscript extends Node func _ready(): # Get current visibility state: "visible" or "hidden" print("Current Visibility: " + Bridge.game.visibility_state) # Connect to visibility changes Bridge.game.connect("visibility_state_changed", Callable(self, "_on_visibility_changed")) func _on_visibility_changed(state: String): match state: Bridge.VisibilityState.HIDDEN: # Tab lost focus - pause game print("Game hidden - pausing") pause_game() Bridge.VisibilityState.VISIBLE: # Tab gained focus - resume game print("Game visible - resuming") resume_game() func pause_game(): get_tree().paused = true AudioServer.set_bus_mute(0, true) func resume_game(): get_tree().paused = false AudioServer.set_bus_mute(0, false) ``` ### Response #### Success Response (200) - **state** (String) - The current visibility state, either `"visible"` or `"hidden"`. #### Response Example ```json { "state": "visible" } ``` ``` -------------------------------- ### Persistent Data Storage (GDScript) Source: https://context7.com/playgama/bridge-godot-4/llms.txt This snippet illustrates how to use the Bridge SDK's storage module for saving and loading game data. It covers checking storage support and availability for both local and cloud storage, saving single values or multiple values at once, and loading data with callback handling for completion status. ```gdscript extends Node func _ready(): # Check storage configuration print("Default Storage Type: " + Bridge.storage.default_type) print("Local Storage Supported: " + str(Bridge.storage.is_supported(Bridge.StorageType.LOCAL_STORAGE))) print("Local Storage Available: " + str(Bridge.storage.is_available(Bridge.StorageType.LOCAL_STORAGE))) print("Platform Internal Supported: " + str(Bridge.storage.is_supported(Bridge.StorageType.PLATFORM_INTERNAL))) print("Platform Internal Available: " + str(Bridge.storage.is_available(Bridge.StorageType.PLATFORM_INTERNAL))) # Save single value func save_high_score(score: int): Bridge.storage.set("high_score", str(score), Callable(self, "_on_save_completed")) # Save multiple values at once func save_game_data(coins: int, level: int, tutorial_completed: bool): var keys = ["coins_count", "level_id", "is_tutorial_completed"] var values = [str(coins), str(level), str(tutorial_completed)] Bridge.storage.set(keys, values, Callable(self, "_on_save_completed")) func _on_save_completed(success: bool): if success: print("Game data saved successfully") else: print("Failed to save game data") # Load single value func load_high_score(): Bridge.storage.get("high_score", Callable(self, "_on_high_score_loaded")) func _on_high_score_loaded(success: bool, data): if success and data != null: var high_score = int(data) print("High score: " + str(high_score)) ``` -------------------------------- ### Implement Social Features in Godot 4 Source: https://context7.com/playgama/bridge-godot-4/llms.txt Shows how to utilize the social module to share game links and create social posts with platform-specific media attachments. ```gdscript func share_game(): var options = null if Bridge.platform.id == "vk": options = { "link": "https://vk.com/your_game_page" } Bridge.social.share(options, Callable(self, "_on_share_completed")) func create_post_with_score(score: int): var options = null match Bridge.platform.id: "vk": options = { "message": "I scored " + str(score) + " points!", "attachments": "photo-199747461_457239629" } "ok": options = { "media": [ { "type": "text", "text": "I scored " + str(score) + " points!" }, { "type": "link", "url": "https://your-game-url.com" } ] } Bridge.social.create_post(options, Callable(self, "_on_post_created")) ``` -------------------------------- ### Game Module: Handle Visibility State Changes Source: https://context7.com/playgama/bridge-godot-4/llms.txt Manages game pausing and resuming based on browser tab visibility. It connects to the 'visibility_state_changed' signal and pauses the game when the tab is hidden and resumes when it becomes visible. This ensures a smooth user experience by stopping gameplay when the user is not actively viewing the game. ```gdscript extends Node func _ready(): # Get current visibility state: "visible" or "hidden" print("Current Visibility: " + Bridge.game.visibility_state) # Connect to visibility changes Bridge.game.connect("visibility_state_changed", Callable(self, "_on_visibility_changed")) func _on_visibility_changed(state: String): match state: Bridge.VisibilityState.HIDDEN: # Tab lost focus - pause game print("Game hidden - pausing") pause_game() Bridge.VisibilityState.VISIBLE: # Tab gained focus - resume game print("Game visible - resuming") resume_game() func pause_game(): get_tree().paused = true AudioServer.set_bus_mute(0, true) func resume_game(): get_tree().paused = false AudioServer.set_bus_mute(0, false) ``` -------------------------------- ### Player Authentication and Profile Management (GDScript) Source: https://context7.com/playgama/bridge-godot-4/llms.txt This code snippet shows how to handle player authentication using the Bridge SDK. It checks authorization status, initiates the authorization process with platform-specific options, and handles the callback to display player information like ID, name, and profile photo. It also includes logic for loading player photos from a URL. ```gdscript extends Node @onready var player_photo_rect = $PlayerPhoto func _ready(): # Check authorization support and status print("Authorization Supported: " + str(Bridge.player.is_authorization_supported)) print("Is Authorized: " + str(Bridge.player.is_authorized)) if Bridge.player.is_authorized: display_player_info() func authorize_player(): if not Bridge.player.is_authorization_supported: print("Authorization not supported on this platform") return # Platform-specific options var options = null match Bridge.platform.id: "yandex": options = { "scopes": true } # Request additional permissions Bridge.player.authorize(options, Callable(self, "_on_authorization_completed")) func _on_authorization_completed(success: bool): if success: print("Authorization successful!") display_player_info() else: print("Authorization failed or cancelled") func display_player_info(): print("Player ID: " + str(Bridge.player.id)) print("Player Name: " + str(Bridge.player.name)) # Access extra platform-specific data var extra = Bridge.player.extra for key in extra: print("Extra - " + key + ": " + str(extra[key])) # Load player photo if available var photos = Bridge.player.photos if photos.size() > 0: load_player_photo(photos[0]) func load_player_photo(url: String): var http_request = HTTPRequest.new() add_child(http_request) http_request.connect("request_completed", Callable(self, "_on_photo_loaded")) http_request.request(url) func _on_photo_loaded(result, response_code, headers, body): var image = Image.new() var error = image.load_png_from_buffer(body) if error == OK: var texture = ImageTexture.new() texture.create_from_image(image) player_photo_rect.texture = texture ``` -------------------------------- ### Platform Module Integration in GDScript Source: https://context7.com/playgama/bridge-godot-4/llms.txt This snippet demonstrates how to use the Platform Module from the Playgama Bridge SDK in Godot 4. It covers accessing platform information, connecting to state change signals, sending game lifecycle messages, retrieving server time, and fetching game catalog data. It relies on the Bridge global singleton and GDScript's signal system. ```gdscript extends Node func _ready(): # Access platform information print("Platform ID: " + Bridge.platform.id) # e.g., "yandex", "vk", "crazy_games" print("Language: " + Bridge.platform.language) # e.g., "en", "ru" print("Payload: " + str(Bridge.platform.payload)) # Launch parameters print("TLD: " + str(Bridge.platform.tld)) # Top-level domain print("Audio Enabled: " + str(Bridge.platform.is_audio_enabled)) # Connect to platform state changes Bridge.platform.connect("audio_state_changed", Callable(self, "_on_audio_state_changed")) Bridge.platform.connect("pause_state_changed", Callable(self, "_on_pause_state_changed")) # Send game lifecycle messages to the platform func notify_game_ready(): Bridge.platform.send_message(Bridge.PlatformMessage.GAME_READY) func notify_loading_started(): Bridge.platform.send_message(Bridge.PlatformMessage.IN_GAME_LOADING_STARTED) func notify_loading_stopped(): Bridge.platform.send_message(Bridge.PlatformMessage.IN_GAME_LOADING_STOPPED) func notify_gameplay_started(): Bridge.platform.send_message(Bridge.PlatformMessage.GAMEPLAY_STARTED) func notify_gameplay_stopped(): Bridge.platform.send_message(Bridge.PlatformMessage.GAMEPLAY_STOPPED) # Send level events with optional data func notify_level_started(level_number: int, level_name: String): var options = { "level": level_number, "name": level_name } Bridge.platform.send_message(Bridge.PlatformMessage.LEVEL_STARTED, options) func notify_level_completed(level_number: int, score: int): var options = { "level": level_number, "score": score } Bridge.platform.send_message(Bridge.PlatformMessage.LEVEL_COMPLETED, options) func notify_level_failed(level_number: int): var options = { "level": level_number } Bridge.platform.send_message(Bridge.PlatformMessage.LEVEL_FAILED, options) # Get server time (UTC milliseconds) func get_server_time(): Bridge.platform.get_server_time(Callable(self, "_on_server_time_received")) func _on_server_time_received(milliseconds: int): print("Server time (UTC): " + str(milliseconds)) var datetime = Time.get_datetime_dict_from_unix_time(milliseconds / 1000) print("Date: %d-%02d-%02d" % [datetime.year, datetime.month, datetime.day]) # Get all games from platform catalog (if supported) func get_all_platform_games(): if Bridge.platform.is_get_all_games_supported: Bridge.platform.get_all_games(Callable(self, "_on_games_received")) func _on_games_received(success: bool, games: Array): if success: for game in games: print("App ID: " + str(game.appID)) print("Title: " + str(game.title)) print("URL: " + str(game.url)) # Get specific game by ID func get_game_info(game_id: String): if Bridge.platform.is_get_game_by_id_supported: var options = { "gameId": game_id } Bridge.platform.get_game_by_id(options, Callable(self, "_on_game_info_received")) func _on_game_info_received(success: bool, game): if success and game: print("Title: " + str(game.title)) print("Available: " + str(game.isAvailable)) func _on_audio_state_changed(is_enabled: bool): # Mute/unmute game audio based on platform request AudioServer.set_bus_mute(0, not is_enabled) func _on_pause_state_changed(is_paused: bool): get_tree().paused = is_paused ``` -------------------------------- ### Storage API Source: https://context7.com/playgama/bridge-godot-4/llms.txt Methods for managing game data persistence, including batch retrieval, deletion, and platform-specific storage configuration. ```APIDOC ## Bridge.storage.get ### Description Retrieves multiple values from persistent storage asynchronously. ### Method GET ### Parameters - **keys** (Array) - Required - List of keys to retrieve. - **callback** (Callable) - Required - Function to handle the result (success: bool, data: Array). ## Bridge.storage.set ### Description Saves a value to storage with an optional storage type. ### Method POST ### Parameters - **key** (String) - Required - The key to store. - **value** (String) - Required - The value to store. - **callback** (Callable) - Required - Completion callback. - **type** (StorageType) - Optional - Storage destination (e.g., PLATFORM_INTERNAL). ``` -------------------------------- ### Advertisement API Source: https://context7.com/playgama/bridge-godot-4/llms.txt Methods for displaying and managing banner, interstitial, and rewarded video advertisements. ```APIDOC ## Bridge.advertisement.show_banner ### Description Displays a banner ad at the specified position. ### Method POST ### Parameters - **position** (BannerPosition) - Required - TOP or BOTTOM. ## Bridge.advertisement.show_interstitial ### Description Displays an interstitial ad, optionally with a specific placement identifier. ### Method POST ### Parameters - **placement** (String) - Optional - Identifier for the ad placement. ## Bridge.advertisement.show_rewarded ### Description Displays a rewarded video ad. The result is handled via the rewarded_state_changed signal. ### Method POST ### Parameters - **placement** (String) - Optional - Identifier for the ad placement. ``` -------------------------------- ### Leaderboards Module Source: https://context7.com/playgama/bridge-godot-4/llms.txt Provides functionality to submit scores and retrieve leaderboard entries. ```APIDOC ## Leaderboards Module ### Description The leaderboards module provides functionality to submit scores and retrieve leaderboard entries. ### Methods - **`submit_score(leaderboard_id: String, score: int)`**: Submits a player's score to a specified leaderboard. - **`get_leaderboard(leaderboard_id: String)`**: Retrieves leaderboard entries for a given leaderboard ID. - **`show_leaderboard_popup(leaderboard_id: String)`**: Displays a native leaderboard popup if supported. ### Callbacks - **`_on_score_submitted(success: bool)`**: Callback function invoked after a score submission attempt. - **`_on_entries_received(success: bool, entries: Array)`**: Callback function invoked after retrieving leaderboard entries. `entries` is an array of dictionaries, each containing `id`, `name`, `score`, `rank`, and `photo`. - **`_on_popup_closed(success: bool)`**: Callback function invoked when the native leaderboard popup is closed. ``` -------------------------------- ### Submit and Retrieve Leaderboard Scores (GDScript) Source: https://context7.com/playgama/bridge-godot-4/llms.txt This snippet demonstrates how to submit a player's score to a specified leaderboard and retrieve leaderboard entries. It includes callbacks for handling success or failure of these operations. Dependencies include the Bridge.leaderboards object. ```gdscript extends Node func _ready(): # Check leaderboard type: "not_available", "in_game", "native", "native_popup" print("Leaderboards Type: " + Bridge.leaderboards.type) # Submit a player's score func submit_score(leaderboard_id: String, score: int): Bridge.leaderboards.set_score(leaderboard_id, score, Callable(self, "_on_score_submitted")) func _on_score_submitted(success: bool): if success: print("Score submitted successfully!") else: print("Failed to submit score") # Get leaderboard entries func get_leaderboard(leaderboard_id: String): Bridge.leaderboards.get_entries(leaderboard_id, Callable(self, "_on_entries_received")) func _on_entries_received(success: bool, entries: Array): if success: print("Leaderboard loaded with " + str(entries.size()) + " entries") for entry in entries: print("Rank #" + str(entry.rank) + ": " + str(entry.name) + " - " + str(entry.score)) # Available fields: id, name, score, rank, photo else: print("Failed to load leaderboard") # Show native leaderboard popup (if supported) func show_leaderboard_popup(leaderboard_id: String): Bridge.leaderboards.show_native_popup(leaderboard_id, Callable(self, "_on_popup_closed")) func _on_popup_closed(success: bool): print("Leaderboard popup closed, success: " + str(success)) # Complete example: End of level flow func on_level_completed(level_id: String, score: int): # Submit to level-specific leaderboard var leaderboard_id = "level_" + level_id + "_highscore" submit_score(leaderboard_id, score) ``` -------------------------------- ### Constants and Enums Reference Source: https://context7.com/playgama/bridge-godot-4/llms.txt Lists the available constants and enums used within the Bridge SDK for various features like device types and visibility states. These provide standardized values for interacting with different SDK functionalities. ```gdscript # Device Types Bridge.DeviceType.DESKTOP # "desktop" Bridge.DeviceType.MOBILE # "mobile" Bridge.DeviceType.TABLET # "tablet" Bridge.DeviceType.TV # "tv" # Visibility States Bridge.VisibilityState.VISIBLE # "visible" Bridge.VisibilityState.HIDDEN # "hidden" ``` -------------------------------- ### Manage Achievements in Godot 4 Source: https://context7.com/playgama/bridge-godot-4/llms.txt Demonstrates how to check for achievement support, unlock achievements with platform-specific options, retrieve achievement lists, and trigger native popups. ```gdscript extends Node func unlock_achievement(achievement_id: String): var options = null match Bridge.platform.id: "y8": options = { "achievementkey": achievement_id, "achievement": "Achievement Name" } "lagged": options = { "achievement": achievement_id } _: options = { "id": achievement_id } Bridge.achievements.unlock(options, Callable(self, "_on_achievement_unlocked")) func load_achievements(): if Bridge.achievements.is_get_list_supported: Bridge.achievements.get_list(null, Callable(self, "_on_achievements_loaded")) func show_achievements_popup(): if Bridge.achievements.is_native_popup_supported: Bridge.achievements.show_native_popup(null, Callable(self, "_on_popup_closed")) ``` -------------------------------- ### Payments Module Source: https://context7.com/playgama/bridge-godot-4/llms.txt Handles in-app purchases including consumable and non-consumable items. ```APIDOC ## Payments Module ### Description The payments module handles in-app purchases including consumable and non-consumable items. ### Methods - **`load_product_catalog()`**: Loads the available products for purchase. - **`purchase_item(product_id: String)`**: Initiates a purchase for a given product ID. - **`purchase_item_with_options(product_id: String, developer_payload: String)`**: Initiates a purchase with additional developer-specified options. - **`consume_purchase(product_id: String)`**: Consumes a purchased item, typically used for consumable products. - **`check_pending_purchases()`**: Retrieves a list of pending or unacknowledged purchases. ### Callbacks - **`_on_catalog_loaded(success: bool, catalog: Array)`**: Callback function invoked after the product catalog is loaded. `catalog` is an array of product details, each with `id`, `price`, `priceCurrencyCode`, and `priceValue`. - **`_on_purchase_completed(success: bool, purchase)`**: Callback function invoked after a purchase attempt. `purchase` contains details of the transaction. - **`_on_consume_completed(success: bool, details)`**: Callback function invoked after a purchase consumption attempt. - **`_on_purchases_loaded(success: bool, purchases: Array)`**: Callback function invoked after retrieving pending purchases. `purchases` is an array of purchase details. ``` -------------------------------- ### Remote Config Module API Source: https://context7.com/playgama/bridge-godot-4/llms.txt Retrieves configuration values from the platform's remote configuration service. ```APIDOC ## Remote Config Module ### Description The remote config module allows retrieving configuration values from the platform's remote configuration service. ### Method `Bridge.remote_config.get(options, callback)` ### Endpoint `Bridge.remote_config.get` ### Parameters #### Path Parameters - **None** #### Query Parameters - **None** #### Request Body - **clientFeatures** (Array[Object]) - Optional. Client features for A/B testing (e.g., Yandex). - **name** (String) - The name of the feature. - **value** (String) - The value of the feature. ### Request Example ```gdscript var options = null match Bridge.platform.id: "yandex": options = { "clientFeatures": [ { "name": "player_coins", "value": "42" }, { "name": "player_level", "value": "dungeon_123" } ] } Bridge.remote_config.get(options, Callable(self, "_on_config_loaded")) ``` ### Response #### Success Response (200) - **data** (Dictionary) - A dictionary containing the remote configuration values. #### Response Example ```json { "success": true, "data": { "difficulty_multiplier": "1.5", "new_feature_enabled": "true" } } ``` #### Error Response (Non-200) - **success** (Boolean) - `false` if loading failed. - **data** (null) - `null` if loading failed. #### Error Response Example ```json { "success": false, "data": null } ``` ``` -------------------------------- ### Social Module API Source: https://context7.com/playgama/bridge-godot-4/llms.txt APIs for social interactions such as joining communities, inviting friends, adding to favorites, and prompting users for actions. ```APIDOC ## Social Module API ### Description This module handles various social interactions within the game. ### Endpoints #### Join Community ```gdscript func join_community(): var options = null match Bridge.platform.id: "vk": options = { "groupId": "199747461" } "ok": options = { "groupId": "62984239710374" } Bridge.social.join_community(options, Callable(self, "_on_joined_community")) func _on_joined_community(success: bool): if success: print("Joined community!") ``` #### Invite Friends ```gdscript func invite_friends(): var options = null match Bridge.platform.id: "ok": options = { "text": "Come play this awesome game with me!" } Bridge.social.invite_friends(options, Callable(self, "_on_friends_invited")) func _on_friends_invited(success: bool): if success: print("Friends invited!") ``` #### Add to Favorites ```gdscript func add_to_favorites(): Bridge.social.add_to_favorites(Callable(self, "_on_added_to_favorites")) func _on_added_to_favorites(success: bool): if success: print("Added to favorites!") ``` #### Prompt Add to Home Screen ```gdscript func prompt_add_to_home_screen(): Bridge.social.add_to_home_screen(Callable(self, "_on_added_to_home_screen")) func _on_added_to_home_screen(success: bool): if success: print("Added to home screen!") ``` #### Prompt Rate Game ```gdscript func prompt_rate_game(): Bridge.social.rate(Callable(self, "_on_rated")) func _on_rated(success: bool): if success: print("Thank you for rating!") ``` #### Grant Share Reward ```gdscript func grant_share_reward(): print("Granting share reward") ``` ``` -------------------------------- ### Social Features: Join Community, Invite Friends, Add to Favorites, Add to Home Screen, Rate Game Source: https://context7.com/playgama/bridge-godot-4/llms.txt Provides functions for interacting with social features of the platform. This includes joining a game community, inviting friends to play, adding the game to favorites, prompting users to add the game to their home screen on mobile, and prompting users to rate the game. These functions typically take optional parameters and a callback function to handle the result. ```gdscript func join_community(): var options = null match Bridge.platform.id: "vk": options = { "groupId": "199747461" } "ok": options = { "groupId": "62984239710374" } Bridge.social.join_community(options, Callable(self, "_on_joined_community")) func _on_joined_community(success: bool): if success: print("Joined community!") func invite_friends(): var options = null match Bridge.platform.id: "ok": options = { "text": "Come play this awesome game with me!" } Bridge.social.invite_friends(options, Callable(self, "_on_friends_invited")) func _on_friends_invited(success: bool): if success: print("Friends invited!") func add_to_favorites(): Bridge.social.add_to_favorites(Callable(self, "_on_added_to_favorites")) func _on_added_to_favorites(success: bool): if success: print("Added to favorites!") func prompt_add_to_home_screen(): Bridge.social.add_to_home_screen(Callable(self, "_on_added_to_home_screen")) func _on_added_to_home_screen(success: bool): if success: print("Added to home screen!") func prompt_rate_game(): Bridge.social.rate(Callable(self, "_on_rated")) func _on_rated(success: bool): if success: print("Thank you for rating!") func grant_share_reward(): print("Granting share reward") ``` -------------------------------- ### Configure Godot Canvas Styling Source: https://github.com/playgama/bridge-godot-4/blob/main/addons/playgama_bridge/template/index.html Defines the CSS styles for the Godot canvas and status elements. It ensures the canvas fills the viewport and handles the visibility of loading status indicators. ```css html, body, #canvas { margin: 0; padding: 0; border: 0; } body { color: white; background-color: black; overflow: hidden; touch-action: none; } #canvas { display: block; } #canvas:focus { outline: none; } #status { background-color: #242424; display: flex; flex-direction: column; justify-content: center; align-items: center; visibility: hidden; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.