[php]
local ldb = LibStub("LibDataBroker-1.1"):New("AliveCount", {
text = "0/0 Alive"
icon = ""
})
local frame = CreateFrame("Frame")
local delay, interval = 0, 5
frame:SetScript("OnUpdate", function(f, e)
delay = delay + e
if delay > interval then
local dead, party, raid = 0, GetNumPartyMembers(), GetNumRaidMembers()
if raid > party then
for i = 1, raidCount do
if UnitIsDead("raid"..i) then
dead = dead + 1
end
end
ldb.text = ("%d/%d Alive"):format(dead, raid)
else
for i = 1, partyCount do
if UnitIsDead("party"..i) then
dead = dead + 1
end
if UnitIsDead("player") then
dead = dead + 1
end
end
ldb.text = ("%d/%d Alive"):format(dead, party)
end
delay = 0
end
end)
[/php]30 lines with some overhead prolly.
local ldb = LibStub("LibDataBroker-1.1"):New("AliveCount", {
text = "0/0 Alive"
icon = ""
})
local frame = CreateFrame("Frame")
local delay, interval = 0, 5
frame:SetScript("OnUpdate", function(f, e)
delay = delay + e
if delay > interval then
local dead, party, raid = 0, GetNumPartyMembers(), GetNumRaidMembers()
if raid > party then
for i = 1, raidCount do
if UnitIsDead("raid"..i) then
dead = dead + 1
end
end
ldb.text = ("%d/%d Alive"):format(dead, raid)
else
for i = 1, partyCount do
if UnitIsDead("party"..i) then
dead = dead + 1
end
if UnitIsDead("player") then
dead = dead + 1
end
end
ldb.text = ("%d/%d Alive"):format(dead, party)
end
delay = 0
end
end)
I have attached the full addon, and hopefully it works; I have not tested it. You can get fancier, but this is KISS.
Note 1 : This should work but you will require the Broker2FuBar addon as well, if you want to use the plugin with FuBar (as its name suggests, despite the fact that Orion wrote an LDB plugin :P)
Note 2: Afaik, optdeping LibDataBroker-1.1 is a big no-no. It should work fine but don't let Tekkub catch you :p
Note 3: The way the plugin is set up, it will perform the check every 5 seconds. You may modify the 'interval' variable value if you want to.
Note3 you might want to check LDB for the correct function call to make a new feed.
Note4 you can't optDep LDB as there is no stand alone version that you can download, tek has seen to that.
Orion and Tris - I don't want to get any one in trouble or mad here. Can we try and make this an official addon from someone? I would think other people might like this. It's a nice quick check of how many are dead in a raid without having to have a crap load of bars on your screen.
I would think people would want that, no?
Edit::: I tried it, shows up at the char selection screen but not in game. Installed Broker2FuBaras Tris suggested, A LOT of crap came on the bar but not this.
Orion and Tris - I don't want to get any one in trouble or mad here. Can we try and make this an official addon from someone? I would think other people might like this. It's a nice quick check of how many are dead in a raid without having to have a crap load of bars on your screen.
I would think people would want that, no?
Edit::: I tried it, shows up at the char selection screen but not in game. Installed Broker2FuBaras Tris suggested, A LOT of crap came on the bar but not this.
There are a few typos as Orion noted. Try this :
local ldb = LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("AliveCount", {type = "data source", label = "Alive Report", text = "0/0 Alive", icon = "Interface\\PVPFrame\\\PVP-ArenaPoints-Icon"})
local frame = CreateFrame("Frame")
local delay, interval = 0, 5
frame:SetScript("OnUpdate", function(f, e)
delay = delay + e
if delay > interval then
local dead, party, raid = 0, GetNumPartyMembers(), GetNumRaidMembers()
if raid > party then
for i = 1, raidCount do
if UnitIsDead("raid"..i) then
dead = dead + 1
end
end
ldb.text = ("%d/%d Alive"):format(dead, raid)
else
for i = 1, partyCount do
if UnitIsDead("party"..i) then
dead = dead + 1
end
if UnitIsDead("player") then
dead = dead + 1
end
end
ldb.text = ("%d/%d Alive"):format(dead, party)
end
delay = 0
end
end)
And yeah this is a "fast" solution that can be surely improved.
local ldb = LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("AliveCount", {type = "data source", text = "0/0 Alive", icon = "Interface\\PVPFrame\\PVP-ArenaPoints-Icon"})
local frame = CreateFrame("Frame")
local delay, interval = 0, .5
frame:SetScript("OnUpdate", function(f, e)
delay = delay + e
if delay > interval then
local dead, partyCount, raidCount = 0, GetNumPartyMembers(), GetNumRaidMembers()
if partyCount == 0 and raidCount == 0 then
ldb.text = "Not In Party/Raid"
elseif raidCount > partyCount then
for i = 1, 40 do
if UnitIsDeadOrGhost("raid"..i) then
dead = dead + 1
end
end
ldb.text = ("%d/%d Alive"):format(dead, raidCount)
else
for i = 1, partyCount do
if UnitIsDeadOrGhost("party"..i) then
dead = dead + 1
end
if UnitIsDeadOrGhost("player") then
dead = dead + 1
end
end
ldb.text = ("%d/%d Alive"):format(dead, partyCount)
end
delay = 0
end
end)
Try this, i went ahead and debuged it. Kinda glitchie in a battleground, but should work fine in a raid.. Unless UnitIsDead has f'ed up requirements to be considered "dead".
Edit: UnitIsDeadOrGhost is the better API to use.
However you might need to go into broker2fubar and configure it to be on a bar instead of around the minimap (try /b2f )
So you have it working? Am I missing something then? I just change the code to that, and I don't see it still Is there another addon i'll see other then broker?
Oh man, why do I get myself involved into these requests :p
Anyway the problem is, the actual lua file was never referenced properly in the .toc (FuBar_AliveFu was missing the .lua suffix :p). Other than that, the dataobject name shouldn't really matter. The addon worked but was using CPU needlessly when ungrouped and it was actually reporting the number of dead people, so I went ahead and made some minor adjustments :p
FuBar_AliveFu.lua
local ldb = LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("FuBar_AliveFu", {type = "data source", label = "Death Report", text = "Ungrouped", icon = "Interface\\PVPFrame\\\PVP-ArenaPoints-Icon"})
local frame = CreateFrame("Frame")
frame:RegisterEvent("RAID_ROSTER_UPDATE")
frame:RegisterEvent("PARTY_MEMBERS_CHANGED")
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
frame:SetScript("OnEvent", function(_, event, ...)
frame[event](frame, ...)
end)
local delay, interval = 0, 5
local function CheckForDead()
frame:SetScript("OnUpdate", function(f, e)
delay = delay + e
if delay > interval then
local dead, party, raid = 0, GetNumPartyMembers(), GetNumRaidMembers()
if raid > party then
for i = 1, raid do
if UnitIsDead("raid"..i) then
dead = dead + 1
end
end
ldb.text = ("%d/%d Dead"):format(dead, raid)
else
for i = 1, party do
if UnitIsDead("party"..i) then
dead = dead + 1
end
if UnitIsDead("player") then
dead = dead + 1
end
end
ldb.text = ("%d/%d Dead"):format(dead, party + 1) -- since party doesn't count the player
end
delay = 0
end
end)
end
function frame:Update()
if UnitExists("party1") or UnitInRaid("player") then
CheckForDead()
else
frame:SetScript("OnUpdate", nil)
ldb.text = "Ungrouped"
end
end
function frame:RAID_ROSTER_UPDATE()
self:Update()
end
function frame:PARTY_MEMBERS_CHANGED()
self:Update()
end
function frame:PLAYER_ENTERING_WORLD()
self:Update()
end
Just a quick view of how many are dead during a raid.
This can't be hard to make.
Thanks!!!
local ldb = LibStub("LibDataBroker-1.1"):New("AliveCount", {
text = "0/0 Alive"
icon = ""
})
local frame = CreateFrame("Frame")
local delay, interval = 0, 5
frame:SetScript("OnUpdate", function(f, e)
delay = delay + e
if delay > interval then
local dead, party, raid = 0, GetNumPartyMembers(), GetNumRaidMembers()
if raid > party then
for i = 1, raidCount do
if UnitIsDead("raid"..i) then
dead = dead + 1
end
end
ldb.text = ("%d/%d Alive"):format(dead, raid)
else
for i = 1, partyCount do
if UnitIsDead("party"..i) then
dead = dead + 1
end
if UnitIsDead("player") then
dead = dead + 1
end
end
ldb.text = ("%d/%d Alive"):format(dead, party)
end
delay = 0
end
end)
[/php]30 lines with some overhead prolly.
Thank you by the way.
And for the FuBar_AliveFu.lua you want:
I have attached the full addon, and hopefully it works; I have not tested it. You can get fancier, but this is KISS.
Note 2: Afaik, optdeping LibDataBroker-1.1 is a big no-no. It should work fine but don't let Tekkub catch you :p
Note 3: The way the plugin is set up, it will perform the check every 5 seconds. You may modify the 'interval' variable value if you want to.
Note4 you can't optDep LDB as there is no stand alone version that you can download, tek has seen to that.
Orion and Tris - I don't want to get any one in trouble or mad here. Can we try and make this an official addon from someone? I would think other people might like this. It's a nice quick check of how many are dead in a raid without having to have a crap load of bars on your screen.
I would think people would want that, no?
Edit::: I tried it, shows up at the char selection screen but not in game. Installed Broker2FuBaras Tris suggested, A LOT of crap came on the bar but not this.
There are a few typos as Orion noted. Try this :
And yeah this is a "fast" solution that can be surely improved.
And shouldn't it be
or something like that? Note the bolded text.
Hey thanks again for your help guys!
Edit: UnitIsDeadOrGhost is the better API to use.
However you might need to go into broker2fubar and configure it to be on a bar instead of around the minimap (try /b2f )
Edit: They are a little small might not be helpful LOL
Anyway the problem is, the actual lua file was never referenced properly in the .toc (FuBar_AliveFu was missing the .lua suffix :p). Other than that, the dataobject name shouldn't really matter. The addon worked but was using CPU needlessly when ungrouped and it was actually reporting the number of dead people, so I went ahead and made some minor adjustments :p
I haven't tested it in a raid, only in a party and it seemed to work, although it may suffer from a few hiccups here and there I suppose.
Edit: UnitIsDeadOrGhost is indeed the better API to use.
I copied both your code's and replaced what I had.