Lua: Add functions to resolve inventories

revert-6246b479
Zackhasacat 2 years ago committed by Petr Mikheev
parent 6adcd122a8
commit f4980c178d

@ -525,6 +525,19 @@ namespace MWLua
MWWorld::ContainerStore& store = ptr.getClass().getContainerStore(ptr);
return store.count(ESM::RefId::stringRefId(recordId));
};
if constexpr (std::is_same_v<ObjectT, GObject>)
{
inventoryT["resolve"] = [](const InventoryT& inventory) {
const MWWorld::Ptr& ptr = inventory.mObj.ptr();
MWWorld::ContainerStore& store = ptr.getClass().getContainerStore(ptr);
store.resolve();
};
}
inventoryT["isResolved"] = [](const InventoryT& inventory) -> bool {
const MWWorld::Ptr& ptr = inventory.mObj.ptr();
MWWorld::ContainerStore& store = ptr.getClass().getContainerStore(ptr);
return store.isResolved();
};
inventoryT["find"] = [](const InventoryT& inventory, std::string_view recordId) -> sol::optional<ObjectT> {
const MWWorld::Ptr& ptr = inventory.mObj.ptr();
MWWorld::ContainerStore& store = ptr.getClass().getContainerStore(ptr);

@ -349,6 +349,19 @@
-- @return #GameObject
-- @usage inventory:find('gold_001')
---
-- Will resolve the inventory, filling it with levelled items if applicable, making its contents permanent. Must be used in a global script.
-- @function [parent=#Inventory] resolve
-- @param self
-- @usage inventory:resolve()
---
-- Checks if the inventory has a resolved item list.
-- @function [parent=#Inventory] isResolved
-- @param self
-- @return #boolean
-- @usage inventory:isResolved()
---
-- Get all items with given recordId from the inventory.
-- @function [parent=#Inventory] findAll

Loading…
Cancel
Save