From 55c9cde2ed43fa068a781c33f6bf0f9659addd1d Mon Sep 17 00:00:00 2001 From: Petr Mikheev Date: Mon, 10 Apr 2023 23:28:15 +0200 Subject: [PATCH] [Lua] Add missing `record.id` for NPC and Creature records. --- apps/openmw/mwlua/types/creature.cpp | 2 ++ apps/openmw/mwlua/types/npc.cpp | 2 ++ files/lua_api/openmw/types.lua | 2 ++ 3 files changed, 6 insertions(+) diff --git a/apps/openmw/mwlua/types/creature.cpp b/apps/openmw/mwlua/types/creature.cpp index be6786b4ca..ec4eb07c87 100644 --- a/apps/openmw/mwlua/types/creature.cpp +++ b/apps/openmw/mwlua/types/creature.cpp @@ -28,6 +28,8 @@ namespace MWLua sol::usertype record = context.mLua->sol().new_usertype("ESM3_Creature"); record[sol::meta_function::to_string] = [](const ESM::Creature& rec) { return "ESM3_Creature[" + rec.mId.toDebugString() + "]"; }; + record["id"] + = sol::readonly_property([](const ESM::Creature& rec) -> std::string { return rec.mId.serializeText(); }); record["name"] = sol::readonly_property([](const ESM::Creature& rec) -> std::string { return rec.mName; }); record["model"] = sol::readonly_property([vfs](const ESM::Creature& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); diff --git a/apps/openmw/mwlua/types/npc.cpp b/apps/openmw/mwlua/types/npc.cpp index 31dc87095f..3f20a657c2 100644 --- a/apps/openmw/mwlua/types/npc.cpp +++ b/apps/openmw/mwlua/types/npc.cpp @@ -30,6 +30,8 @@ namespace MWLua sol::usertype record = context.mLua->sol().new_usertype("ESM3_NPC"); record[sol::meta_function::to_string] = [](const ESM::NPC& rec) { return "ESM3_NPC[" + rec.mId.toDebugString() + "]"; }; + record["id"] + = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mId.serializeText(); }); record["name"] = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mName; }); record["race"] = sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mRace.serializeText(); }); diff --git a/files/lua_api/openmw/types.lua b/files/lua_api/openmw/types.lua index 14067fde16..ef2237128c 100644 --- a/files/lua_api/openmw/types.lua +++ b/files/lua_api/openmw/types.lua @@ -473,6 +473,7 @@ --- -- @type CreatureRecord +-- @field #string id The record ID of the creature -- @field #string name -- @field #string baseCreature Record id of a base creature, which was modified to create this one -- @field #string model VFS path to the creature's model @@ -514,6 +515,7 @@ --- -- @type NpcRecord +-- @field #string id The record ID of the NPC -- @field #string name -- @field #string race -- @field #string class Name of the NPC's class (e. g. Acrobat)