mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 06:23:53 +00:00
Lua: Add functions to resolve inventories
This commit is contained in:
parent
6adcd122a8
commit
f4980c178d
2 changed files with 26 additions and 0 deletions
|
@ -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…
Reference in a new issue