From 65ee464941137a1963cfd3beaf7eeef8ca9227da Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 2 Dec 2025 18:21:52 +0300 Subject: [PATCH] fix generated item's script --- src/content/ContentLoader.cpp | 3 +++ src/items/ItemDef.cpp | 7 ++++--- src/items/ItemDef.hpp | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/content/ContentLoader.cpp b/src/content/ContentLoader.cpp index c9b98281..c98d5168 100644 --- a/src/content/ContentLoader.cpp +++ b/src/content/ContentLoader.cpp @@ -289,6 +289,9 @@ void ContentLoader::loadContent(const dv::value& root) { item.icon = def.name; item.placingBlock = def.name; item.tags = def.tags; + item.scriptFile = def.name + BLOCK_ITEM_SUFFIX + ".lua"; + + logger.info() << "scriptFile: " << item.scriptFile; for (uint j = 0; j < 4; j++) { item.emission[j] = def.emission[j]; diff --git a/src/items/ItemDef.cpp b/src/items/ItemDef.cpp index 236efc6b..bff25e7a 100644 --- a/src/items/ItemDef.cpp +++ b/src/items/ItemDef.cpp @@ -2,9 +2,10 @@ #include "util/stringutil.hpp" -ItemDef::ItemDef(const std::string& name) : name(name) { - caption = util::id_to_caption(name); - description = ""; +ItemDef::ItemDef(const std::string& name) + : name(name), + caption(util::id_to_caption(name)), + scriptName(name.substr(name.find(':') + 1)) { } void ItemDef::cloneTo(ItemDef& dst) { dst.caption = caption; diff --git a/src/items/ItemDef.hpp b/src/items/ItemDef.hpp index 40e052b9..ee37215a 100644 --- a/src/items/ItemDef.hpp +++ b/src/items/ItemDef.hpp @@ -37,7 +37,7 @@ struct ItemDef { std::string caption; /// @brief Item description will shown in inventory - std::string description; + std::string description = ""; dv::value properties = nullptr; @@ -60,7 +60,7 @@ struct ItemDef { std::string icon = "blocks:notfound"; std::string placingBlock = "core:air"; - std::string scriptName = name.substr(name.find(':') + 1); + std::string scriptName; std::string modelName = name + ".model";