Playgama
  • Welcome
  • 🚀Quick start
  • Submitting a game
  • Game Requirments
    • 💥Self-check
    • Technical Requirements
    • Advertising Requirements
    • User Experience Requirements
    • Content Requirements
    • Other Requirements
    • Platform-Specific Requirements
  • In-Game Purchases
    • Step-by-step IAP integration guide for Unity
  • FAQ
    • General
    • Submitting a Game
    • Game Moderation
    • Payments and Statistics
  • SDK
    • Getting started
    • Engines
      • Core (Plain JS)
        • 💥Intro
        • Setup
        • Platform Parameters
        • User Data
        • Advertising
          • Banner
          • Interstitial
          • Rewarded
          • AdBlock
        • User Parameters
        • Social Interactions
        • Leaderboards
        • Achievements
        • In-Game Purchases
        • Remote Configuration
      • Unity
        • 💥Intro
        • Setup
        • Platform Parameters
        • User Data
        • Advertising
          • Banner
          • Interstitial
          • Rewarded
          • AdBlock
        • User Parameters
        • Social Interactions
        • Leaderboards
        • Achievements
        • In-Game Purchases
        • Remote Configuration
      • Construct 3
        • 💥Intro
        • Setup
        • Platform Parameters
        • User Data
        • Advertising
          • Banner
          • Interstitial
          • Rewarded
          • AdBlock
        • User Parameters
        • Social Interactions
        • Leaderboards
        • Achievements
        • In-Game Purchases
        • Remote Configuration
      • GDevelop
        • 💥Intro
        • Setup
        • Platform Parameters
        • User Data
        • Advertising
          • Banner
          • Interstitial
          • Rewarded
          • AdBlock
        • User Parameters
        • Social Interactions
        • Leaderboards
        • Achievements
        • In-Game Purchases
        • Remote Configuration
      • Godot
        • 💥Intro
        • Setup
        • Platform Parameters
        • User Data
        • Advertising
          • Banner
          • Interstitial
          • Rewarded
          • AdBlock
        • User Parameters
        • Social Interactions
        • Leaderboards
        • Achievements
        • In-Game Purchases
        • Remote Configuration
      • Game Maker
        • 💥Intro
        • Setup
        • Platform Parameters
        • User Data
        • Advertising
          • Banner
          • Interstitial
          • Rewarded
          • AdBlock
        • User Parameters
        • Social Interactions
        • Leaderboards
        • Achievements
        • In-Game Purchases
        • Remote Configuration
      • Defold
        • 💥Intro
        • Setup
        • Platform Parameters
        • User Data
        • Advertising
          • Banner
          • Interstitial
          • Rewarded
          • AdBlock
        • User Parameters
        • Social Interactions
        • Leaderboards
        • Achievements
        • In-Game Purchases
        • Remote Configuration
    • Playgama Bridge Config
    • Changelog
  • For Partners
    • Getting Started
    • Embed the Widget
      • Adding Games Widget to Your WordPress Site
      • Adding Games Widget to Your Tilda Site
      • Adding Games Widget to Your Framer Site
    • Import the Game Catalog
    • Share your referral link
Powered by GitBook
On this page
  1. SDK
  2. Engines
  3. Defold

User Data

PreviousPlatform ParametersNextAdvertising

Last updated 3 months ago

Store and manage player data to enhance gameplay experience and retain progress.

There are two types of storage: local_storage and platform_internal. When writing to local storage, data is saved on the player's device. When writing to internal storage, data is saved on the platform's servers.

If you need to call storage methods in a sequence, make sure you wait for previous call to finish, so there is no potential data collisions.

Current Storage Type

Identify the default storage type to understand where data is being saved (local or server).

bridge.storage.default_type()

Possible values: local_storage, platform_internal.

Support Check

Verify if the specified storage type is supported on the platform to ensure compatibility.

bridge.storage.is_supported("local_storage")
bridge.storage.is_supported("platform_internal")

Availability Check

Check if the specified storage type is currently available for use to manage data storage effectively.

bridge.storage.is_available("local_storage")
bridge.storage.is_available("platform_internal")

Load Data

Retrieve stored data based on a key or multiple keys to restore player progress or settings.

local bridge = require("bridge.bridge")

function init(self)	
	bridge.storage.get(
		{ "coins", "level" }, 
		function (_, data)
			if data.coins then
				print("Coins: ", data.coins)
			end
			if data.level then
				print("Level: ", data.level)
			end
		end, 
		function ()
			-- error
		end
	)
end

Save data to the specified storage with a key to retain player progress or settings.

local bridge = require("bridge.bridge")

function init(self)	
	bridge.storage.set(
		{ coins = 42, level = "dungeon" }, 
		function (_)
			-- success
		end, 
		function (_)
			-- error
		end
	)	
end

Delete Data

Remove data from the specified storage by key to manage player data and settings effectively.

local bridge = require("bridge.bridge")

function init(self)	
	bridge.storage.delete(
		{ "coins", "level" }, 
		function ()
			-- success
		end, 
		function ()
			-- error
		end
	)
end

All data operations interact with the default storage type. You can specify the storage type as the second argument. Ensure the storage is supported and available before using it.

brdige.storage.get(table_keys, on_success, on_error, storage_type)
brdige.storage.set(table, on_success, on_error, storage_type)
brdige.storage.delete(table_keys, on_success, on_error, storage_type)

Save Data