diff --git a/apps/openmw/mwlua/cellbindings.cpp b/apps/openmw/mwlua/cellbindings.cpp index ade50cf289..914f3f5fcc 100644 --- a/apps/openmw/mwlua/cellbindings.cpp +++ b/apps/openmw/mwlua/cellbindings.cpp @@ -88,19 +88,15 @@ namespace MWLua return true; }; - bool ok = false; - sol::optional typeId = sol::nullopt; - if (type.has_value()) - typeId = ids[*type]; - else - { - ok = true; + bool ok = true; + if (!type.has_value()) cell.mStore->forEach(std::move(visitor)); - } - if (typeId.has_value()) + else if (ids[*type] == sol::nil) + ok = false; + else { - ok = true; - switch (*typeId) + uint32_t typeId = ids[*type]; + switch (typeId) { case ESM::REC_INTERNAL_PLAYER: { diff --git a/apps/openmw/mwlua/luabindings.cpp b/apps/openmw/mwlua/luabindings.cpp index 1804ea4004..5d4c538538 100644 --- a/apps/openmw/mwlua/luabindings.cpp +++ b/apps/openmw/mwlua/luabindings.cpp @@ -112,7 +112,7 @@ namespace MWLua { auto* lua = context.mLua; sol::table api(lua->sol(), sol::create); - api["API_REVISION"] = 41; + api["API_REVISION"] = 42; api["quit"] = [lua]() { Log(Debug::Warning) << "Quit requested by a Lua script.\n" << lua->debugTraceback(); MWBase::Environment::get().getStateManager()->requestQuit(); diff --git a/apps/openmw/mwlua/types/item.cpp b/apps/openmw/mwlua/types/item.cpp index 604a628d8f..2b77b6a7c8 100644 --- a/apps/openmw/mwlua/types/item.cpp +++ b/apps/openmw/mwlua/types/item.cpp @@ -1,3 +1,6 @@ +#include + +#include "../../mwworld/class.hpp" #include "types.hpp" diff --git a/apps/openmw/mwlua/worldview.cpp b/apps/openmw/mwlua/worldview.cpp index d1703e8964..097a418869 100644 --- a/apps/openmw/mwlua/worldview.cpp +++ b/apps/openmw/mwlua/worldview.cpp @@ -51,7 +51,7 @@ namespace MWLua return &mDoorsInScene; if (typeid(cls) == typeid(MWClass::Container)) return &mContainersInScene; - if (cls.isItem(ptr)) + if (cls.isItem(ptr) || ptr.mRef->getType() == ESM::REC_LIGH) return &mItemsInScene; return nullptr; } diff --git a/files/lua_api/openmw/nearby.lua b/files/lua_api/openmw/nearby.lua index 6f99418a07..e49257dace 100644 --- a/files/lua_api/openmw/nearby.lua +++ b/files/lua_api/openmw/nearby.lua @@ -23,7 +23,7 @@ -- @field [parent=#nearby] openmw.core#ObjectList doors --- --- Everything that can be picked up in the nearby. +-- Everything in the nearby that is derived from @{openmw.types#Item}. -- @field [parent=#nearby] openmw.core#ObjectList items --- diff --git a/files/lua_api/openmw/types.lua b/files/lua_api/openmw/types.lua index 6659a44a2f..36d63358df 100644 --- a/files/lua_api/openmw/types.lua +++ b/files/lua_api/openmw/types.lua @@ -592,10 +592,11 @@ -- @field #SkillStats skills ---- @{#Item} functions (all pickable items that can be placed to an inventory or container) +-------------------------------------------------------------------------------- +-- @{#Item} functions (all items that can be placed to an inventory or container) -- @field [parent=#types] #Item Item ---- Functions for pickable items that can be placed to an inventory or container +--- Functions for items that can be placed to an inventory or container -- @type Item --- @@ -607,16 +608,26 @@ --- -- Get this item's current enchantment charge. -- @function [parent=#Item] getEnchantmentCharge --- @param #Item item +-- @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. --- -- Set this item's enchantment charge. -- @function [parent=#Item] setEnchantmentCharge --- @param #Item item +-- @param openmw.core#GameObject item -- @param #number charge ---- @{#Creature} functions +--- +-- Whether the object is supposed to be carriable. It is true for all items except +-- lights without the Carry flag. Non-carriable lights can still be put into +-- an inventory with an explicit `object:moveInto` call. +-- @function [parent=#Item] isCarriable +-- @param openmw.core#GameObject object +-- @return #boolean + + +-------------------------------------------------------------------------------- +-- @{#Creature} functions -- @field [parent=#types] #Creature Creature ---