Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/game/StarItemDatabase.cpp7
-rw-r--r--source/game/StarItemDatabase.hpp5
-rw-r--r--source/game/scripting/StarRootLuaBindings.cpp4
3 files changed, 14 insertions, 2 deletions
diff --git a/source/game/StarItemDatabase.cpp b/source/game/StarItemDatabase.cpp
index b3eb16b..30e8c5e 100644
--- a/source/game/StarItemDatabase.cpp
+++ b/source/game/StarItemDatabase.cpp
@@ -213,6 +213,11 @@ ItemDatabase::ItemConfig ItemDatabase::itemConfig(String const& itemName, Json p
return itemConfig;
}
+Maybe<String> ItemDatabase::itemFile(String const& itemName) const {
+ auto const& data = itemData(itemName);
+ return itemData(itemName).assetsConfig;
+}
+
ItemPtr ItemDatabase::itemShared(ItemDescriptor descriptor, Maybe<float> level, Maybe<uint64_t> seed) const {
if (!descriptor)
return {};
@@ -757,4 +762,4 @@ void ItemDatabase::addCodexes() {
}
}
-}
+} \ No newline at end of file
diff --git a/source/game/StarItemDatabase.hpp b/source/game/StarItemDatabase.hpp
index d5b86fc..714eee7 100644
--- a/source/game/StarItemDatabase.hpp
+++ b/source/game/StarItemDatabase.hpp
@@ -110,6 +110,9 @@ public:
// of the unique item data or may be ignored.
ItemConfig itemConfig(String const& itemName, Json parameters, Maybe<float> level = {}, Maybe<uint64_t> seed = {}) const;
+ // Returns the path to the item's json file in the assets.
+ Maybe<String> itemFile(String const& itemName) const;
+
// Generates the config for the given item descriptor and then loads the item
// from the appropriate factory. If there is a problem instantiating the
// item, will return a default item instead. If item is passed a null
@@ -212,4 +215,4 @@ bool ItemDatabase::diskLoad(Json const& diskStore, shared_ptr<ItemT>& itemPtr) c
return false;
}
}
-}
+} \ No newline at end of file
diff --git a/source/game/scripting/StarRootLuaBindings.cpp b/source/game/scripting/StarRootLuaBindings.cpp
index d87b423..b7c9a74 100644
--- a/source/game/scripting/StarRootLuaBindings.cpp
+++ b/source/game/scripting/StarRootLuaBindings.cpp
@@ -116,6 +116,10 @@ LuaCallbacks LuaBindings::makeRootCallbacks() {
return table;
});
+ callbacks.registerCallback("itemFile", [root](LuaEngine& engine, String const& itemName) -> Maybe<String> {
+ return root->itemDatabase()->itemFile(itemName);
+ });
+
callbacks.registerCallback("materialConfig", [root](String const& materialName) -> Json {
auto materialId = root->materialDatabase()->materialId(materialName);
if (auto path = root->materialDatabase()->materialPath(materialId))