Thread Tools Display Modes
05-27-06, 04:18 PM   #1
Echo5ive
A Defias Bandit
AddOn Author - Click to view addons
Join Date: Oct 2005
Posts: 3
FuBar and events

I'm not quite used to lua and event management yet, so this might possibly be a very easy question. I'm learning lua and the script API as I go.

I'm working on a FuBar mod that watches your reputation and monitors how much you've gained/lost.

Code:
function WangFu:Enable()
	self:RegisterEvent("CHAT_MSG_COMBAT_FACTION_CHANGE");
end

function WangFu:CHAT_MSG_COMBAT_FACTION_CHANGE()
	DEFAULT_CHAT_FRAME:AddMessage("Rep changed")
end
So far so good - I get a message when I get reputation. However, I can't figure out how to extract the faction and amount of rep gained/lost in the event function. Anyone got a friendly pointer?
  Reply With Quote
05-27-06, 05:27 PM   #2
chuckg
A Fallenroot Satyr
 
chuckg's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2005
Posts: 26
I haven't messed around with faction changes, so I'm not 100% sure but this should work:

Code:
function WangFu:Enable()
self:RegisterEvent("CHAT_MSG_COMBAT_FACTION_CHANGE", "FactionChange");
end

function WangFu:FactionChange(arg)
DEFAULT_CHAT_FRAME:AddMessage("Rep changed")
_,_,faction,_,change,rep = strfind(arg, "Your reputation with has (.+) has (.+) (.+) ((.+) reputation (.+)");
end
That should work. The strfind was an example, I don't remember precisely what the rep change line is, but faction/change/rep would catch the faction it changed with, whether it was an increase and by how much. But, it should look something like that.
  Reply With Quote
05-27-06, 10:56 PM   #3
Echo5ive
A Defias Bandit
AddOn Author - Click to view addons
Join Date: Oct 2005
Posts: 3
My problem appears to be that the event doesn't pass on any arguments whatsoever.
  Reply With Quote
05-28-06, 07:59 AM   #4
Aileen
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 28
Originally Posted by Echo5ive
My problem appears to be that the event doesn't pass on any arguments whatsoever.
Are you sure? Try:

Code:
function WangFu:CHAT_MSG_COMBAT_FACTION_CHANGE()
	ace:print(arg1)
end
I was working on a faction addon for a little while before SCT got the faction info in it, and this is an example what I used:

Code:
function Foo:Enable()
  self:RegisterEvent("CHAT_MSG_COMBAT_FACTION_CHANGE", "FactionChange")
end

function Foo:FactionChange()
  local _, _, faction, change, direction = strfind(arg1, "Your reputation with (.+) has .+. %((%d+) reputation (.+)%")
  if faction then
    self:Msg("You have %s %d reputation with %s.", direction, change, faction)
  end
end
This would look for something like "Your reputation with Timbermaw Hold has increased. (25 reputation gained)" and print out "You have gained 25 reputation with Timbermaw Hold."
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » FuBar and events


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off