Block.scriptName, ItemDef.scriptName

This commit is contained in:
MihailRis 2024-01-18 04:41:35 +03:00
parent 9119caca65
commit b12d242335
3 changed files with 7 additions and 3 deletions

View File

@ -172,6 +172,7 @@ void ContentLoader::loadBlock(Block* def, std::string name, fs::path file) {
root->flag("sky-light-passing", def->skyLightPassing);
root->num("draw-group", def->drawGroup);
root->str("picking-item", def->pickingItem);
root->str("script-name", def->scriptName);
}
void ContentLoader::loadCustomBlockModel(Block* def, dynamic::Map* primitives) {
@ -233,6 +234,7 @@ void ContentLoader::loadItem(ItemDef* def, std::string name, fs::path file) {
}
root->str("icon", def->icon);
root->str("placing-block", def->placingBlock);
root->str("script-name", def->scriptName);
root->num("stack-size", def->stackSize);
// item light emission [r, g, b] where r,g,b in range [0..15]
@ -248,7 +250,7 @@ void ContentLoader::loadBlock(Block* def, std::string full, std::string name) {
auto folder = pack->folder;
fs::path configFile = folder/fs::path("blocks/"+name+".json");
fs::path scriptfile = folder/fs::path("scripts/"+name+".lua");
fs::path scriptfile = folder/fs::path("scripts/"+def->scriptName+".lua");
loadBlock(def, full, configFile);
if (fs::is_regular_file(scriptfile)) {
scripting::load_block_script(full, scriptfile, &def->rt.funcsset);
@ -259,7 +261,7 @@ void ContentLoader::loadItem(ItemDef* def, std::string full, std::string name) {
auto folder = pack->folder;
fs::path configFile = folder/fs::path("items/"+name+".json");
fs::path scriptfile = folder/fs::path("scripts/"+name+".lua");
fs::path scriptfile = folder/fs::path("scripts/"+def->scriptName+".lua");
loadItem(def, full, configFile);
if (fs::is_regular_file(scriptfile)) {
scripting::load_item_script(full, scriptfile, &def->rt.funcsset);

View File

@ -30,6 +30,7 @@ public:
std::string icon = "blocks:notfound";
std::string placingBlock = "core:air";
std::string scriptName = name.substr(name.find(':')+1);
struct {
itemid_t id;

View File

@ -81,7 +81,7 @@ public:
std::vector<glm::vec3> modelExtraPoints = {}; //initially made for tetragons
std::vector<UVRegion> modelUVs = {}; // boxes' tex-UVs also there
uint8_t emission[4] {0, 0, 0, 0};
unsigned char drawGroup = 0;
ubyte drawGroup = 0;
BlockModel model = BlockModel::block;
bool lightPassing = false;
bool skyLightPassing = false;
@ -95,6 +95,7 @@ public:
AABB hitbox;
BlockRotProfile rotations;
std::string pickingItem = name+BLOCK_ITEM_SUFFIX;
std::string scriptName = name.substr(name.find(':')+1);
struct {
blockid_t id;