diff --git a/apps/openmw/mwlua/types/creature.cpp b/apps/openmw/mwlua/types/creature.cpp index d07138f1c6..b42f433ede 100644 --- a/apps/openmw/mwlua/types/creature.cpp +++ b/apps/openmw/mwlua/types/creature.cpp @@ -21,6 +21,13 @@ namespace MWLua { void addCreatureBindings(sol::table creature, const Context& context) { + creature["TYPE"] = LuaUtil::makeStrictReadOnly(context.mLua->tableFromPairs({ + { "Creatures", ESM::Creature::Creatures }, + { "Daedra", ESM::Creature::Daedra }, + { "Undead", ESM::Creature::Undead }, + { "Humanoid", ESM::Creature::Humanoid }, + })); + auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); addRecordFunctionBinding(creature, context); @@ -39,5 +46,6 @@ namespace MWLua record["baseCreature"] = sol::readonly_property( [](const ESM::Creature& rec) -> std::string { return rec.mOriginal.serializeText(); }); record["soulValue"] = sol::readonly_property([](const ESM::Creature& rec) -> int { return rec.mData.mSoul; }); + record["type"] = sol::readonly_property([](const ESM::Creature& rec) -> int { return rec.mData.mType; }); } } diff --git a/files/lua_api/openmw/types.lua b/files/lua_api/openmw/types.lua index 8b86e7f816..99d7387947 100644 --- a/files/lua_api/openmw/types.lua +++ b/files/lua_api/openmw/types.lua @@ -578,6 +578,16 @@ -- @param openmw.core#GameObject object -- @return #boolean +--- Creature.TYPE +-- @type CreatureTYPE +-- @field #number Creatures +-- @field #number Daedra +-- @field #number Undead +-- @field #number Humanoid + +--- @{#CreatureTYPE} +-- @field [parent=#Creature] #CreatureTYPE TYPE + --- -- Returns the read-only @{#CreatureRecord} of a creature -- @function [parent=#Creature] record @@ -592,6 +602,7 @@ -- @field #string model VFS path to the creature's model -- @field #string mwscript -- @field #number soulValue The soul value of the creature record +-- @field #number type The @{#Creature.TYPE} of the creature --- @{#NPC} functions