gamecircle.Whispersync.GetLatestNumberList

类型 函数
gamecircle.*
返回值 SyncableNumber
修订版本 版本 2024.3703
关键词 最新, 列表, SyncableNumberList, Whispersync

概述

将最新的数字列表作为 SyncableNumberList 返回。

语法

local syncNumList = gamecircle.Whispersync.GetLatestNumberList(key, NT_constant)
(必填)

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

NT_常量 (必填)

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

示例

local latestListKey = "myFirstLatestNumberList" 
local gamecircle = require("plugin.gamecircle")  
gamecircle.Init(false, false, true)  
gamecircle.Whispersync.SetLatestNumberListLength(latestListKey, 4)  
gamecircle.Whispersync.AddToLatestNumberList(latestListKey, 10, "INT")  
gamecircle.Whispersync.AddToLatestNumberList(latestListKey, 1000, "INT")  
gamecircle.Whispersync.AddToLatestNumberList(latestListKey, 1, "INT")  
gamecircle.Whispersync.AddToLatestNumberList(latestListKey, 10000, "INT")   
gamecircle.Whispersync.AddToLatestNumberList(latestListKey, 100, "INT")  
print("Here is the list of numbers as they are stored in the latest number list. They should be in the order from latest to oldest.")  
local latestList = gamecircle.Whispersync.GetLatestNumberList(latestListKey)  
for i,entry in ipairs(latestList) do  
    print("-" entry.value)  
end  
local keys = gamecircle.Whispersync.GetLatestNumberListKeys()  
for i,key in ipairs(keys) do  
    print("-" .. key)  
end