mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-26 16:50:15 +00:00
feat: add GetEnchantInfo for enchantment name resolution
GetEnchantInfo(enchantId) looks up the enchantment name from SpellItemEnchantment.dbc (field 14). Returns the display name like "Crusader", "+22 Intellect", or "Mongoose" for a given enchant ID. Used by equipment comparison addons and tooltip addons to display enchantment names on equipped gear. The enchant ID comes from the item's ITEM_FIELD_ENCHANTMENT update field. Also adds getEnchantName() to GameHandler for C++ access.
This commit is contained in:
parent
922d6bc8f6
commit
b9a1b0244b
3 changed files with 28 additions and 0 deletions
|
|
@ -1687,6 +1687,17 @@ static int lua_GetSpellDescription(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
// GetEnchantInfo(enchantId) → name or nil
|
||||
static int lua_GetEnchantInfo(lua_State* L) {
|
||||
auto* gh = getGameHandler(L);
|
||||
if (!gh) { lua_pushnil(L); return 1; }
|
||||
uint32_t enchantId = static_cast<uint32_t>(luaL_checknumber(L, 1));
|
||||
std::string name = gh->getEnchantName(enchantId);
|
||||
if (name.empty()) { lua_pushnil(L); return 1; }
|
||||
lua_pushstring(L, name.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lua_GetSpellCooldown(lua_State* L) {
|
||||
auto* gh = getGameHandler(L);
|
||||
if (!gh) { lua_pushnumber(L, 0); lua_pushnumber(L, 0); return 2; }
|
||||
|
|
@ -5049,6 +5060,7 @@ void LuaEngine::registerCoreAPI() {
|
|||
{"GetSpellCooldown", lua_GetSpellCooldown},
|
||||
{"GetSpellPowerCost", lua_GetSpellPowerCost},
|
||||
{"GetSpellDescription", lua_GetSpellDescription},
|
||||
{"GetEnchantInfo", lua_GetEnchantInfo},
|
||||
{"IsSpellInRange", lua_IsSpellInRange},
|
||||
{"UnitDistanceSquared", lua_UnitDistanceSquared},
|
||||
{"CheckInteractDistance", lua_CheckInteractDistance},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue