Difference between revisions of "FBInstant.player.flushDataAsync"

From GiderosMobile
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
'''Available since:''' Gideros 2018.3<br/>
+
<languages />
=== Description ===
+
'''<translate>Available since</translate>:''' Gideros 2018.3<br/>
<br />
+
'''<translate>Class</translate>:''' [[Special:MyLanguage/Player|Player]]<br/>
 +
=== <translate>Description</translate> ===
 +
<translate><br />
 
Immediately flushes any changes to the player data to the designated cloud storage. This function is expensive, and should primarily be used for critical changes where persistence needs to be immediate and known by the game. Non-critical changes should rely on the platform to persist them in the background. NOTE: Calls to player.setDataAsync will be rejected while this function's result is pending.<br />
 
Immediately flushes any changes to the player data to the designated cloud storage. This function is expensive, and should primarily be used for critical changes where persistence needs to be immediate and known by the game. Non-critical changes should rely on the platform to persist them in the background. NOTE: Calls to player.setDataAsync will be rejected while this function's result is pending.<br />
<br />
+
<br /></translate>
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
  FBInstant.player.flushDataAsync(callback)
 
  FBInstant.player.flushDataAsync(callback)
</source>
+
</syntaxhighlight>
'''callback''': (function) A function that will be called with two arguments: true when changes have been persisted successfully or nil if the operation failed, and an error code if the function failed. ''''''<br/>
+
=== <translate>Parameters</translate> ===
 +
'''callback''': (function) <translate>A function that will be called with two arguments: true when changes have been persisted successfully or nil if the operation failed, and an error code if the function failed.</translate> <br/>
 +
=== <translate>Examples</translate> ===
 +
'''Example'''<br/>
 +
<syntaxhighlight lang="lua">
 +
FBInstant.player.setDataAsync({achievements={"medal1","medal2","medal3"},currentLife=300}, function(result,error)
 +
    if result then
 +
FBInstant.player.flushDataAsync(function (result,error)
 +
if result then
 +
print("Data persisted to FB!")
 +
end
 +
end)
 +
end
 +
end)
 +
<br/></syntaxhighlight>
 +
 
 +
{{FBInstant.player}}

Latest revision as of 14:29, 13 July 2023


Available since: Gideros 2018.3
Class: Player

Description


Immediately flushes any changes to the player data to the designated cloud storage. This function is expensive, and should primarily be used for critical changes where persistence needs to be immediate and known by the game. Non-critical changes should rely on the platform to persist them in the background. NOTE: Calls to player.setDataAsync will be rejected while this function's result is pending.

 FBInstant.player.flushDataAsync(callback)

Parameters

callback: (function) A function that will be called with two arguments: true when changes have been persisted successfully or nil if the operation failed, and an error code if the function failed.

Examples

Example

FBInstant.player.setDataAsync({achievements={"medal1","medal2","medal3"},currentLife=300}, function(result,error)
    if result then
		FBInstant.player.flushDataAsync(function (result,error)
			if result then
				print("Data persisted to FB!")
			end
		end)
	end
end)
<br/>