魔兽世界的 LUA 脚本:MSP,结合 GTAL?

虽然我知道从基础开始最好,但我喜欢尝试。但这对我来说很难。在魔兽世界中,我使用ElvUI和MyRolePlay(MRP),结果出现了增强的工具提示问题。我已经对代码进行了相当多的编辑,现在唯一剩下的是尝试使最后一行的格式正确 - 三个变量全部在同一行上。我不明白什么是gtal(或“L”),但它似乎会创建一个新行。有没有办法结合gtal行,同时保留它们各自的RGB颜色?我试图保持在代码风格内(因为我很难引入新代码),但由于作者如何调用变量的颜色,我无法使最终的%s具有自己的颜色值,而不必创建全新的一行。

local dC = GetQuestDifficultyColor(level);
local cC = RAID_CLASS_COLORS[ classunloc ];

我能想到的最好的是,

gtal( format( L["|r%s|cffffffff %s"], e, emptynil( mrp.DisplayTooltip.RA( f.RA ) ) or race, class), dC.r, dC.g, dC.b )
gtal( format( L["|r%s"], class), cC.r, cC.g, cC.b )

关于mod和其他地方都没有gtal的信息。我听说作者很难接近。但我希望有人能从这里得到灵感。

这两个gtal行的结果 完美,只要最后一个词在上一行就好了!

如果有帮助的话,所有这些都在这个块中

local dC = GetQuestDifficultyColor(level);
local cC = RAID_CLASS_COLORS[ classunloc ];
if level ~= nil and level < 0 then
    e = L["|cffffffff(Boss)"]
else
    e = format( L["|r%d|cffffffff"], level )
end
if mspsupported then
    gtal( format( L["|r%s|cffffffff %s"], e, emptynil( mrp.DisplayTooltip.RA( f.RA ) ) or race, class), dC.r, dC.g, dC.b )
    gtal( format( L["|r%s"], class), cC.r, cC.g, cC.b )
    n = nil
    t = nil
    if f.FR and f.FR ~= "" and f.FR ~= "0" then
        n = mrp.DisplayTooltip.FR( f.FR ) .. "  "
    end

最后,这就是原始gtal的样子

gtal( format( L["%s %s |r%s|cffffffff (Player)"], e, emptynil( mrp.DisplayTooltip.RA( f.RA ) ) or race, class), r, g, b )
r, g, b = 1.0, 1.0, 1.0

更新 - 这里的解决方案是这样的,因为如果这对其他人有帮助:

local dC = GetQuestDifficultyColor(level);
local cC = RAID_CLASS_COLORS[ classunloc ];
if level ~= nil and level < 0 then
    e = L["|cffffffff(Boss)"]
else
    e = format( L["|r%d|cffffffff"], level )
end
if mspsupported then
    local classStr = format("|cff%02x%02x%02x%s|r", cC.r * 255, cC.g * 255, cC.b * 255, class)
    local str = format( L["|r%s |cffffffff%s|r %s"], e, emptynil( mrp.DisplayTooltip.RA( f.RA ) ) or race, classStr)
    gtal(str, dC.r, dC.g, dC.b)
点赞
用户271475
用户271475

gtalUI_Tooltip.lua 中被定义:

--[[
  EPIC KLUDGE!
  Special local functions to overwrite and add the current tooltip.
]]
-- 单个字符串
local function gtal( n, r, g, b )
  local l = GameTooltip.mrpLines + 1
  GameTooltip.mrpLines = l

  r, g, b = (r or 1.0), (g or 1.0), (b or 1.0)

  --if GameTooltip.mrpLines <= GameTooltip.orgLines then
    -- 按我们的格式替换原本的行,如果不存在就新增
    if _G["GameTooltipTextLeft"..tostring(l)] then
      if _G["GameTooltipTextLeft"..tostring(l)]:IsVisible() then
        if _G["GameTooltipTextRight"..tostring(l)] then
          _G["GameTooltipTextRight"..tostring(l)]:Hide()
        end
        _G["GameTooltipTextLeft"..tostring(l)]:SetText( n )
        _G["GameTooltipTextLeft"..tostring(l)]:SetTextColor( r, g, b )
      else
        GameTooltip:AddLine( n, r, g, b )
      end
    else
      GameTooltip:AddLine( n, r, g, b )
    end
end

L 通常是一个用于查找本地化表的变量,在这里用于如果需要其他语言的格式字符串。

在这种情况下,看起来 gtal 总是添加一行,因此您需要在同一行中完成您的工作。幸运的是,WoW 提供了内联颜色覆盖,您可以使用它们!请参见 UI 转义序列 - 字符串中的 |cxxxxxxxx 就是这样的。您可能需要这样做:

-- 创建一个彩色格式的职业字符串
local classStr = format("|c%02x%02x%02x%s|r", cC.r, cC.g, cC.b, class)
-- 创建您的工具提示行,其中包括 `$e $race $class`
local str = format(L["|r%s |cffffffff%s|r %s"], e, emptynil(mrp.DisplayTooltip.RA(f.RA)) or race, classStr)
-- 将行添加到工具提示
gtal(str, dC.r, dC.g, dC.b)
2015-03-06 18:58:51