vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | -- FileName: KillMore.lua |
2 | |||
3 | local KM_USE_ERROR_FRAME = true; -- Use the Error Frame by default |
||
4 | local KM_USE_CHAT_FRAME = true; -- Use the Chat Frame by default |
||
5 | |||
6 | -- |
||
7 | -- Load localized versions in KillMore_GetLocalizedStrings() |
||
8 | -- |
||
9 | local KM_EXPERIENCE_GAINED_STRING = ""; |
||
10 | local KM_HELP_TITLE = ""; |
||
11 | local KM_CMD_HELP = ""; |
||
12 | local KM_CMD_CHAT_HELP = ""; |
||
13 | local KM_CMD_ERROR_HELP = ""; |
||
14 | local KM_CMD_BOTH_HELP = ""; |
||
15 | local KM_CMD_OFF_HELP = ""; |
||
16 | local KM_CMD_STATUS_HELP = ""; |
||
17 | |||
18 | function KillMore_OnLoad() |
||
19 | this:RegisterEvent("CHAT_MSG_COMBAT_XP_GAIN"); |
||
20 | |||
21 | SlashCmdList["KillMore"] = KillMore_Command; |
||
22 | SLASH_KillMore1 = "/killmore"; |
||
23 | end |
||
24 | |||
25 | function KillMore_GetLocalizedStrings() |
||
26 | -- English by default |
||
27 | KM_EXPERIENCE_GAINED_STRING = "(.+) dies, you gain (%d+) experience."; |
||
28 | KM_OUTPUT_STRING = "%d %s needed to level"; |
||
29 | KM_HELP_TITLE = "KillMore Commands:"; |
||
30 | KM_CMD_HELP = " /killmore shows this help message"; |
||
31 | KM_CMD_CHAT_HELP = " /killmore chat outputs the KillMore data in the chat window"; |
||
32 | KM_CMD_ERROR_HELP = " /killmore error outputs the KillMore data to the main screen"; |
||
33 | KM_CMD_BOTH_HELP = " /killmore both outputs the KillMore data to the chat window and main screen"; |
||
34 | KM_CMD_OFF_HELP = " /killmore off turn KillMore off"; |
||
35 | KM_CMD_STATUS_HELP = " /killmore status shows KillMore status"; |
||
36 | |||
37 | |||
38 | -- German |
||
39 | if (GetLocale() == "deDE") then |
||
40 | KM_EXPERIENCE_GAINED_STRING = "(.+) stirbt, Ihr bekommt (%d+) Erfahrung."; |
||
41 | KM_OUTPUT_STRING = "Noch %d %s bis zum n\195\164chsten Level"; |
||
42 | KM_HELP_TITLE = "KillMore Commands:"; |
||
43 | KM_CMD_HELP = " /killmore zeigt diese Nachricht an"; |
||
44 | KM_CMD_CHAT_HELP = " /killmore chat chat schreibt die killmore-Statistik in das Chatfenster"; |
||
45 | KM_CMD_ERROR_HELP = " /killmore error zeigt die killmore-Statstik zentriert im Fenster an"; |
||
46 | KM_CMD_BOTH_HELP = " /killmore both zeigt die killmore-Statstik zentriert im Fenster und in das Chatfenster"; |
||
47 | KM_CMD_OFF_HELP = " /killmore off stellen Sie KillMore ab"; |
||
48 | KM_CMD_STATUS_HELP = " /killmore status Erscheinen KillMore Status"; |
||
49 | end |
||
50 | end |
||
51 | |||
52 | function KillMore_OnEvent() |
||
53 | if (KM_USE_ERROR_FRAME or KM_USE_CHAT_FRAME) then |
||
54 | if (event == "CHAT_MSG_COMBAT_XP_GAIN") then |
||
55 | local xpTotal, xpCurrent, xpToLevel, mobsToLevel; |
||
56 | for creatureName, xp in string.gfind(arg1, KM_EXPERIENCE_GAINED_STRING) do |
||
57 | xpTotal = UnitXPMax("player"); |
||
58 | xpCurrent = UnitXP("player") + xp; |
||
59 | xpToLevel = xpTotal - xpCurrent; |
||
60 | mobsToLevel = abs(xpToLevel / xp)+1; |
||
61 | if (xpCurrent < xpTotal) then |
||
62 | if (KM_USE_ERROR_FRAME) then |
||
63 | UIErrorsFrame:AddMessage(format(TEXT(KM_OUTPUT_STRING),mobsToLevel,creatureName), 1.0, 1.0, 0.0, 1.0, UIERRORS_HOLD_TIME); |
||
64 | end |
||
65 | if (KM_USE_CHAT_FRAME) then |
||
66 | DEFAULT_CHAT_FRAME:AddMessage(format(TEXT(KM_OUTPUT_STRING),mobsToLevel,creatureName),1,1,255); |
||
67 | end |
||
68 | end |
||
69 | return; |
||
70 | end |
||
71 | end |
||
72 | end |
||
73 | end |
||
74 | |||
75 | function KillMore_Command(msg) |
||
76 | msg = string.lower(msg); |
||
77 | |||
78 | if (msg == 'chat') then KM_USE_ERROR_FRAME = false; KM_USE_CHAT_FRAME = true; KillMore_Status(); |
||
79 | elseif (msg == 'error') then KM_USE_ERROR_FRAME = true; KM_USE_CHAT_FRAME = false; KillMore_Status(); |
||
80 | elseif (msg == 'both') then KM_USE_ERROR_FRAME = true; KM_USE_CHAT_FRAME = true; KillMore_Status(); |
||
81 | elseif (msg == 'off') then KM_USE_ERROR_FRAME = false; KM_USE_CHAT_FRAME = false; KillMore_Status(); |
||
82 | elseif (msg == 'status') then KillMore_Status(); |
||
83 | else KillMore_Help(); |
||
84 | end |
||
85 | end |
||
86 | |||
87 | function KillMore_Help() |
||
88 | DEFAULT_CHAT_FRAME:AddMessage(KM_HELP_TITLE, 1.0, 1.0, 0.0); |
||
89 | DEFAULT_CHAT_FRAME:AddMessage(KM_CMD_HELP, 1.0, 1.0, 0.0); |
||
90 | DEFAULT_CHAT_FRAME:AddMessage(KM_CMD_CHAT_HELP, 1.0, 1.0, 0.0); |
||
91 | DEFAULT_CHAT_FRAME:AddMessage(KM_CMD_ERROR_HELP, 1.0, 1.0, 0.0); |
||
92 | DEFAULT_CHAT_FRAME:AddMessage(KM_CMD_BOTH_HELP, 1.0, 1.0, 0.0); |
||
93 | DEFAULT_CHAT_FRAME:AddMessage(KM_CMD_OFF_HELP, 1.0, 1.0, 0.0); |
||
94 | DEFAULT_CHAT_FRAME:AddMessage(KM_CMD_STATUS_HELP, 1.0, 1.0, 0.0); |
||
95 | end |
||
96 | |||
97 | function KillMore_Status() |
||
98 | if (KM_USE_ERROR_FRAME) then |
||
99 | if (KM_USE_CHAT_FRAME) then |
||
100 | DEFAULT_CHAT_FRAME:AddMessage("KillMore Output: Both", 1.0, 1.0, 0.0); |
||
101 | else |
||
102 | DEFAULT_CHAT_FRAME:AddMessage("KillMore Output: Error Frame", 1.0, 1.0, 0.0); |
||
103 | end |
||
104 | elseif (KM_USE_CHAT_FRAME) then |
||
105 | DEFAULT_CHAT_FRAME:AddMessage("KillMore Output: Chat Frame", 1.0, 1.0, 0.0); |
||
106 | else |
||
107 | DEFAULT_CHAT_FRAME:AddMessage("KillMore Output: None", 1.0, 1.0, 0.0); |
||
108 | end |
||
109 | end |