dl
首页
相关页面
命名空间
类
文件
文件列表
文件成员
dl
script
dl_lua.h
浏览该文件的文档.
1
15
#pragma once
16
17
#include <string>
18
#include <unordered_map>
19
20
#define LUA_USE_APICHECK
21
#include <lua.hpp>
22
#include <LuaBridge/LuaBridge.h>
23
24
#include "
dl_io.h
"
25
26
struct
lua_State;
27
namespace
dl
28
{
29
class
LuaScript
30
{
31
public
:
32
LuaScript
();
33
~LuaScript
();
34
35
struct
Env
36
{
37
//std::string _funcUpdate;
38
};
39
40
bool
DoFile
(std::string_view path_name);
41
42
bool
ExcuteFunction
(std::string_view name)
43
{
44
luabridge::LuaRef v = luabridge::getGlobal(L, name.data());
45
luabridge::LuaResult ret = v();
46
if
(ret.hasFailed())
47
{
48
log_warn
(
"{}"
, ret.errorMessage());
49
return
false
;
50
}
51
// todo ret
52
return
true
;
53
}
54
template
<
typename
T
,
typename
...Args>
55
bool
ExcuteFunction
(std::string_view name, Args&&... args)
56
{
57
luabridge::LuaRef v = luabridge::getGlobal(L, name.data());
58
luabridge::LuaResult ret = v(args);
59
if
(ret.hasFailed())
60
{
61
log_warn
(
"{}"
, ret.errorMessage());
62
return
false
;
63
}
64
// todo ret
65
return
true
;
66
}
67
68
Env
&
GetEnv
() {
return
_env; }
69
lua_State*
GetL
() {
return
L; }
70
private
:
71
lua_State*
L
;
72
Env _env;
73
};
74
75
extern
LuaScript*
g_lua
;
76
}
dl::LuaScript::LuaScript
LuaScript()
dl::LuaScript::GetEnv
Env & GetEnv()
定义
dl_lua.h:68
dl::LuaScript::DoFile
bool DoFile(std::string_view path_name)
dl::LuaScript::ExcuteFunction
bool ExcuteFunction(std::string_view name, Args &&... args)
定义
dl_lua.h:55
dl::LuaScript::ExcuteFunction
bool ExcuteFunction(std::string_view name)
定义
dl_lua.h:42
dl::LuaScript::~LuaScript
~LuaScript()
dl::LuaScript::GetL
lua_State * GetL()
定义
dl_lua.h:69
dl_io.h
io相关
log_warn
#define log_warn(...)
定义
dl_log.h:214
dl
定义
dl_array2.h:18
dl::KeyCode::T
@ T
定义
dl_input.h:120
dl::KeyCode::L
@ L
定义
dl_input.h:112
dl::g_lua
LuaScript * g_lua
dl::LuaScript::Env
定义
dl_lua.h:36
制作者
1.13.1