diff --git a/apps/openmw/mwlua/objectbindings.cpp b/apps/openmw/mwlua/objectbindings.cpp index ef25dadfab7..7db7877245c 100644 --- a/apps/openmw/mwlua/objectbindings.cpp +++ b/apps/openmw/mwlua/objectbindings.cpp @@ -211,6 +211,13 @@ namespace MWLua objectT["isValid"] = [](const ObjectT& o) { return !o.ptrOrEmpty().isEmpty(); }; objectT["recordId"] = sol::readonly_property( [](const ObjectT& o) -> std::string { return o.ptr().getCellRef().getRefId().serializeText(); }); + objectT["globalVariable"] = sol::readonly_property([](const ObjectT& o) -> sol::optional { + std::string globalVariable = o.ptr().getCellRef().getGlobalVariable(); + if (globalVariable.empty()) + return sol::nullopt; + else + return ESM::RefId::stringRefId(globalVariable).serializeText(); + }); objectT["cell"] = sol::readonly_property([](const ObjectT& o) -> sol::optional> { const MWWorld::Ptr& ptr = o.ptr(); MWWorld::WorldModel* wm = MWBase::Environment::get().getWorldModel(); diff --git a/files/lua_api/openmw/core.lua b/files/lua_api/openmw/core.lua index 2c815d6dfc8..acfa6a1fc28 100644 --- a/files/lua_api/openmw/core.lua +++ b/files/lua_api/openmw/core.lua @@ -167,6 +167,7 @@ -- @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 #string recordId Returns record ID of the object in lowercase. +-- @field #string globalVariable Global Variable associated with this object(read only). --- -- Does the object still exist and is available.