refactor: LuaState replaced with lua_engine
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
#include "scripting_hud.hpp"
|
||||
#include "scripting.hpp"
|
||||
|
||||
#include "lua/lua_util.hpp"
|
||||
#include "lua/api_lua.hpp"
|
||||
#include "lua/LuaState.hpp"
|
||||
#include "lua/lua_engine.hpp"
|
||||
|
||||
#include "../../debug/Logger.hpp"
|
||||
#include "../../frontend/hud.hpp"
|
||||
@@ -11,9 +10,6 @@
|
||||
#include "../../files/files.hpp"
|
||||
#include "../../engine.hpp"
|
||||
|
||||
namespace scripting {
|
||||
extern lua::LuaState* state;
|
||||
}
|
||||
using namespace scripting;
|
||||
|
||||
static debug::Logger logger("scripting-hud");
|
||||
@@ -22,10 +18,10 @@ Hud* scripting::hud = nullptr;
|
||||
|
||||
void scripting::on_frontend_init(Hud* hud) {
|
||||
scripting::hud = hud;
|
||||
state->openlib(state->getMainThread(), "hud", hudlib);
|
||||
lua::openlib(lua::get_main_thread(), "hud", hudlib);
|
||||
|
||||
for (auto& pack : engine->getContentPacks()) {
|
||||
state->emitEvent(state->getMainThread(), pack.id + ".hudopen",
|
||||
lua::emit_event(lua::get_main_thread(), pack.id + ".hudopen",
|
||||
[&] (lua_State* L) {
|
||||
return lua::pushinteger(L, hud->getPlayer()->getId());
|
||||
});
|
||||
@@ -34,7 +30,7 @@ void scripting::on_frontend_init(Hud* hud) {
|
||||
|
||||
void scripting::on_frontend_close() {
|
||||
for (auto& pack : engine->getContentPacks()) {
|
||||
state->emitEvent(state->getMainThread(), pack.id + ".hudclose",
|
||||
lua::emit_event(lua::get_main_thread(), pack.id + ".hudclose",
|
||||
[&] (lua_State* L) {
|
||||
return lua::pushinteger(L, hud->getPlayer()->getId());
|
||||
});
|
||||
@@ -47,7 +43,7 @@ void scripting::load_hud_script(const scriptenv& senv, const std::string& packid
|
||||
std::string src = files::read_string(file);
|
||||
logger.info() << "loading script " << file.u8string();
|
||||
|
||||
lua::execute(state->getMainThread(), env, src, file.u8string());
|
||||
lua::execute(lua::get_main_thread(), env, src, file.u8string());
|
||||
|
||||
register_event(env, "init", packid+".init");
|
||||
register_event(env, "on_hud_open", packid+".hudopen");
|
||||
|
||||
Reference in New Issue
Block a user