如何在lua中为文本添加颜色?

如何在lua中为文本添加颜色?,lua,world-of-warcraft,Lua,World Of Warcraft,我正在为魔兽世界制作一个插件,我想知道如何更改打印字母的颜色。如果在一分钟内通过websearch找到它 据 您也可以使用wraptextinocolorcode(文本,颜色代码)试试这个。如果在一分钟内通过websearch找到它 据 您还可以使用wraptextinocorcode(text,colorCode)哪个Lua版本有table.getn()?-Lua5.1中不推荐使用@koyaanisqatsi-getn来替代Lua5.3中的table.getn()。使用长度运算符#,#

我正在为魔兽世界制作一个插件,我想知道如何更改打印字母的颜色。如果在一分钟内通过websearch找到它


您也可以使用
wraptextinocolorcode(文本,颜色代码)

试试这个。如果在一分钟内通过websearch找到它


您还可以使用
wraptextinocorcode(text,colorCode)

哪个Lua版本有
table.getn()
?-Lua5.1中不推荐使用@koyaanisqatsi-getn来替代Lua5.3中的
table.getn()
。使用长度运算符
#
#colors
替换
表格.getn(colors)
。或者干脆做
i,v在ipairs(colors)中打印(startine..v.color..v.title..endline)end
你在哪里有网站搜索?我来自柏林/德国,我使用metager.de-我在Lua 5.3.5中尝试了上面的代码,用
Lua-i
替换
table.getn()
使用
#颜色
时,不会出现彩色输出-只有一些奇怪的代码,如:
|cff00cfflightblue | r
我不知道Lua5.3.5上已经有了WoW,我只能告诉你我在文档中找到了什么,以及我在论坛上用几个示例确认了什么。如果这不起作用,你可能最好在WoW社区询问同意-为我的失败感到抱歉哪个Lua版本有
table.getn()
?-Lua5.1中不推荐使用@koyaanisqatsi-getn来替代Lua5.3中的
table.getn()
。使用长度运算符
#
#colors
替换
表格.getn(colors)
。或者干脆做
i,v在ipairs(colors)中打印(startine..v.color..v.title..endline)end
你在哪里有网站搜索?我来自柏林/德国,我使用metager.de-我在Lua 5.3.5中尝试了上面的代码,用
Lua-i
替换
table.getn()
使用
#颜色
时,不会出现彩色输出-只有一些奇怪的代码,如:
|cff00cfflightblue | r
我不知道Lua5.3.5上已经有了WoW,我只能告诉你我在文档中找到了什么,以及我在论坛上用几个示例确认了什么。如果这不起作用,你最好去问一下魔兽世界社区同意吗?对不起,我失败了
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")
colors = {
    {
        title = 'LIGHTBLUE',
        color = 'cff00ccff',
    }, -- and many more
}
function printColors()
    --print("\124cffFF0000This text is red\124r") --This is red color
    local startLine = '\124'
    local endLine = '\124r'
    for i = 1, table.getn(colors) do
        print(startLine .. colors[i].color .. colors[i].title .. endLine)
    end
end