User Data
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

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)
Last updated