Appearance
云服模块管理接口 CloudSever
具体函数名及描述如下:
| 序号 | 函数名 | 函数描述 |
|---|---|---|
| 1 | SetDataListBykey(...) | 设置表中指定键的值 |
| 2 | GetDataListByKey(...) | 获取表中指定键的值 |
| 3 | GetRoomID(...) | 获取当前云服房间ID |
SetDataListBykey
- 参数及类型: libvarid:string:表变量设计名,key:string:获取的键值,value:Any:任意值(number,string,table)
- 返回值及类型:
- ret:
boolean成功(true)
- ret:
- 该方法的主要作用: 设置表中指定键的值
- 具体使用案例如下:
lua
local result = CloudSever:SetDataListBykey("datalist_1744283491", "num", 123)GetDataListByKey
- 参数及类型: libvarid:string:表变量设计名,key:string:获取的键值,callback:function:更新回调(function(code/错误码...)0成功1失败2数据不存在)
- 返回值及类型:
- 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
- 参数及类型: 无
- 返回值及类型: ret:boolean:成功(true),roomid:string:房间ID
- 该方法的主要作用: 获取当前云服房间ID
- 具体使用案例如下:
lua
--仅云服生效
local roomID = CloudSever:GetRoomID()
print("房间ID:" .. roomID)