added hud.lua script

This commit is contained in:
MihailRis
2024-02-18 12:45:37 +03:00
parent 33d14be71c
commit dabf42162c
5 changed files with 76 additions and 10 deletions
+11
View File
@@ -21,6 +21,7 @@
#include "../objects/Player.h"
#include "../logic/ChunksController.h"
#include "../logic/LevelController.h"
#include "../logic/scripting/scripting.h"
#include "../logic/scripting/scripting_frontend.h"
#include "../voxels/Chunks.h"
#include "../voxels/Chunk.h"
@@ -97,11 +98,21 @@ LevelScreen::LevelScreen(Engine* engine, Level* level)
animator.reset(new TextureAnimator());
animator->addAnimations(engine->getAssets()->getAnimations());
auto content = level->content;
for (auto& pack : content->getPacks()) {
const ContentPack& info = pack->getInfo();
fs::path scriptFile = info.folder/fs::path("scripts/hud.lua");
if (fs::is_regular_file(scriptFile)) {
scripting::load_hud_script(pack->getEnvironment()->getId(), info.id, scriptFile);
}
}
scripting::on_frontend_init(hud.get());
}
LevelScreen::~LevelScreen() {
std::cout << "-- writing world" << std::endl;
scripting::on_frontend_close();
controller->onWorldSave();
auto world = level->getWorld();
world->write(level.get());