Scripting WIP (#70)

* Scripting introduced

* AppImage workflow fixes

* AppImage workflow simplified

* README.md update

* README.md update

* small fix
This commit is contained in:
MihailRis
2023-12-25 05:26:03 +03:00
committed by GitHub
parent ce26f0c227
commit acce49f188
35 changed files with 649 additions and 138 deletions
+9 -1
View File
@@ -12,6 +12,7 @@
#include "../typedefs.h"
#include "ContentPack.h"
#include "../logic/scripting/scripting.h"
namespace fs = std::filesystem;
@@ -84,6 +85,7 @@ Block* ContentLoader::loadBlock(std::string name, fs::path file) {
root->flag("light-passing", def->lightPassing);
root->flag("breakable", def->breakable);
root->flag("selectable", def->selectable);
root->flag("grounded", def->grounded);
root->flag("sky-light-passing", def->skyLightPassing);
root->num("draw-group", def->drawGroup);
@@ -100,8 +102,14 @@ void ContentLoader::load(ContentBuilder* builder) {
if (blocksarr) {
for (uint i = 0; i < blocksarr->size(); i++) {
std::string name = blocksarr->str(i);
std::string prefix = pack->id+":"+name;
fs::path blockfile = folder/fs::path("blocks/"+name+".json");
builder->add(loadBlock(pack->id+":"+name, blockfile));
Block* block = loadBlock(prefix, blockfile);
builder->add(block);
fs::path scriptfile = folder/fs::path("scripts/"+name+".lua");
if (fs::is_regular_file(scriptfile)) {
scripting::load_block_script(prefix, scriptfile, &block->rt.funcsset);
}
}
}
}