Store and manage player data to enhance gameplay experience and retain progress.
There are two types of storage: local (local_storage) and internal (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.
Default Storage Type
Identify the default storage type to understand where data is being saved (local or server).
Bridge.storage.default_type
Used automatically if no specific storage type is specified when working with data. 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")# To use constants for convenience:Bridge.storage.is_supported(Bridge.StorageType.LOCAL_STORAGE)Bridge.storage.is_supported(Bridge.StorageType.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")# To use constants for convenience:Bridge.storage.is_available(Bridge.StorageType.LOCAL_STORAGE)Bridge.storage.is_available(Bridge.StorageType.PLATFORM_INTERNAL)
Load Data
Retrieve stored data based on a key or multiple keys to restore player progress or settings.
# Load data by keyfunc_ready():Bridge.storage.get("level", funcref(self,"_on_storage_get_completed"))func_on_storage_get_completed(success,data):if success:if data !=null:print(data)else:# No data for the key 'level'print("Data is null")# Load data by multiple keysfunc_ready():Bridge.storage.get(["level", "coins"], funcref(self,"_on_storage_get_completed"))func_on_storage_get_completed(success,data):if success:if data[0] !=null:print("Level: ", data[0])else:# No data for the key 'level'print("Level is null")if data[1] !=null:print("Coins: ", data[1])else:# No data for the key 'coins'print("Coins is null")# Load data from a specific storage typeBridge.storage.get("level", funcref(self,"_on_storage_get_completed"), Bridge.StorageType.LOCAL_STORAGE)
# Load data by keyfunc_ready():Bridge.storage.get("level", Callable(self,"_on_storage_get_completed"))func_on_storage_get_completed(success,data):if success:if data !=null:print(data)else:# No data for the key 'level'print("Data is null")# Load data by multiple keysfunc_ready():Bridge.storage.get(["level", "coins"], Callable(self,"_on_storage_get_completed"))func_on_storage_get_completed(success,data):if success:if data[0] !=null:print("Level: ", data[0])else:# No data for the key 'level'print("Level is null")if data[1] !=null:print("Coins: ", data[1])else:# No data for the key 'coins'print("Coins is null")# Load data from a specific storage typeBridge.storage.get("level", Callable(self,"_on_storage_get_completed"), Bridge.StorageType.LOCAL_STORAGE)
Save Data
Save data to the specified storage with a key to retain player progress or settings.
# Save data by keyfunc_ready():Bridge.storage.set("level","dungeon_123", funcref(self,"_on_storage_set_completed"))func_on_storage_set_completed(success):print("On Storage Set Completed, success: ", success)# Save data by multiple keysBridge.storage.set(["level", "is_tutorial_completed", "coins"], ["dungeon_123", true, 42], funcref(self, "_on_storage_set_completed"))
# Save data to a specific storage typeBridge.storage.set("level", "dungeon_123", funcref(self, "_on_storage_set_completed"), Bridge.StorageType.LOCAL_STORAGE)
# Save data by keyfunc_ready():Bridge.storage.set("level","dungeon_123", Callable(self,"_on_storage_set_completed"))func_on_storage_set_completed(success):print("On Storage Set Completed, success: ", success)# Save data by multiple keysBridge.storage.set(["level", "is_tutorial_completed", "coins"], ["dungeon_123", true, 42], Callable(self, "_on_storage_set_completed"))
# Save data to a specific storage typeBridge.storage.set("level", "dungeon_123", Callable(self, "_on_storage_set_completed"), Bridge.StorageType.LOCAL_STORAGE)
Delete Data
Remove data from the specified storage by key to manage player data and settings effectively.
# Delete data by keyfunc_ready():Bridge.storage.delete("level", funcref(self,"_on_storage_delete_completed"))func_on_storage_delete_completed(success):print("On Storage Delete Completed, success: ", success)# Delete data by multiple keysBridge.storage.delete(["level", "is_tutorial_completed", "coins"], funcref(self,"_on_storage_delete_completed"))# Delete data from a specific storage typeBridge.storage.delete("level", funcref(self,"_on_storage_delete_completed"), Bridge.StorageType.LOCAL_STORAGE)
# Delete data by keyfunc_ready():Bridge.storage.delete("level", Callable(self,"_on_storage_delete_completed"))func_on_storage_delete_completed(success):print("On Storage Delete Completed, success: ", success)# Delete data by multiple keysBridge.storage.delete(["level", "is_tutorial_completed", "coins"], Callable(self,"_on_storage_delete_completed"))# Delete data from a specific storage typeBridge.storage.delete("level", Callable(self,"_on_storage_delete_completed"), Bridge.StorageType.LOCAL_STORAGE)
If no specific storage type is passed as the third argument when working with data, the default storage type Bridge.storage.default_type is used.