gamecircle.Whispersync.SetLatestNumber

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

概述

设置与键关联的最新数字值。仅存储最后分配的值。

语法

gamecircle.Whispersync.SetLatestNumber(key, value, NT_constant)
gamecircle.Whispersync.SetLatestNumber(key, value, NT_constant, metadata)
(必填)

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

(必填)

数字. 要分配给最新数字的值。

NT_常量 (必填)

字符串. NT_常量,值为“INT”或“DOUBLE”,决定了最新数字的存储方式。“INT”会截断小数部分。“DOUBLE”会保留完整的小数部分。如果给定的字符串无效,则默认使用“INT”。

元数据 (可选)

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

示例

local latestNumKey = "myFirstLatestNumber" 
local gamecircle = require("plugin.gamecircle")  
gamecircle.Init(false, false, true)  
gamecircle.Whispersync.SetLatestNumber(latestNumKey, 10, "INT")  
gamecircle.Whispersync.SetLatestNumber(latestNumKey, 1000, "INT")  
gamecircle.Whispersync.SetLatestNumber(latestNumKey, 1, "INT")  
gamecircle.Whispersync.SetLatestNumber(latestNumKey, 10000, "INT")  
gamecircle.Whispersync.SetLatestNumber(latestNumKey, 100, "INT")  
print("The Latest Number is: " .. gamecircle.Whispersync.GetLatestNumber(latestNumKey, "INT").value)  
print("These are all the Latest Number values stored under the current GameData set of Whispersync.")  
local keys = gamecircle.Whispersync.GetLatestNumberKeys()  
for i,key in ipairs(keys) do   
    print("-" .. key)  
end