kaybe, thanks. Are you using this library in an addon you're working on? Because right now I don't really know if any addon besides Squishy is using RosterLib.
Hopefully keeping you motivated! I'll be using RosterLib after 1.12 when AceComms replaces my custom lib that contains my current mixture of raid and comm methods.
I think RosterLib is going to be very helpful for SnaFu. I find, though, that I am too unsavvy to figure out a lot of the stuff on my own. I look forward to the API page on the Wiki, replete with examples for the faint of heart (such as myself.)
function myAddon:UpdateFood(name)
local u = self.rosterlib:GetUnitObjectFromName(n)
if not u then return end
if u.class = "WARRIOR" then
u.food = "meat"
else
u.food = "vegetables"
end
end
Does that mean the object returned by GetUnitObjectFromName() is a new table created which is only available to the caller ?
For exaple, if Rophy is a warrior, and addon_A do this:
local u = self.rosterlib:GetUnitObjectFromName("Rophy")
if u.class == "WARRIOR" then -- No, I want to be a mage!
u.class = "MAGE"
end
after that, in addon_B
local u = self.rosterlib:GetUnitObjectFromName("Rophy")
print(u.class)
What will be the result of the print() ? "WARRIOR" or "MAGE" ?
In the implementation of GetUnitObjectFromName() I see RosterLib is simply returning an existing object, not creating an object, which means the result will probably be "MAGE", which to addon_B obviously is an incorrect result?
rophy, any change you make to the RosterLib roster is global. So don't change the class, name or anything else please. It's no problem if you want to add stuff (like u.myAddon.something = true), but other than that please don't touch the units. I don't want to make them read only ;)
i don't think we should have to code the library against malicious coders ;-) we just need to educate them not to modify any of the objects except to add their own data beneath their addon 'signature' or something like that :)
An other thing, is it possible to add an event or something like that which fires when I am
joining or leaving a raid.
This would be nice, so I dont have to check this always, simply wait for the event.
What about the subgroup thing I suggested? Will you add something like that?
a suggestion: To get informations about the raidgroups, who is in which group and/or how many people are in the several groups.
Just trying to understand why you're asking for it - why don't you simply loop through the roster whenever the RosterChanged event is triggered? Thats like 8 lines of code.
theondry:
I think RosterLib is going to be very helpful for SnaFu. I find, though, that I am too unsavvy to figure out a lot of the stuff on my own. I look forward to the API page on the Wiki, replete with examples for the faint of heart (such as myself.)
Yeah, sorry, I still didn't create the wiki API page. Is there anything I can help you with?
kaybe:
An other thing, is it possible to add an event or something like that which fires when I am
joining or leaving a raid.
Same as above - something like:
local c=0; for u in rosterlib.roster do c=c+1 end; if c==0 then ...(LEFT ROSTER) ... else ... end
is all you really need.
So that it more closely mimics other libraries, ie if you decide to make a RosterLib-3.0 at some point it wouldn't be a completely different folder at the root level.
Yeah, sorry, I still didn't create the wiki API page. Is there anything I can help you with?
I didn't want to clutter this, but...
local roster = AceLibrary("RosterLib-2.0")
function SnaFu:OnEnable()
self:RegisterEvent("RosterLib_RosterChanged")
self:RegisterEvent("RosterLib_PendingRefresh")
roster:Enable()
end
tells me that there is no such event. I've commented it out and it went away.
the error message vomited forth by bugsack is
[14:47-149]: FuBar_SnaFu\SnaFu.lua:40: AceEvent-2.0: Cannot register event "RosterLib_RosterChanged" to method "RosterLib_RosterChanged", it does not exist
<evaluated>: in function `error'
AceLibrary\AceLibrary.lua:106: in function `error'
AceEvent\AceEvent-2.0.lua:91: in function `RegisterEvent'
FuBar_SnaFu\SnaFu.lua:40: in function `OnEnable'
AceAddon\AceAddon-2.0.lua:299: in function `obj_method'
AceEvent\AceEvent-2.0.lua:213: in function `TriggerEvent'
AceEvent\AceEvent-2.0.lua:919: in function <...ce\AddOns\AuldLangSyne\lib\AceEvent\AceEvent-2.0.lua:911>
What I want to do in my FuBar plugin (I'm not sure if the fubarness matters, but okay) is to grab a list of everyone in the current grouping, whether that's solo, raid, whatever.
I want to go through everyone on that list and check for a buff (specifically a soulstone).
If the person has that buff, I want to make an N-by-2 matrix that looks roughly like
Then I can take that matrix and do nifty things with it. Granted, I don't know how to use matricies in this thing but that's okay.
Later on, I'll want to remove people from the listing after the buff fades and so on, but that's for later (I said that, didn't I?)
*IF* I were only dealing with raids, I think there are wowapi commands that let me do this, but it looks like RosterLib should let me do this with an arbitrary grouping of any kind. (which is good, because I'm lazy, and dont' like my current method of checking if there's a party, then a raid, then myself... that leads to stupid logic errors that don't exist.)
theondry, first I assume the problem is that you didn't create functions to line the events to, so you'll have to provide at least a function SnaFu:RosterLib_RosterChanged() . At least thats what the error message is trying to tell you (I think).
As for saving and querying soulstone data, you could do something like:
local soulstone = {}
local rosterlib = AceLibrary("RosterLib-2.0")
function SnaFu:OnEnable()
self:RegisterEvent("RosterLib_RosterChanged")
rosterlib:Enable()
end
function SnaFu:RosterLib_RosterChanged()
for u,name in rosterlib:IterateRoster() do
soulstone[name] = soulstone[name] or 0
end
end
function SnaFu:NewSoulstone(name)
soulstone[name] = GetTime()
end
function SnaFu:GetTimeOnSoulstone(name)
local casted = GetTime() - soulstone[name]
if casted < 30 then return casted else return nil end
end
This will create a local table with all units RosterLib provides. When the roster changes it will create new table entries for all units, and when someone is buffed, then you call NewSoulStone(name). To query if someone currently has a soulstone, you can use GetTimeOnSoulstone(name) - aka you can loop through the roster and query that data.
The code above is not optimized and very simple. In fact you wouldn't even need RosterLib, but if you e.g. want to remove people from your table when they leave the raid, only watch specific classes or groups etc., then using RosterLib is quite a help.
theondry, first I assume the problem is that you didn't create functions to line the events to, so you'll have to provide at least a function SnaFu:RosterLib_RosterChanged() . At least thats what the error message is trying to tell you (I think).
=p
You don't say anything about needing to make functions for that in your cover page on the wiki. (I will again reiterate another time that I don't really know what I'm doing here... I just throw stuff together and prey.)
The thing that makes me want to use RosterLib is that, from what I understand, it creates an abstracted list of people, without the need to know how those people are arranged. Anyway, I'll play with this and see what I get. Thanks.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I only want to say that I like your lib. Great work.
Idling at less than 1kps, usually around .5 - unless I'm in a city, of course.
Can you fix that??? :D
(kidding...)
To get informations about the raidgroups, who is in which group and/or how many people are in the several groups.
Thanks a bunch.
- HealthMon (Josh_Borke)
- SnaFu (theondry)
- HealHub (eternally777)
did I miss anyone? Worf, ag, kaybe, OttoDeFe?
Does that mean the object returned by GetUnitObjectFromName() is a new table created which is only available to the caller ?
For exaple, if Rophy is a warrior, and addon_A do this:
after that, in addon_B
What will be the result of the print() ? "WARRIOR" or "MAGE" ?
In the implementation of GetUnitObjectFromName() I see RosterLib is simply returning an existing object, not creating an object, which means the result will probably be "MAGE", which to addon_B obviously is an incorrect result?
for example if two addons are both adding and using a 'food' field to the table, then there are problems.
u.food
but
u.myAddon.food
Not public at the moment.
An other thing, is it possible to add an event or something like that which fires when I am
joining or leaving a raid.
This would be nice, so I dont have to check this always, simply wait for the event.
What about the subgroup thing I suggested? Will you add something like that?
Just trying to understand why you're asking for it - why don't you simply loop through the roster whenever the RosterChanged event is triggered? Thats like 8 lines of code.
theondry:
Yeah, sorry, I still didn't create the wiki API page. Is there anything I can help you with?
kaybe:
Same as above - something like:
local c=0; for u in rosterlib.roster do c=c+1 end; if c==0 then ...(LEFT ROSTER) ... else ... end
is all you really need.
http://svn.wowace.com/root/trunk/RosterLib/Roster-2.0 or
http://svn.wowace.com/root/trunk/RosterLib/RosterLib-2.0
So that it more closely mimics other libraries, ie if you decide to make a RosterLib-3.0 at some point it wouldn't be a completely different folder at the root level.
I didn't want to clutter this, but...
tells me that there is no such event. I've commented it out and it went away.
the error message vomited forth by bugsack is
What I want to do in my FuBar plugin (I'm not sure if the fubarness matters, but okay) is to grab a list of everyone in the current grouping, whether that's solo, raid, whatever.
I want to go through everyone on that list and check for a buff (specifically a soulstone).
If the person has that buff, I want to make an N-by-2 matrix that looks roughly like
Then I can take that matrix and do nifty things with it. Granted, I don't know how to use matricies in this thing but that's okay.
Later on, I'll want to remove people from the listing after the buff fades and so on, but that's for later (I said that, didn't I?)
*IF* I were only dealing with raids, I think there are wowapi commands that let me do this, but it looks like RosterLib should let me do this with an arbitrary grouping of any kind. (which is good, because I'm lazy, and dont' like my current method of checking if there's a party, then a raid, then myself... that leads to stupid logic errors that don't exist.)
As for saving and querying soulstone data, you could do something like:
This will create a local table with all units RosterLib provides. When the roster changes it will create new table entries for all units, and when someone is buffed, then you call NewSoulStone(name). To query if someone currently has a soulstone, you can use GetTimeOnSoulstone(name) - aka you can loop through the roster and query that data.
The code above is not optimized and very simple. In fact you wouldn't even need RosterLib, but if you e.g. want to remove people from your table when they leave the raid, only watch specific classes or groups etc., then using RosterLib is quite a help.
=p
You don't say anything about needing to make functions for that in your cover page on the wiki. (I will again reiterate another time that I don't really know what I'm doing here... I just throw stuff together and prey.)
The thing that makes me want to use RosterLib is that, from what I understand, it creates an abstracted list of people, without the need to know how those people are arranged. Anyway, I'll play with this and see what I get. Thanks.