From 81f2402e66cdc9c21dd81e7126b29a06dbd56d59 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Sun, 15 Dec 2024 03:20:34 +0300 Subject: [PATCH] Lua: Expose capacity for creatures as well --- apps/openmw/mwlua/types/actor.cpp | 5 +++++ apps/openmw/mwlua/types/npc.cpp | 4 ---- files/lua_api/openmw/types.lua | 12 ++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwlua/types/actor.cpp b/apps/openmw/mwlua/types/actor.cpp index 02686684e8..413a656e90 100644 --- a/apps/openmw/mwlua/types/actor.cpp +++ b/apps/openmw/mwlua/types/actor.cpp @@ -415,6 +415,11 @@ namespace MWLua return ptr.getClass().getEncumbrance(ptr); }; + actor["getCapacity"] = [](const Object& actor) -> float { + const MWWorld::Ptr ptr = actor.ptr(); + return ptr.getClass().getCapacity(ptr); + }; + addActorStatsBindings(actor, context); addActorMagicBindings(actor, context); } diff --git a/apps/openmw/mwlua/types/npc.cpp b/apps/openmw/mwlua/types/npc.cpp index 7cfcf6d704..e649c56a0f 100644 --- a/apps/openmw/mwlua/types/npc.cpp +++ b/apps/openmw/mwlua/types/npc.cpp @@ -353,9 +353,5 @@ namespace MWLua return res; }; - npc["getCapacity"] = [](const Object& actor) -> float { - const MWWorld::Ptr ptr = actor.ptr(); - return ptr.getClass().getCapacity(ptr); - }; } } diff --git a/files/lua_api/openmw/types.lua b/files/lua_api/openmw/types.lua index e518723ea5..e1b814f8b3 100644 --- a/files/lua_api/openmw/types.lua +++ b/files/lua_api/openmw/types.lua @@ -15,6 +15,12 @@ -- @param openmw.core#GameObject actor -- @return #number +--- +-- Get the total weight that the actor can carry. +-- @function [parent=#Actor] getCapacity +-- @param openmw.core#GameObject actor +-- @return #number + --- -- Check if the given actor is dead (health reached 0, so death process started). -- @function [parent=#Actor] isDead @@ -1035,12 +1041,6 @@ -- @param openmw.core#GameObject player The player that you want to modify the disposition for. -- @param #number value Base disposition modification value ---- --- Get the total weight that the actor can carry. --- @function [parent=#NPC] getCapacity --- @param openmw.core#GameObject actor --- @return #number - --- @{#Classes}: Class Data -- @field [parent=#NPC] #Classes classes