From 364c03e5cf6841958a3a5ddddae15e4c15e75eca Mon Sep 17 00:00:00 2001 From: iThorgrim <125808072+iThorgrim@users.noreply.github.com> Date: Wed, 5 Feb 2025 14:30:20 +0100 Subject: [PATCH] feat(LuaEngine/ItemTemplateMethods): add GetIcon method (#241) Co-authored-by: 55Honey <71938210+55Honey@users.noreply.github.com> --- src/LuaEngine/LuaFunctions.cpp | 1 + src/LuaEngine/methods/ItemTemplateMethods.h | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/LuaEngine/LuaFunctions.cpp b/src/LuaEngine/LuaFunctions.cpp index aa617ed..843a6c9 100644 --- a/src/LuaEngine/LuaFunctions.cpp +++ b/src/LuaEngine/LuaFunctions.cpp @@ -966,6 +966,7 @@ ElunaRegister ItemTemplateMethods[] = { "GetAllowableRace", &LuaItemTemplate::GetAllowableRace }, { "GetItemLevel", &LuaItemTemplate::GetItemLevel }, { "GetRequiredLevel", &LuaItemTemplate::GetRequiredLevel }, + { "GetIcon", &LuaItemTemplate::GetIcon }, { NULL, NULL } }; diff --git a/src/LuaEngine/methods/ItemTemplateMethods.h b/src/LuaEngine/methods/ItemTemplateMethods.h index 66980c9..b7ffe3d 100644 --- a/src/LuaEngine/methods/ItemTemplateMethods.h +++ b/src/LuaEngine/methods/ItemTemplateMethods.h @@ -196,6 +196,22 @@ namespace LuaItemTemplate Eluna::Push(L, itemTemplate->RequiredLevel); return 1; } + + /** + * Returns the icon is used by this [ItemTemplate]. + * + * @return string itemIcon + */ + int GetIcon(lua_State* L, ItemTemplate* itemTemplate) + { + uint32 display_id = itemTemplate->DisplayInfoID; + + ItemDisplayInfoEntry const* displayInfo = sItemDisplayInfoStore.LookupEntry(display_id); + const char* icon = displayInfo->inventoryIcon; + + Eluna::Push(L, icon); + return 1; + } } #endif