📄 tipbuddy.lua
字号:
end
--------------------------------------------------------------------------------------------------------------------------------------
-- GET/COLOR NAME
--------------------------------------------------------------------------------------------------------------------------------------
function TipBuddy_TargetInfo_CheckName( type, unit )
local targettype = TipBuddy_SavedVars[type];
TipBuddy.gtt_namecolor = "";
if (targettype.off == 2) then
return;
end
if (not type or not unit) then
TipBuddy.gtt_namecolor = tbcolor_unknown;
if (UnitName(unit)) then
TipBuddy.gtt_name = UnitName(unit);
else
TipBuddy.gtt_name = "";
end
return;
end
if (UnitHealth(unit) <= 0) then
TipBuddy.gtt_namecolor = tbcolor_corpse;
elseif (TipBuddy.reaction) then
TipBuddy.gtt_namecolor = getglobal("tbcolor_nam_"..TipBuddy.reaction);
elseif ( UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit) ) then
TipBuddy.gtt_namecolor = (tbcolor_nam_tappedother.." >");
elseif (UnitIsTappedByPlayer(unit)) then
TipBuddy.gtt_namecolor = (tbcolor_nam_tappedplayer);
else
TipBuddy.gtt_namecolor = tbcolor_unknown;
end
if (TipBuddy.refresh == 1 and TipBuddy.gtt_name ~= nil) then
return;
end
if (not UnitPlayerControlled(unit)) then
if (UnitName(unit)) then
TipBuddy.gtt_name = UnitName(unit);
else
TipBuddy.gtt_name = "";
end
elseif (targettype.rnm == 1) then
if (unit == "player" or unit == "mouseover" or unit == "target" ) then
TipBuddy.gtt_name = UnitPVPName(unit);
else
if (getglobal("GameTooltipTextLeft1"):GetText()) then
TipBuddy.gtt_name = getglobal("GameTooltipTextLeft1"):GetText();
else
if (UnitName(unit)) then
TipBuddy.gtt_name = UnitName(unit);
else
TipBuddy.gtt_name = "";
end
end
end
else
if (UnitName(unit)) then
TipBuddy.gtt_name = UnitName(unit);
else
TipBuddy.gtt_name = "";
end
end
if (not TipBuddy.gtt_name or TipBuddy.gtt_name == "") then
TipBuddy.gtt_name = tb_translate_notspecified;
end
end
--------------------------------------------------------------------------------------------------------------------------------------
-- GET TARGET's TARGET
--------------------------------------------------------------------------------------------------------------------------------------
function TipBuddy_TargetInfo_TargetsTarget( type, unit )
if (not TipBuddy.gtt_target) then
TipBuddy.gtt_target = "";
end
if (TipBuddy_SavedVars[type].trg == 0 and TipBuddy_SavedVars[type].off ~= 2) then
--TB_AddMessage("TT for "..type.." is turned off");
return;
end
local tunit = unit.."target";
local target = UnitName(tunit);
if (target) then
if (target == UNKNOWNOBJECT) then
return;
end
local treaction = TipBuddy_GetUnitReaction( tunit );
local tcolor = "";
TipBuddy.tt = 1;
if (target == UnitName("player")) then
tcolor = TB_WHT_TXT;
if (TipBuddy_SavedVars[type].trg_2l and TipBuddy_SavedVars[type].trg_2l == 1) then
TipBuddy.gtt_target = "\n"..tcolor.." [YOU]";
else
TipBuddy.gtt_target = tcolor.." : [YOU]";
end
--TB_AddMessage("target = "..tcolor.." [YOU]");
return;
elseif (target == UnitInParty(tunit)) then
if (TipBuddy_SavedVars[type].trg_pa == 0) then
return;
else
tcolor = TB_PNK_TXT;
end
elseif (UnitHealth(tunit) <= 0) then
tcolor = TB_DGY_TXT;
--elseif (treaction) then
elseif ( UnitPlayerControlled(tunit) ) then
--[[
TB_NML_TXT = "|cffffd200"
TB_WHT_TXT = "|cffffffff"
TB_GRY_TXT = "|cffC0C0C0"
TB_DGY_TXT = "|cff585858"
TB_RED_TXT = "|cffff2020"
TB_GRN_TXT = "|cff20ff20"
TB_YLW_TXT = "|cffffff00"
TB_BLE_TXT = "|cff3366ff"
TB_PNK_TXT = "|cffff00ff"
TB_DBL_TXT = "|cff3399ff"
TB_DGN_TXT = "|cff339900"
TB_DRD_TXT = "|cffcc0000"
]]
if ( UnitCanAttack(tunit, "player") or UnitCanAttack("player", tunit) ) then
if (TipBuddy_SavedVars[type].trg_en == 0) then
return;
else
tcolor = TB_RED_TXT;
end
--return "hostile";
else
-- All other players are green
if (TipBuddy_SavedVars[type].trg_pl == 0) then
return;
else
tcolor = TB_GRN_TXT;
--return "friendly";
end
end
elseif ( UnitIsEnemy(tunit, "player") ) then
if (TipBuddy_SavedVars[type].trg_en == 0) then
return;
else
tcolor = TB_RED_TXT;
--return "pvp";
end
else
if (TipBuddy_SavedVars[type].trg_np == 0) then
return;
else
tcolor = TB_BLE_TXT;
end
end
--TipBuddy.gtt_target = tcolor.." ["..TB_WHT_TXT..UnitName(unit.."target")..tcolor.."]";
if (TipBuddy_SavedVars[type].trg_2l and TipBuddy_SavedVars[type].trg_2l == 1) then
TipBuddy.gtt_target = "\n"..TB_WHT_TXT.." "..tcolor.."["..UnitName(unit.."target").."]";
else
TipBuddy.gtt_target = TB_WHT_TXT.." : "..tcolor.."["..UnitName(unit.."target").."]";
--TB_AddMessage("target = "..tcolor.."["..UnitName(unit.."target").."]");
end
else
TipBuddy.tt = 0;
end
end
function TipBuddy_Adv_TargetsTarget( unit )
local tunit = unit.."target";
local target = UnitName(tunit);
if (target) then
local treaction = TipBuddy_GetUnitReaction( tunit );
local tcolor = "";
if (target == UnitName("player")) then
return "YOU", TB_WHT_TXT;
elseif (target == UnitInParty(tunit)) then
return target, TB_PNK_TXT;
elseif (UnitHealth(tunit) <= 0) then
return target, TB_DGY_TXT;
elseif ( UnitPlayerControlled(tunit) ) then
if ( UnitCanAttack(tunit, "player") or UnitCanAttack("player", tunit) ) then
--return "hostile";
return target, TB_RED_TXT;
else
--return "friendly";
return target, TB_GRN_TXT;
end
elseif ( UnitIsEnemy(tunit, "player") ) then
--return "pvp";
return target, TB_RED_TXT;
else
return target, TB_BLE_TXT;
end
else
return "", "";
end
end
--------------------------------------------------------------------------------------------------------------------------------------
-- GET/SHOW CITY FACTION
--------------------------------------------------------------------------------------------------------------------------------------
function TipBuddy_TargetInfo_ShowCityFaction( type, unit )
if (UnitPlayerControlled(unit) or unit == "player" or unit == "party1" or unit == "partypet1" or unit == "party2" or unit == "partypet2" or unit == "party3" or unit == "partypet3" or unit == "party4" or unit == "partypet4" or unit == "party5" or unit == "partypet5" ) then
--TB_AddMessage("CityFac: found a player");
return;
end
local line;
for i=1, (GameTooltip:NumLines()), 1 do
local tipline = getglobal("GameTooltipTextLeft"..i);
if (not tipline or not tipline:GetText()) then
--TB_AddMessage("tipline: "..i.." is empty");
return;
end
if ( string.find(tipline:GetText(), LEVEL..".+") or string.find(tipline:GetText(), TipBuddy.gtt_level..".+") ) then
line = getglobal("GameTooltipTextLeft"..(i + 1));
if (line:GetText() == "\n" or line:GetText() == nil) then
--TB_AddMessage("Line after Level is empty");
break;
end
--if (type == "corpse") then
--TB_AddMessage("CityFac: found corpse");
-- break;
if (string.find(line:GetText(), PVP_ENABLED) or line:GetText() == nil) then
--TB_AddMessage("CityFac: found PvP or something");
break;
else
--TB_AddMessage("testing cityfac: ("..line:GetText()..") Line: "..(i+1));
for j=1, table.getn(TB_Factions), 1 do
if (line:GetText() == TB_Factions[j]) then
--TB_AddMessage("found cityfac: ("..line:GetText()..") Line: "..(i+1));
TipBuddy.gtt_lastline = i+1;
TipBuddy.gtt_cityfac = line:GetText();
break;
end
end
end
end
end
end
function TipBuddy_ConfirmLastLine(unit)
local line;
for i=TipBuddy.gtt_numlines, 1, -1 do
line = getglobal("GameTooltipTextLeft"..i);
if (not line or not line:GetText()) then
return;
end
TB_AddMessage("LASTLINE: i = "..i..", text: "..line:GetText());
if (string.find(line:GetText(), PVP_ENABLED)
or string.find(line:GetText(), LEVEL )
or (TipBuddy.gtt_cityfac ~= "" and string.find(line:GetText(), TipBuddy.gtt_cityfac ) ) ) then
if (i > TipBuddy.gtt_lastline) then
TipBuddy.gtt_lastline = i;
TB_AddMessage("i>LL: "..TipBuddy.gtt_lastline);
break;
else
TB_AddMessage("i!>LL: "..TipBuddy.gtt_lastline);
break;
end
end
end
end
--------------------------------------------------------------------------------------------------------------------------------------
-- GET EXTRAS
--------------------------------------------------------------------------------------------------------------------------------------
function TipBuddy_TargetInfo_FindExtras()
TipBuddy_GTT_GetExtraLines(10);
TipBuddy_TargetInfo_ShowExtras();
end
function TipBuddy_TargetInfo_ShowExtras()
TB_AddMessage("SHOWING_EXTRAS");
if (TipBuddy.gtt_xtra) then
local lineL, LineR;
for i=1, 10, 1 do
getglobal("TipBuddy_Xtra"..i.."_Text"):Hide();
getglobal("TipBuddy_Xtra"..i.."_Text"):SetText("");
getglobal("TipBuddy_XtraR"..i.."_Text"):Hide();
getglobal("TipBuddy_XtraR"..i.."_Text"):SetText("");
end
for i=1, table.getn(TipBuddy.gtt_xtra), 1 do
lineL = getglobal("TipBuddy_Xtra"..i.."_Text");
--TB_AddMessage(TEXT(TipBuddy.gtt_xtra[i]))
if (TipBuddy.gtt_xtra[i.."color"]) then
lineL:SetVertexColor(TipBuddy.gtt_xtra[i.."color"].r, TipBuddy.gtt_xtra[i.."color"].g, TipBuddy.gtt_xtra[i.."color"].b);
else
lineL:SetTextColor(HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
end
if (TipBuddy.gtt_xtraR) then
lineL:SetText(TEXT(TipBuddy.gtt_xtra[i]));
lineL:Show();
lineR = getglobal("TipBuddy_XtraR"..i.."_Text");
--TB_AddMessage(TEXT(TipBuddy.gtt_xtraR[i]))
lineR:SetText(TEXT(TipBuddy.gtt_xtraR[i]));
lineR:Show();
else
lineL:SetText(TEXT(TipBuddy.gtt_xtra[i]));
lineL:Show();
end
end
--[[if (TipBuddy.gtt_xtra) then
for i=1, table.getn(TipBuddy.gtt_xtra), 1 do
tip = getglobal("GameTooltipTextLeft"..tipnum);
tipR = getglobal("GameTooltipTextRight"..tipnum);
--TB_AddMessage(TipBuddy.gtt_xtra[i])
if (tipnum > TipBuddy.gtt_numlines) then
if (TipBuddy.gtt_xtraR) then
GameTooltip:AddDoubleLine(TipBuddy.gtt_xtra[i], TipBuddy.gtt_xtraR[i]);
else
GameTooltip:AddLine(TipBuddy.gtt_xtra[i]);
end
else
if (TipBuddy.gtt_xtraR) then
tip:SetText(TipBuddy.gtt_xtra[i]);
tipR:SetText(TipBuddy.gtt_xtraR[i]);
else
tip:SetText(TipBuddy.gtt_xtra[i]);
end
end
tip:Show();
tipnum = tipnum + 1;
end
end]]
end
end
function TipBuddy_GTT_GetExtraLines( numlines )
--TB_AddMessage("getting extra lines");
if (not numlines) then
return;
end
TB_AddMessage("!! lastline: "..TipBuddy.gtt_lastline..", numlines (stored): "..TipBuddy.gtt_numlines..", numlines (real): "..GameTooltip:NumLines());
TipBuddy.gtt_xtra = {};
TipBuddy.gtt_xtraR = {};
if (numlines > TipBuddy.gtt_lastline) then
--TB_AddMessage("numlines > TipBuddy.gtt_lastline");
--/script GameTooltipTextLeft1:SetText(GameTooltipTextLeft1:GetText().."\nSecondLine");GameTooltip:Show();
local line, text;
local j = 1;
for i=TipBuddy.gtt_lastline + 1, numlines, 1 do
line = getglobal("GameTooltipTextLeft"..i);
lineR = getglobal("GameTooltipTextRight"..i);
if (not line or not line:GetText() or string.find(line:GetText(), PVP_ENABLED)) then
return;
elseif (string.find(line:GetText(), PVP_RANK_CIVILIAN) or string.find(line:GetText(), RESURRECTABLE) or string.find(line:GetText(), UNIT_SKINNABLE)) then
TipBuddy.gtt_xtra[j.."color"] = {};
TipBuddy.gtt_xtra[j.."color"].r, TipBuddy.gtt_xtra[j.."color"].g, TipBuddy.gtt_xtra[j.."color"].b = line:GetTextColor();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -