* lua使用基础
This commit is contained in:
@@ -1,7 +1,31 @@
|
||||
#include "dl_lua.h"
|
||||
|
||||
#define LUA_USE_APICHECK
|
||||
#include <lua.hpp>
|
||||
namespace dl
|
||||
{
|
||||
LuaScript* g_lua;
|
||||
|
||||
LuaScript::LuaScript()
|
||||
{
|
||||
L = luaL_newstate();
|
||||
luaL_openlibs(L);
|
||||
}
|
||||
|
||||
LuaScript::~LuaScript()
|
||||
{
|
||||
lua_close(L);
|
||||
}
|
||||
|
||||
bool LuaScript::DoFile(std::string_view path_name)
|
||||
{
|
||||
int ret = luaL_dofile(L, path_name.data());
|
||||
if (ret)
|
||||
{
|
||||
log_err("lua do file失败!{}", path_name);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user