diff --git a/src/graphics/ui/elements/InventoryView.cpp b/src/graphics/ui/elements/InventoryView.cpp index d3a747225..1df173951 100644 --- a/src/graphics/ui/elements/InventoryView.cpp +++ b/src/graphics/ui/elements/InventoryView.cpp @@ -382,7 +382,7 @@ void SlotView::performLeftClick(ItemStack& stack, ItemStack& grabbed) { void SlotView::performRightClick(ItemStack& stack, ItemStack& grabbed) { if (layout.rightClick) { - layout.rightClick(inventoryid, stack); + layout.rightClick(inventoryId, stack); if (layout.updateFunc) { layout.updateFunc(layout.index, stack); } @@ -454,7 +454,7 @@ const std::wstring& SlotView::getTooltip() const { void SlotView::bind( int64_t inventoryid, ItemStack& stack, const Content* content ) { - this->inventoryid = inventoryid; + this->inventoryId = inventoryid; bound = &stack; this->content = content; } @@ -467,6 +467,10 @@ ItemStack& SlotView::getStack() { return *bound; } +int64_t SlotView::getInventoryId() const { + return inventoryId; +} + InventoryView::InventoryView(GUI& gui) : Container(gui, glm::vec2()) { setColor(glm::vec4(0, 0, 0, 0.0f)); } diff --git a/src/graphics/ui/elements/InventoryView.hpp b/src/graphics/ui/elements/InventoryView.hpp index b80f65e68..4dbb9afcf 100644 --- a/src/graphics/ui/elements/InventoryView.hpp +++ b/src/graphics/ui/elements/InventoryView.hpp @@ -61,7 +61,7 @@ namespace gui { SlotLayout layout; bool highlighted = false; - int64_t inventoryid = 0; + int64_t inventoryId = 0; ItemStack* bound = nullptr; void performLeftClick(ItemStack& stack, ItemStack& grabbed); @@ -105,6 +105,7 @@ namespace gui { ItemStack& getStack(); const SlotLayout& getLayout() const; + int64_t getInventoryId() const; static inline std::string EXCHANGE_SLOT_NAME = "exchange-slot"; }; diff --git a/src/logic/scripting/lua/libs/libgui.cpp b/src/logic/scripting/lua/libs/libgui.cpp index b08d54455..31147e767 100644 --- a/src/logic/scripting/lua/libs/libgui.cpp +++ b/src/logic/scripting/lua/libs/libgui.cpp @@ -209,6 +209,8 @@ static int p_get_inventory(UINode* node, lua::State* L) { if (auto inventory = dynamic_cast(node)) { auto inv = inventory->getInventory(); return lua::pushinteger(L, inv ? inv->getId() : 0); + } else if (auto slot = dynamic_cast(node)) { + return lua::pushinteger(L, slot->getInventoryId()); } return 0; }