gamecircle.Whispersync.SetLatestString

类型 函数
gamecircle.*
返回值
修订版本 版本 2024.3703
关键词 最新, 可同步字符串, Whispersync

概述

将值设置为与键关联的最新字符串。仅存储分配的最新值。

语法

gamecircle.Whispersync.SetLatestString(key, value)
gamecircle.Whispersync.SetLatestString(key, value, metadata)
(必填)

字符串. 用于访问特定最新字符串的键。

(必填)

字符串. 要分配给最新字符串的值。

元数据 (可选)

元数据. 要与字符串一起存储的元数据表。它必须是一个 Lua 表,仅包含字符串字段,并且这些字段中包含字符串值。有关示例和更多信息,请查看元数据的文档页面。

示例

local latestNumKey = "myFirstLatestString"  
local gamecircle = require("plugin.gamecircle")  
gamecircle.Init(false, false, true)  
gamecircle.Whispersync.SetLatestString(latestNumKey, "A")
gamecircle.Whispersync.SetLatestString(latestNumKey, "B") 
gamecircle.Whispersync.SetLatestString(latestNumKey, "C")
gamecircle.Whispersync.SetLatestString(latestNumKey, "D") 
gamecircle.Whispersync.SetLatestString(latestNumKey, "E") 
print("The Latest String is: " .. gamecircle.Whispersync.GetLatestString(latestNumKey, "INT").value)  
print("These are all the Latest String values stored under the current GameData set of Whispersync.")  
local keys = gamecircle.Whispersync.GetLatestStringKeys()  
for i,key in ipairs(keys) do   
    print("-" .. key)  
end