gamecircle.Whispersync.AddToLowNumberList

类型 函数
gamecircle.*
返回的值
修订版 发行版 2024.3703
关键字 低、列表、可同步数字列表、Whispersync

概述

向低数字列表添加一个值。如果该数字小于列表中存储的最大数字,则会被添加。然后,如果列表超过其最大长度,则整个列表中当前最大的数字会被截断。

语法

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

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

value (必需)

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

NT_constant (必需)

字符串. NT_constant,为 “INT” 或 “DOUBLE”,它确定如何存储最低数字。 “INT” 截断小数位值。 “DOUBLE” 保持小数位值不变。如果给定的字符串无效,则默认使用 “INT”。

metadata (可选)

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

示例

local lowListKey = "myFirstLowNumberList" 
local gamecircle = require("plugin.gamecircle")  
gamecircle.Init(false, false, true)  
gamecircle.Whispersync.SetLowNumberListLength(lowListKey, 4)  
gamecircle.Whispersync.AddToLowNumberList(lowListKey, 10, "INT")  
gamecircle.Whispersync.AddToLowNumberList(lowListKey, 1000, "INT")  
gamecircle.Whispersync.AddToLowNumberList(lowListKey, 1, "INT")  
gamecircle.Whispersync.AddToLowNumberList(lowListKey, 10000, "INT")   
gamecircle.Whispersync.AddToLowNumberList(lowListKey, 100, "INT")  
print("Here is the list of numbers as they are stored in the low number list. They should be in the order from lowest to highest.")  
local lowList = gamecircle.Whispersync.GetLowNumberList(lowListKey)  
for i,entry in ipairs(lowList) do  
    print("-" entry.value)  
end  
local keys = gamecircle.Whispersync.GetLowNumberListKeys()  
for i,key in ipairs(keys) do  
    print("-" .. key)  
end