1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-24 22:43:47 +00:00

Merge branch 'lua/capacity_encum_bindings' into 'master'

Add more lua bindings for encumbrance and capacity

See merge request OpenMW/openmw!3462
This commit is contained in:
psi29a 2023-09-28 08:32:38 +00:00
commit bae8d585fe
4 changed files with 27 additions and 4 deletions

View File

@ -375,6 +375,11 @@ namespace MWLua
return result;
};
actor["getEncumbrance"] = [](const Object& actor) -> float {
const MWWorld::Ptr ptr = actor.ptr();
return ptr.getClass().getEncumbrance(ptr);
};
addActorStatsBindings(actor, context);
addActorMagicBindings(actor, context);
}

View File

@ -31,14 +31,16 @@ namespace MWLua
container["content"] = sol::overload([](const LObject& o) { return Inventory<LObject>{ o }; },
[](const GObject& o) { return Inventory<GObject>{ o }; });
container["inventory"] = container["content"];
container["encumbrance"] = [](const Object& obj) -> float {
container["getEncumbrance"] = [](const Object& obj) -> float {
const MWWorld::Ptr& ptr = containerPtr(obj);
return ptr.getClass().getEncumbrance(ptr);
};
container["capacity"] = [](const Object& obj) -> float {
container["encumbrance"] = container["getEncumbrance"]; // for compatibility; should be removed later
container["getCapacity"] = [](const Object& obj) -> float {
const MWWorld::Ptr& ptr = containerPtr(obj);
return ptr.getClass().getCapacity(ptr);
};
container["capacity"] = container["getCapacity"]; // for compatibility; should be removed later
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();

View File

@ -305,5 +305,9 @@ namespace MWLua
return res;
};
npc["getCapacity"] = [](const Object& actor) -> float {
const MWWorld::Ptr ptr = actor.ptr();
return ptr.getClass().getCapacity(ptr);
};
}
}

View File

@ -9,6 +9,12 @@
--- Common functions for Creature, NPC, and Player.
-- @type Actor
---
-- Get the total weight of everything the actor is carrying, plus modifications from magic effects.
-- @function [parent=#Actor] getEncumbrance
-- @param openmw.core#GameObject actor
-- @return #number
---
-- Agent bounds to be used for pathfinding functions.
-- @function [parent=#Actor] getPathfindingAgentBounds
@ -855,6 +861,12 @@
-- @param openmw.core#GameObject player The player that you want to check the disposition for.
-- @return #number
---
-- Get the total weight that the actor can carry.
-- @function [parent=#NPC] getCapacity
-- @param openmw.core#GameObject actor
-- @return #number
---
-- Whether the NPC or player is in the werewolf form at the moment.
-- @function [parent=#NPC] isWerewolf
@ -1639,13 +1651,13 @@
---
-- Returns the total weight of everything in a container
-- @function [parent=#Container] encumbrance
-- @function [parent=#Container] getEncumbrance
-- @param openmw.core#GameObject object
-- @return #number
---
-- Returns the capacity of a container
-- @function [parent=#Container] capacity
-- @function [parent=#Container] getCapacity
-- @param openmw.core#GameObject object
-- @return #number