View Single Post
11-05-09, 07:16 PM   #13
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
Originally Posted by dlui View Post
I don't know a nice way to take screenshots on reputation level ups, any ideas on how to implement that?
Sample Code (tested in a mini-addon):
1. In function Multishot:OnEnable() add
Code:
self:RegisterEvent("CHAT_MSG_SYSTEM")
2. Create a capture pattern from the global rep standing change formatstring:
Code:
local FACTION_CAPTURE_PATTERN = string.gsub(FACTION_STANDING_CHANGED,"%%%d?%$?s", "(.+)")
This will make your capture pattern locale independent.

3. In your CHAT_MSG_SYSTEM event handler:
Check arg1 (the first argument of the event is the actual message)
against your capture pattern.
Code:
local newstanding, withfaction = string.match(arg1, FACTION_CAPTURE_PATTERN)
4. If you catch a relevant system message and newstanding is not nil:
Compare it with the global standing labels (this will also work locale independent)
Code:
if newstanding == FACTION_STANDING_LABEL8
or newstanding == FACTION_STANDING_LABEL8_FEMALE
then
-- do our screenshot magic
end
This would only screenshot if you just gained Exalted status.
To check for other rep standings or make it screenshot on any major rep change,
you'd need to check against FACTION_STANDING_LABELx or FACTION_STANDING_LABELx_FEMALE
where x is 1 to 8 and corresponds to Hated, Hostile, Unfriendly, Neutral, Friendly, Honored, Revered, Exalted.

Hope it helps
  Reply With Quote