mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
debug::Logger
This commit is contained in:
parent
f298d6ef1d
commit
0c411cf227
16 changed files with 233 additions and 51 deletions
|
|
@ -1,52 +0,0 @@
|
|||
#include "scripting_frontend.h"
|
||||
#include "scripting.h"
|
||||
|
||||
#include "lua/api_lua.h"
|
||||
#include "lua/LuaState.h"
|
||||
|
||||
#include "../../frontend/hud.h"
|
||||
#include "../../objects/Player.h"
|
||||
#include "../../files/files.h"
|
||||
#include "../../engine.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace scripting {
|
||||
extern lua::LuaState* state;
|
||||
}
|
||||
|
||||
Hud* scripting::hud = nullptr;
|
||||
|
||||
void scripting::on_frontend_init(Hud* hud) {
|
||||
scripting::hud = hud;
|
||||
scripting::state->openlib("hud", hudlib, 0);
|
||||
|
||||
for (auto& pack : scripting::engine->getContentPacks()) {
|
||||
emit_event(pack.id + ".hudopen", [&] (lua::LuaState* state) {
|
||||
state->pushinteger(hud->getPlayer()->getId());
|
||||
return 1;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void scripting::on_frontend_close() {
|
||||
for (auto& pack : scripting::engine->getContentPacks()) {
|
||||
emit_event(pack.id + ".hudclose", [&] (lua::LuaState* state) {
|
||||
state->pushinteger(hud->getPlayer()->getId());
|
||||
return 1;
|
||||
});
|
||||
}
|
||||
scripting::hud = nullptr;
|
||||
}
|
||||
|
||||
void scripting::load_hud_script(int env, std::string packid, fs::path file) {
|
||||
std::string src = files::read_string(file);
|
||||
std::cout << "loading script " << file.u8string() << std::endl;
|
||||
|
||||
state->loadbuffer(env, src, file.u8string());
|
||||
state->callNoThrow(0);
|
||||
|
||||
register_event(env, "init", packid+".init");
|
||||
register_event(env, "on_hud_open", packid+".hudopen");
|
||||
register_event(env, "on_hud_close", packid+".hudclose");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue