Appearance
云服模块管理接口 CloudSever
具体函数名及描述如下:
序号 | 函数名 | 函数描述 |
---|---|---|
1 | SetDataListBykey(...) | 设置表中指定键的值 |
2 | GetDataListByKey(...) | 获取表中指定键的值 |
3 | GetRoomID(...) | 获取当前云服房间ID |
SetDataListBykey
- 参数及类型:
- 返回值及类型:
- ret:
boolean
成功(true)
- ret:
- 该方法的主要作用: 设置表中指定键的值
- 具体使用案例如下:
lua
local result = CloudSever:SetDataListBykey("datalist_1744283491", "num", 123)
GetDataListByKey
- 参数及类型:
- 返回值及类型:
- ret:
boolean
成功(true)
- ret:
- 该方法的主要作用: 获取表中指定键的值
- 具体使用案例如下:
lua
CloudSever:GetDataListByKey("datalist_1744283491", "num", function (code, key, data)
-- 成功
if code == 0 then
value = data
isSuccess = true
print("获取成功")
elseif code == 1 then
isSuccess = false
print("获取失败")
elseif code == 2 then
isSuccess = false
print("数据不存在")
end
end)
GetRoomID
lua
--仅云服生效
local roomID = CloudSever:GetRoomID()
print("房间ID:" .. roomID)