eluna api, return item icon
src\server\game\DataStores\DBCfmt.h
src\server\game\DataStores\DBCStores.cpp
src/server/game/DataStores/DBCStores.h
src/server/game/DataStores/DBCStructure.h
src\LuaEngine\GlobalMethods.h
src\LuaEngine\ItemMethods.h
src\LuaEngine\LuaFunctions.cpp
use:
item:GetIcon(40,40,0,0)
or
GetIcon(item,40,40)
or
GetIcon(123456,40,40,-1,10)
Thanks~ :argh::argh:
src\server\game\DataStores\DBCfmt.h
Code:
---- //char const ItemDisplayTemplateEntryfmt[] = "nxxxxxxxxxxixxxxxxxxxxx";
++++ char const ItemDisplayTemplateEntryfmt[] = "nxxxxsxxxxxxxxxxxxxxxxxxx";
src\server\game\DataStores\DBCStores.cpp
Code:
---- //DBCStorage <ItemDisplayInfoEntry> sItemDisplayInfoStore(ItemDisplayTemplateEntryfmt); -- not used currently
++++ DBCStorage <ItemDisplayInfoEntry> sItemDisplayInfoStore(ItemDisplayTemplateEntryfmt);
src/server/game/DataStores/DBCStores.h
Code:
---- //extern DBCStorage <ItemDisplayInfoEntry> sItemDisplayInfoStore; -- not used currently
++++ extern DBCStorage <ItemDisplayInfoEntry> sItemDisplayInfoStore;
src/server/game/DataStores/DBCStructure.h
Code:
uint32 ID; // 0 m_ID
// 1 m_modelName[2]
// 2 m_modelTexture[2]
--- // 3 m_inventoryIcon
+++ char* inventoryIcon; // 3 m_inventoryIcon
// 4 m_geosetGroup[3]
// 5 m_flags
// 6 m_spellVisualID
src\LuaEngine\GlobalMethods.h
Code:
int GetIcon(lua_State* L)
{
Item* item = Eluna::CHECKOBJ<Item>(L, 1, false);
const ItemDisplayInfoEntry* dispInfo;
if (!item)
{
uint32 entry = Eluna::CHECKVAL<uint32 >(L, 1);
const ItemTemplate* temp = eObjectMgr->GetItemTemplate(entry);
if (temp)
dispInfo = sItemDisplayInfoStore.LookupEntry(temp->DisplayInfoID);
}
else
dispInfo = sItemDisplayInfoStore.LookupEntry(item->GetTemplate()->DisplayInfoID);
std::ostringstream iconText;
float w = Eluna::CHECKVAL<float >(L, 2);
float h = Eluna::CHECKVAL<float >(L, 3);
float x = Eluna::CHECKVAL<float >(L, 4,0);
float y = Eluna::CHECKVAL<float >(L, 5,0);
iconText << "|TInterface";
if (dispInfo)
{
iconText << "/ICONS/" << dispInfo->inventoryIcon;
}
else
{
iconText << "/InventoryItems/WoWUnknownItem01";
}
iconText << ":" << w << ":" << h << ":" << x << ":" << y << "|t";
Eluna::Push(L, iconText.str());
return 1;
}
src\LuaEngine\ItemMethods.h
Code:
int GetIcon(lua_State* L, Item* item)
{
std::ostringstream iconText;
float w = Eluna::CHECKVAL<float >(L, 2);
float h = Eluna::CHECKVAL<float >(L, 3);
float x = Eluna::CHECKVAL<float >(L, 4,0);
float y = Eluna::CHECKVAL<float >(L, 5,0);
const ItemDisplayInfoEntry* dispInfo = sItemDisplayInfoStore.LookupEntry(item->GetTemplate()->DisplayInfoID);
iconText << "|TInterface";
if (dispInfo)
{
iconText << "/ICONS/" << dispInfo->inventoryIcon;
}
else
{
iconText << "/InventoryItems/WoWUnknownItem01";
}
iconText << ":" << w << ":" << h << ":" << x << ":" << y << "|t";
Eluna::Push(L, iconText.str());
return 1;
}
src\LuaEngine\LuaFunctions.cpp
Code:
void RegisterGlobals(lua_State* L)
{
// Getters
++++ lua_register(L, "GetIcon", &LuaGlobalFunctions::GetIcon); //GetIcon(entry/item,high,width,x,y)
Code:
ElunaRegister<Item> ItemMethods[] =
{
// Getters
++++ { "GetIcon", &LuaItem::GetIcon }, // :GetIcon(high,width,x,y)
use:
item:GetIcon(40,40,0,0)
or
GetIcon(item,40,40)
or
GetIcon(123456,40,40,-1,10)
Thanks~ :argh::argh:
Last edited: