Skip to content

Commit

Permalink
feat(LuaEngine/ItemTemplateMethods): add GetIcon method (#241)
Browse files Browse the repository at this point in the history
Co-authored-by: 55Honey <[email protected]>
  • Loading branch information
iThorgrim and 55Honey authored Feb 5, 2025
1 parent 4ffa5f3 commit 364c03e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/LuaEngine/LuaFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,7 @@ ElunaRegister<ItemTemplate> ItemTemplateMethods[] =
{ "GetAllowableRace", &LuaItemTemplate::GetAllowableRace },
{ "GetItemLevel", &LuaItemTemplate::GetItemLevel },
{ "GetRequiredLevel", &LuaItemTemplate::GetRequiredLevel },
{ "GetIcon", &LuaItemTemplate::GetIcon },
{ NULL, NULL }
};

Expand Down
16 changes: 16 additions & 0 deletions src/LuaEngine/methods/ItemTemplateMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 364c03e

Please sign in to comment.