Originally Posted by Ketho
I'm also looking for exactly this functionality~
...
Could someone please point us to a Library for this (if there exists one), or give a (Lua) snippet or addon example on how this should be done?
|
well.... im dying trying to get this to work... umm.. i have attempted 4 times, and no luck... except the 2nd time, it did work, i still have that code saved too, but... not exactly...
ok, this is a broken code, but it should give u a good idea of how it should work... this is my 4th attempt... if you can help get it working like it should i would appreciate it!
Code:
guildbot2 = CreateFrame("frame")
local queue = 0
guildbot2:RegisterEvent("CHAT_MSG_GUILD");
guildbot2:SetScript("OnEvent", function(_, event, ...) guildbot2[event](...) end);
local databaseupdate = CreateFrame("Frame", "ViewAddonMessageFrame")
local function printMsg(_, _, prefix, msg2, type, sender)
ChatFrame3:AddMessage("["..prefix.."]["..msg2.."]["..type.."]["..sender.."]")
function QueueAdd( queue, qnewname, qnewvalue ) -- adds or creates a new value
if queue == nil then -- if the queue is empty create a new one
queue = { qname = qnewname, qvalue = qnewvalue } -- add this as root
return queue -- return the new queue
else
if qnewvalue < 1 then -- if less, recursively add
return QueueAdd( queue, qnewname, qnewvalue )
else -- otherwise, add same
return QueueAdd( queue, qname, qvalue )
end
end
end
function QueueMin( queue, qname) -- returns with the smallest value
if queue == nil then -- if the queue is empty, return nil
return nil
else if queue ~= 0 then -- recursively
return QueuePeek( queue, qname )
else -- if no name is found, it will be the smallest value
return queue
end
end
function QueuePeek( queue, qname ) -- returns the next value without removing it
local min = QueueMin ( queue, qname )
return min.qvalue
end
function QueueNext( queue, name )-- returns the next value after removing it from the queue
local min = QueueMin ( queue, name )
local minValue = min.qvalue
if min.qvalue == nil then-- check to see if the minimum has children
min = nil -- if so, remove it
else -- otherwise, replace the minimum with the other value
min = min.qvalue
end
return minValue -- return the minimum value
end
end
SendAddonMessage("GBOT!Q", "QUEUE DATA:", "GUILD", "SENDER")
end
databaseupdate:SetScript("OnEvent", printMsg)
databaseupdate:RegisterEvent("CHAT_MSG_ADDON")
function guildbot2.CHAT_MSG_GUILD(msg, sender, ...)
-- if strfind(msg, string.upper("$TEST")) then
queue = queue + 1
SendAddonMessage("GBOT!Q", queue, "GUILD", "SENDER")
--print("test?channel") --debugging
-- end;
end