gamecircle.Whispersync.AddToStringSet

类型 函数
gamecircle.*
返回值
版本 2024.3703 版
关键字 最高、列表、Whispersync

概述

将一个值添加到一个字符串集中,其中可以包含 Metadata

语法

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

String。用于访问特定字符串集的密钥。

value (必填)

String。要添加到字符串集的值。

metadata (可选)

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

示例

local stringSetKey = "myFirstStringSet" 
local gamecircle = require("plugin.gamecircle")   
gamecircle.Init(false, false, true)  
gamecircle.Whispersync.AddToStringSet("A")  
gamecircle.Whispersync.AddToStringSet("B")  
gamecircle.Whispersync.AddToStringSet("C")  
gamecircle.Whispersync.AddToStringSet("D")  
gamecircle.Whispersync.AddToStringSet("E")  
print("Does the set contain F?: " .. gamecircle.Whispersync.StringSetContains(stringSetKey, "F"))  
print("Here is what the string set does contain:")  
local stringSet = gamecircle.Whispersync.GetStringSet(stringSetKey)  
for i,entry in ipairs(stringSet) do  
    print("-" entry.value)  
end  
print("The extra for element A is:")  
local entryA = gamecircle.Whispersync.GetStringSetValue("A")  
print("-value: " .. entryA.value)  
print("-isSet: " .. entryA.isSet)  
print("-metadataPresent: " .. entryA.metadataPresent)  
print("-timestamp: " .. entryA.timestamp)  
local keys = gamecircle.Whispersync.GetHighNumberListKeys()   
for i,key in ipairs(keys) do  
    print("-" .. key)  
end