我怎样才能给 lua 中的文本上色?

How can i put color on text in lua?

currentHead, maximumHead= GetInventoryItemDurability(1);
currentShoulder, maximumShoulder = GetInventoryItemDurability(3);
currentChest, maximumChest = GetInventoryItemDurability(5);

print("Head: " .. currentHead .. " Durability")
print("Shoulders: " .. currentShoulder .. " Durability")
print("Chest: " .. currentChest .. "/" .. maximumChest .. " Durability")

我正在为魔兽世界制作一个插件,我想知道如何更改打印中字母的颜色

试试这个。如果在一分钟左右通过网络搜索找到它...

https://www.wowinterface.com/forums/showthread.php?t=25712

colors = {
    {
        title = 'LIGHTBLUE',
        color = 'cff00ccff',
    }, -- and many more
}
function printColors()
    --print("4cffFF0000This text is red4r") --This is red color
    local startLine = '4'
    local endLine = '4r'
    for i = 1, table.getn(colors) do
        print(startLine .. colors[i].color .. colors[i].title .. endLine)
    end
end

根据 https://wow.gamepedia.com/UI_escape_sequences

你也可以使用WrapTextInColorCode(text, colorCode)