-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGearScoreDKP.lua
More file actions
154 lines (122 loc) · 3.77 KB
/
Copy pathGearScoreDKP.lua
File metadata and controls
154 lines (122 loc) · 3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
-- DKP system by Leo
-- read dkp from roster
function GearScoreDKP_GetDKP()
local DKP_Net, DKP_Tot, DKP_Spent = 99999, 99999, 0;
local tmp;
-- Check if we're in a guild and can view officer notes
if IsInGuild() and CanViewOfficerNote() then
-- Update guild roster so info is read correctly
GuildRoster();
-- find your officer note
for i = 1, GetNumGuildMembers(0) do
local Name,_,_,_,_,_,_,OfficerNote = GetGuildRosterInfo(i);
if Name == GS_Self then
tmp = OfficerNote;
end
end
-- check for valid note
if GearScoreDKP_QDKP(tmp) then
-- find main's name if on alt
local tries = 0;
while GearScoreDKP_IsAlt(tmp) do
if tries == 2 then
print("\124cffff0000You have an alt linking loop. (Your character is linked to an alt that is linked to yourself.) FIX IT!\124r");
break;
end
tmp = GearScoreDKP_GetMain(tmp);
tries = tries + 1;
end
-- get dkp net
DKP_Net = GearScoreDKP_ParseNote(tmp, 1);
-- get dkp total and spent
DKP_Tot = GearScoreDKP_ParseNote(tmp, 2);
DKP_Spent = DKP_Tot - DKP_Net;
end
-- display this shit
PersonalDKP_Net:SetText("DKP: "..DKP_Net);
PersonalDKP_Tot:SetText("Spent: "..DKP_Spent);
-- move strings if too long
if (string.len(DKP_Tot) == 5 or string.len(DKP_Net) == 5) and DKP_Tot ~= 99999 then
PersonalDKP_Tot:SetPoint("BOTTOMLEFT",PaperDollFrame,"TOPLEFT",230,-265)
PersonalDKP_Net:SetPoint("BOTTOMLEFT",PaperDollFrame,"TOPLEFT",230,-253)
else
PersonalDKP_Tot:SetPoint("BOTTOMLEFT",PaperDollFrame,"TOPLEFT",240,-265)
PersonalDKP_Net:SetPoint("BOTTOMLEFT",PaperDollFrame,"TOPLEFT",240,-253)
end
-- color this shit
GearScoreDKP_ColorString(DKP_Net);
end
end
-- check that correct DKP string is in note
function GearScoreDKP_QDKP(OfficerNote)
OfficerNote = strlower(OfficerNote);
if OfficerNote:find("%w+:-?%d+ %w+:%d+") or OfficerNote:match("%w+") then
return true;
else
return false;
end
end
-- check if alt
function GearScoreDKP_IsAlt(OfficerNote)
if OfficerNote:find(":") then
return false;
else
return true;
end
end
-- get alt's dkp string from main's note
function GearScoreDKP_GetMain(GS_Self)
local tmp = "Net:99999 Tot:99999 Hrs:99999";
for i = 1, GetNumGuildMembers(1) do
local Name,_,_,_,_,_,_,OfficerNote = GetGuildRosterInfo(i);
if Name == GS_Self then
tmp = OfficerNote;
end
end
return tmp;
--return "Net:0 Tot:0 Hrs:0";
end
-- get Net from officer note (OFFSET1 = DKP | OFFSET2 = TOTAL)
function GearScoreDKP_ParseNote(OfficerNote, Offset)
local DKP = {};
-- extract any numbers between : and space
for item in string.gmatch(OfficerNote, ":(-?%d+)") do
table.insert(DKP, item);
end
return DKP[Offset];
end
-- color dkp text based on value
function GearScoreDKP_ColorString(DKP)
DKP = tonumber(DKP); -- Probably should have done this sooner, whatever.
if DKP == 0 then
DKP = 1;
end
local modGS = 6000; -- This makes your dkp turn red at cap
local Red, Green, Blue = GearScore_GetQuality(DKP * (modGS / GearScoreDKP_GetCap()));
-- show it
PersonalDKP_Tot:SetTextColor(Red, Green, Blue, 1);
PersonalDKP_Net:SetTextColor(Red, Green, Blue, 1);
-- We're disabling dkp if the value is incorrect.
if DKP == 99999 then
PersonalDKP_Tot:SetText("");
PersonalDKP_Net:SetText("");
end
end
function GearScoreDKP_SetCap(Max)
local guildName, _ = GetGuildInfo("player");
if IsInGuild() then
GS_Guilds[guildName] = Max;
end
end
function GearScoreDKP_GetCap()
local guildName, _ = GetGuildInfo("player");
if IsInGuild() then
if GS_Guilds[guildName] == nil then
return 0;
else
return GS_Guilds[guildName];
end
else
return 0;
end
end