Appearance
全局函数
具体函数名及描述如下:
序号 | 函数名 | 函数描述 |
---|---|---|
1 | json.decode(...) | json格式字符串转换table数据 |
2 | json.encode(...) | table数据转换json格式字符串 |
3 | GetWorld() | 获取当前世界对象 |
4 | print(...) | 打印信息 |
5 | printError(...) | 打印错误信息 |
6 | Class(...) | 定义类 |
7 | Instance(...) | 创建类实例 |
8 | GetInst() | 获取类单例 |
json.decode
lua
local tab = json.decode('{"a":1,"b":2}')
json.encode
lua
local jsonstr = json.encode({a=1,b=2})
GetWorld
- 参数及类型:
- 无
- 返回值及类型:
- ret:
table
世界对象
- ret:
- 该方法的主要作用: 获取当前世界对象
lua
local world = GetWorld()
print
- 参数及类型:
- ...:number 或者 string 或者 boolean: 只能传这三种类型数据的不定参数
- 返回值及类型:
- 无
- 该方法的主要作用: 打印信息
lua
print("hello ",1,true)
printError
- 参数及类型:
- ...:number 或者 string 或者 boolean: 只能传这三种类型数据的不定参数
- 返回值及类型:
- 无
- 该方法的主要作用: 打印错误信息
lua
printError("hello ",1,true)
Class
- 参数及类型:
- 返回值及类型:
- ret:
table
对象定义
- ret:
- 该方法的主要作用: 定义类对象
- 具体使用案例如下:
lua
local classdef = Class("Abc", {}, true)
Instance
lua
local instance = Instance("Abc")
if not instance then
printError("创建实例失败 请检查类定义issingle 参数是否是false")
end
GetInst
lua
local instance = GetInst("Abc")
if not instance then
printError("获取单例失败 请检查类定义 issingle 参数是否是false")
end