Files
dl_old/dl/script/dl_lua.cpp
T
2025-01-11 18:16:11 +08:00

36 lines
524 B
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "dl_lua.h"
#define LUA_USE_APICHECK
#include <lua.hpp>
#include "dl_lua_register.h"
namespace dl
{
LuaScript* g_lua;
LuaScript::LuaScript()
{
L = luaL_newstate();
luaL_openlibs(L);
lua_register_all(L);
}
LuaScript::~LuaScript()
{
lua_close(L);
}
bool LuaScript::DoFile(std::string_view path_name)
{
int ret = luaL_dofile(L, (_pathRoot + path_name).data());
if (ret)
{
log_err("lua 执行失败:[{}]:{}", path_name, lua_tostring(L, -1));
return false;
}
return true;
}
}