gamecircle.Whispersync.AddToHighNumberList

类型 函数
gamecircle.*
返回值
修订版 发行版 2024.3703
关键词 最高、列表、Whispersync

概述

向 HighNumberList 中添加值。如果该数字高于列表中存储的最低数字,那么将添加该数字。然后,如果列表超出其最大长度,则将修剪掉整个列表中当前最低的数字。

语法

gamecircle.Whispersync.AddToHighNumberList(key, value, NT_constant)
gamecircle.Whispersync.AddToHighNumberList(key, value, NT_constant, metadata)
key (必需)

String. 用于访问特定最高数字的键。

value (必需)

Number. 分配给最高数字的值。

NT_constant (必需)

String. NT_constant(即“INT”或“DOUBLE”)确定如何存储最高数字。“INT”截去小数部分。“DOUBLE”保持小数部分不变。如果给定的字符串无效,则默认使用“INT”。

metadata (可选)

Metadata. 要与数字一起存储的元数据表。它必须是一个仅由字段中具有字符串值的字符串字段组成的 lua 表。有关示例和详细信息,请查看元数据的文档页面。

示例

local highListKey = "myFirstHighNumberList" 
local gamecircle = require("plugin.gamecircle")  
gamecircle.Init(false, false, true)  
gamecircle.Whispersync.SetHighNumberListLength(highListKey, 4)  
gamecircle.Whispersync.AddToHighNumberList(highListKey, 10, "INT")  
gamecircle.Whispersync.AddToHighNumberList(highListKey, 1000, "INT")  
gamecircle.Whispersync.AddToHighNumberList(highListKey, 1, "INT")  
gamecircle.Whispersync.AddToHighNumberList(highListKey, 10000, "INT")   
gamecircle.Whispersync.AddToHighNumberList(highListKey, 100, "INT")  
print("Here is the list of numbers as they are stored in the high number list. They should be in the order from highest to lowest.")  
local highList = gamecircle.Whispersync.GetHighNumberList(highListKey)  
for i,entry in ipairs(highList) do  
    print("-" entry.value)  
end  
local keys = gamecircle.Whispersync.GetHighNumberListKeys()  
for i,key in ipairs(keys) do  
    print("-" .. key)  
end