Added CreateTextureString and AttachSpellIcon to DiesalTools

main
jeffi 11 months ago
parent 31e349d8b2
commit 8c2f43b11e
  1. 26
      DiesalTools-2.0/DiesalTools-2.0.lua

@ -637,3 +637,29 @@ function DiesalTools.GetTexCoord(zoomPercent, width, height, xOffset, yOffset)
return unpack(currentCoord)
end
---@param texture string|integer
function DiesalTools.CreateTextureString(texture)
if type(texture) ~= "string" then
texture = tostring(texture)
end
return string.format("|T%s:0::0:0:64:64:4:60:4:60|t", texture)
end
---@param spell number | Bastion.Spell
---@param text? string
---@param position? "start" | "end"
function DiesalTools.AttachSpellIcon(spell, text, position)
position = position or "start"
local icon
if type(spell) == "table" then
text = text or spell:GetName()
icon = spell:GetIcon()
elseif type(spell) == "number" then
text = text or GetSpellInfo(spell)
icon = select(3, GetSpellInfo(spell))
end
return string.format("%s %s", position == "start" and DiesalTools.CreateTextureString(icon) or text, position == "end" and DiesalTools.CreateTextureString(icon) or text)
end

Loading…
Cancel
Save