Block.scriptName, ItemDef.scriptName
This commit is contained in:
@@ -172,6 +172,7 @@ void ContentLoader::loadBlock(Block* def, std::string name, fs::path file) {
|
|||||||
root->flag("sky-light-passing", def->skyLightPassing);
|
root->flag("sky-light-passing", def->skyLightPassing);
|
||||||
root->num("draw-group", def->drawGroup);
|
root->num("draw-group", def->drawGroup);
|
||||||
root->str("picking-item", def->pickingItem);
|
root->str("picking-item", def->pickingItem);
|
||||||
|
root->str("script-name", def->scriptName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentLoader::loadCustomBlockModel(Block* def, dynamic::Map* primitives) {
|
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("icon", def->icon);
|
||||||
root->str("placing-block", def->placingBlock);
|
root->str("placing-block", def->placingBlock);
|
||||||
|
root->str("script-name", def->scriptName);
|
||||||
root->num("stack-size", def->stackSize);
|
root->num("stack-size", def->stackSize);
|
||||||
|
|
||||||
// item light emission [r, g, b] where r,g,b in range [0..15]
|
// 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;
|
auto folder = pack->folder;
|
||||||
|
|
||||||
fs::path configFile = folder/fs::path("blocks/"+name+".json");
|
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);
|
loadBlock(def, full, configFile);
|
||||||
if (fs::is_regular_file(scriptfile)) {
|
if (fs::is_regular_file(scriptfile)) {
|
||||||
scripting::load_block_script(full, scriptfile, &def->rt.funcsset);
|
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;
|
auto folder = pack->folder;
|
||||||
|
|
||||||
fs::path configFile = folder/fs::path("items/"+name+".json");
|
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);
|
loadItem(def, full, configFile);
|
||||||
if (fs::is_regular_file(scriptfile)) {
|
if (fs::is_regular_file(scriptfile)) {
|
||||||
scripting::load_item_script(full, scriptfile, &def->rt.funcsset);
|
scripting::load_item_script(full, scriptfile, &def->rt.funcsset);
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ public:
|
|||||||
std::string icon = "blocks:notfound";
|
std::string icon = "blocks:notfound";
|
||||||
|
|
||||||
std::string placingBlock = "core:air";
|
std::string placingBlock = "core:air";
|
||||||
|
std::string scriptName = name.substr(name.find(':')+1);
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
itemid_t id;
|
itemid_t id;
|
||||||
|
|||||||
+2
-1
@@ -81,7 +81,7 @@ public:
|
|||||||
std::vector<glm::vec3> modelExtraPoints = {}; //initially made for tetragons
|
std::vector<glm::vec3> modelExtraPoints = {}; //initially made for tetragons
|
||||||
std::vector<UVRegion> modelUVs = {}; // boxes' tex-UVs also there
|
std::vector<UVRegion> modelUVs = {}; // boxes' tex-UVs also there
|
||||||
uint8_t emission[4] {0, 0, 0, 0};
|
uint8_t emission[4] {0, 0, 0, 0};
|
||||||
unsigned char drawGroup = 0;
|
ubyte drawGroup = 0;
|
||||||
BlockModel model = BlockModel::block;
|
BlockModel model = BlockModel::block;
|
||||||
bool lightPassing = false;
|
bool lightPassing = false;
|
||||||
bool skyLightPassing = false;
|
bool skyLightPassing = false;
|
||||||
@@ -95,6 +95,7 @@ public:
|
|||||||
AABB hitbox;
|
AABB hitbox;
|
||||||
BlockRotProfile rotations;
|
BlockRotProfile rotations;
|
||||||
std::string pickingItem = name+BLOCK_ITEM_SUFFIX;
|
std::string pickingItem = name+BLOCK_ITEM_SUFFIX;
|
||||||
|
std::string scriptName = name.substr(name.find(':')+1);
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
blockid_t id;
|
blockid_t id;
|
||||||
|
|||||||
Reference in New Issue
Block a user