From 84987450ee488df4d5ab0b56d3cd0c17b0bdf47f Mon Sep 17 00:00:00 2001 From: Zackhasacat Date: Sun, 27 Aug 2023 20:47:43 -0500 Subject: [PATCH 1/3] Add baseCount --- apps/openmw/mwlua/objectbindings.cpp | 2 ++ files/lua_api/openmw/core.lua | 1 + 2 files changed, 3 insertions(+) diff --git a/apps/openmw/mwlua/objectbindings.cpp b/apps/openmw/mwlua/objectbindings.cpp index 32bd0b95d4..7dcf0d5fe7 100644 --- a/apps/openmw/mwlua/objectbindings.cpp +++ b/apps/openmw/mwlua/objectbindings.cpp @@ -214,6 +214,8 @@ namespace MWLua const ObjectT& o) mutable { return types[getLiveCellRefType(o.ptr().mRef)]; }); objectT["count"] = sol::readonly_property([](const ObjectT& o) { return o.ptr().getRefData().getCount(); }); + objectT["baseCount"] + = sol::readonly_property([](const ObjectT& o) { return o.ptr().getRefData().getCount(false); }); objectT[sol::meta_function::equal_to] = [](const ObjectT& a, const ObjectT& b) { return a.id() == b.id(); }; objectT[sol::meta_function::to_string] = &ObjectT::toString; objectT["sendEvent"] = [context](const ObjectT& dest, std::string eventName, const sol::object& eventData) { diff --git a/files/lua_api/openmw/core.lua b/files/lua_api/openmw/core.lua index 7a43cd2c3f..8500993208 100644 --- a/files/lua_api/openmw/core.lua +++ b/files/lua_api/openmw/core.lua @@ -161,6 +161,7 @@ -- @field #Cell cell The cell where the object currently is. During loading a game and for objects in an inventory or a container `cell` is nil. -- @field #any type Type of the object (one of the tables from the package @{openmw.types#types}). -- @field #number count Count (>1 means a stack of objects). +-- @field #number baseCount Base Count (<1 means a restocking item). -- @field #string recordId Returns record ID of the object in lowercase. --- From 5fdaee093a6d36d0422f677304de0a4d6d63eda1 Mon Sep 17 00:00:00 2001 From: Zackhasacat Date: Mon, 28 Aug 2023 08:30:54 -0500 Subject: [PATCH 2/3] add isRestocking --- apps/openmw/mwlua/objectbindings.cpp | 2 -- apps/openmw/mwlua/types/item.cpp | 2 ++ files/lua_api/openmw/core.lua | 1 - files/lua_api/openmw/types.lua | 7 +++++++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwlua/objectbindings.cpp b/apps/openmw/mwlua/objectbindings.cpp index 7dcf0d5fe7..32bd0b95d4 100644 --- a/apps/openmw/mwlua/objectbindings.cpp +++ b/apps/openmw/mwlua/objectbindings.cpp @@ -214,8 +214,6 @@ namespace MWLua const ObjectT& o) mutable { return types[getLiveCellRefType(o.ptr().mRef)]; }); objectT["count"] = sol::readonly_property([](const ObjectT& o) { return o.ptr().getRefData().getCount(); }); - objectT["baseCount"] - = sol::readonly_property([](const ObjectT& o) { return o.ptr().getRefData().getCount(false); }); objectT[sol::meta_function::equal_to] = [](const ObjectT& a, const ObjectT& b) { return a.id() == b.id(); }; objectT[sol::meta_function::to_string] = &ObjectT::toString; objectT["sendEvent"] = [context](const ObjectT& dest, std::string eventName, const sol::object& eventData) { diff --git a/apps/openmw/mwlua/types/item.cpp b/apps/openmw/mwlua/types/item.cpp index 2b77b6a7c8..01e968777d 100644 --- a/apps/openmw/mwlua/types/item.cpp +++ b/apps/openmw/mwlua/types/item.cpp @@ -12,5 +12,7 @@ namespace MWLua = [](const Object& object) { return object.ptr().getCellRef().getEnchantmentCharge(); }; item["setEnchantmentCharge"] = [](const GObject& object, float charge) { object.ptr().getCellRef().setEnchantmentCharge(charge); }; + item["isRestocking"] + = [](const GObject& object) -> bool { return object.ptr().getRefData().getCount(false) < 0; }; } } diff --git a/files/lua_api/openmw/core.lua b/files/lua_api/openmw/core.lua index 8500993208..7a43cd2c3f 100644 --- a/files/lua_api/openmw/core.lua +++ b/files/lua_api/openmw/core.lua @@ -161,7 +161,6 @@ -- @field #Cell cell The cell where the object currently is. During loading a game and for objects in an inventory or a container `cell` is nil. -- @field #any type Type of the object (one of the tables from the package @{openmw.types#types}). -- @field #number count Count (>1 means a stack of objects). --- @field #number baseCount Base Count (<1 means a restocking item). -- @field #string recordId Returns record ID of the object in lowercase. --- diff --git a/files/lua_api/openmw/types.lua b/files/lua_api/openmw/types.lua index 199b1a8e8b..a62ecbc846 100644 --- a/files/lua_api/openmw/types.lua +++ b/files/lua_api/openmw/types.lua @@ -632,6 +632,13 @@ -- @param openmw.core#GameObject item -- @return #number The charge remaining. -1 if the enchantment has never been used, implying the charge is full. Unenchanted items will always return a value of -1. +--- +-- Checks if the item restocks. +-- Returns true if the object restocks, and false otherwise. +-- @function [parent=#Item] isRestocking +-- @param openmw.core#GameObject item +-- @return #boolean + --- -- Set this item's enchantment charge. -- @function [parent=#Item] setEnchantmentCharge From 95c736d54e1bfd4c746b3ac5674e9c4a9415b9f3 Mon Sep 17 00:00:00 2001 From: Zackhasacat Date: Mon, 28 Aug 2023 08:50:25 -0500 Subject: [PATCH 3/3] Remove gobjefct --- apps/openmw/mwlua/types/item.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwlua/types/item.cpp b/apps/openmw/mwlua/types/item.cpp index 01e968777d..e15be1a2e4 100644 --- a/apps/openmw/mwlua/types/item.cpp +++ b/apps/openmw/mwlua/types/item.cpp @@ -13,6 +13,6 @@ namespace MWLua item["setEnchantmentCharge"] = [](const GObject& object, float charge) { object.ptr().getCellRef().setEnchantmentCharge(charge); }; item["isRestocking"] - = [](const GObject& object) -> bool { return object.ptr().getRefData().getCount(false) < 0; }; + = [](const Object& object) -> bool { return object.ptr().getRefData().getCount(false) < 0; }; } }