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