diff --git a/apps/openmw/mwlua/types/item.cpp b/apps/openmw/mwlua/types/item.cpp index e7dfaabcbc..e15be1a2e4 100644 --- a/apps/openmw/mwlua/types/item.cpp +++ b/apps/openmw/mwlua/types/item.cpp @@ -12,10 +12,6 @@ namespace MWLua = [](const Object& object) { return object.ptr().getCellRef().getEnchantmentCharge(); }; item["setEnchantmentCharge"] = [](const GObject& object, float charge) { object.ptr().getCellRef().setEnchantmentCharge(charge); }; - item["getPickUpSound"] - = [](const Object& object) { return object.ptr().getClass().getUpSoundId(object.ptr()).serializeText(); }; - item["getDropSound"] - = [](const Object& object) { return object.ptr().getClass().getDownSoundId(object.ptr()).serializeText(); }; item["isRestocking"] = [](const Object& object) -> bool { return object.ptr().getRefData().getCount(false) < 0; }; } diff --git a/docs/source/reference/lua-scripting/api.rst b/docs/source/reference/lua-scripting/api.rst index 76092fec3f..0cd86a4d23 100644 --- a/docs/source/reference/lua-scripting/api.rst +++ b/docs/source/reference/lua-scripting/api.rst @@ -28,6 +28,7 @@ Lua API reference openmw_aux_util openmw_aux_time openmw_aux_ui + openmw_aux_core interface_activation interface_ai interface_camera diff --git a/docs/source/reference/lua-scripting/openmw_aux_core.rst b/docs/source/reference/lua-scripting/openmw_aux_core.rst new file mode 100644 index 0000000000..49c72e7911 --- /dev/null +++ b/docs/source/reference/lua-scripting/openmw_aux_core.rst @@ -0,0 +1,5 @@ +Package openmw_aux.core +======================= + +.. raw:: html + :file: generated_html/openmw_aux_core.html diff --git a/docs/source/reference/lua-scripting/tables/aux_packages.rst b/docs/source/reference/lua-scripting/tables/aux_packages.rst index 928e5821de..af80f15243 100644 --- a/docs/source/reference/lua-scripting/tables/aux_packages.rst +++ b/docs/source/reference/lua-scripting/tables/aux_packages.rst @@ -9,3 +9,5 @@ +---------------------------------------------------------+--------------------+---------------------------------------------------------------+ |:ref:`openmw_aux.ui ` | by player scripts | | User interface utils | +---------------------------------------------------------+--------------------+---------------------------------------------------------------+ +|:ref:`openmw_aux.core ` | everywhere | | GameObject Utils | ++---------------------------------------------------------+--------------------+---------------------------------------------------------------+ diff --git a/files/data/openmw_aux/core.lua b/files/data/openmw_aux/core.lua index bfb0607aeb..7d908832d4 100644 --- a/files/data/openmw_aux/core.lua +++ b/files/data/openmw_aux/core.lua @@ -8,14 +8,21 @@ local core = require('openmw.core') local aux_core = {} --- --- Checks if the provided armor is Heavy, Medium, or Light +-- Checks if the provided armor is Heavy, Medium, or Light. Errors if invaid object supplied. -- @function [parent=#core] getArmorType --- @param openmw.core#GameObject armor --- @return #string -function aux_core.getArmorType(item) - if item.type ~= types.Armor then +-- @param openmw.core#GameObject armor Either a gameObject or a armor record. +-- @return #string Heavy, Medium, or Light +function aux_core.getArmorType(armor) + + if armor.type ~= types.Armor and not armor.baseArmor then error("Not Armor") end + local record = nil + if armor.baseArmor then--A record was supplied, not a gameObject + record = armor + else + record = types.Armor.record(armor) + end local epsilon = 0.0005; local lightMultiplier = core.getGMST("fLightMaxMod") + epsilon local medMultiplier = core.getGMST("fMedMaxMod") + epsilon @@ -32,8 +39,8 @@ function aux_core.getArmorType(item) [types.Armor.TYPE.LGauntlet] = "iGauntletWeight", [types.Armor.TYPE.RGauntlet] = "iGauntletWeight", } - local armorType = types.Armor.record(item).type - local weight = item.type.record(item).weight + local armorType = record.type + local weight = record.weight local armorTypeWeight = math.floor(core.getGMST(armorGMSTs[armorType])) if weight <= armorTypeWeight * lightMultiplier then @@ -95,8 +102,8 @@ end -- @function [parent=#core] getDropSound -- @param openmw.core#GameObject item -- @return #string -function aux_core.getDropSound(obj) - local soundName = getItemSound(obj) +function aux_core.getDropSound(item) + local soundName = getItemSound(item) return string.format("Item %s Down", soundName) end @@ -105,8 +112,8 @@ end -- @function [parent=#core] getPickupSound -- @param openmw.core#GameObject item -- @return #string -function aux_core.getPickupSound(obj) - local soundName = getItemSound(obj) +function aux_core.getPickupSound(item) + local soundName = getItemSound(item) return string.format("Item %s Up", soundName) end diff --git a/files/lua_api/openmw/types.lua b/files/lua_api/openmw/types.lua index f37ef0de85..cc8a0365f1 100644 --- a/files/lua_api/openmw/types.lua +++ b/files/lua_api/openmw/types.lua @@ -626,18 +626,6 @@ -- @param openmw.core#GameObject object -- @return #boolean ---- --- Get this item's pick up sound --- @function [parent=#Item] getPickupSound --- @param openmw.core#GameObject item --- @return #string The String ID of the pick up sound for this item. - ---- --- Get this item's drop sound --- @function [parent=#Item] getDropSound --- @param openmw.core#GameObject item --- @return #string The String ID of the drop sound for this item. - --- -- Get this item's current enchantment charge. -- @function [parent=#Item] getEnchantmentCharge