Thread Tools Display Modes
05-26-11, 11:54 PM   #1
Myke916
A Deviate Faerie Dragon
 
Myke916's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 18
Need Help Building a Queue

ive been trying to build a queue for my addon, no luck...

supposively the programming work that i have done so far, is like talking to a mirror.... the code is supposed to be the same for each addon, but two players are supposed to run it, the script doesnt talk to eachother it talks to itself... weird... but! it does work 30%

What it is supposed to do, is this:

you get 10 people running the addon, 1 person takes lead, and shuts down all the other 9... but, not completely... just addon:UnregisterEvent("guild_chat_msg") and while that one event is dissabled, the addon's script scans for the lead users online status(on the addon channel), so when they log off... any one of the 9 can assume lead....

ive described it in 5-6 lines.. cant write it in 20 lines, in fact i think last time was 80 lines...

ive written this code 3 times, and failed 3 times.. seems very complicated...

could use a little help...

Last edited by Myke916 : 05-27-11 at 04:05 PM. Reason: removed souce, scan down for 4th attempt
  Reply With Quote
05-27-11, 12:16 AM   #2
Moxie
A Cobalt Mageweaver
 
Moxie's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 206
Didn't you post this on Wowace and mentioned you're testing it on a private server? I could have read wrong, but the thread over there was closed.

Are you testing it on live now?
__________________
"Someday we'll look back on this, laugh nervously and quickly change the subject."

"The truth is like sunlight: people used to think it was good for you."
  Reply With Quote
05-27-11, 12:32 AM   #3
Myke916
A Deviate Faerie Dragon
 
Myke916's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 18
Originally Posted by Decabah View Post
Didn't you post this on Wowace and mentioned you're testing it on a private server? I could have read wrong, but the thread over there was closed.

Are you testing it on live now?
NO... that was all a HUGE MISUNDERSTANDING.... i was talking about wowbench... a testbench software..... we were talking about style and coding programs, and that stupid word came up... im not even going to say it... in fact i allready forgot....

next question...

Last edited by Myke916 : 05-27-11 at 12:35 AM. Reason: not to be rude... or anything... id rather not remember and watch it happen again!! LMAO..
  Reply With Quote
05-27-11, 12:34 AM   #4
Moxie
A Cobalt Mageweaver
 
Moxie's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 206
Jinkies.

Just asking.
__________________
"Someday we'll look back on this, laugh nervously and quickly change the subject."

"The truth is like sunlight: people used to think it was good for you."
  Reply With Quote
05-27-11, 12:43 AM   #5
Myke916
A Deviate Faerie Dragon
 
Myke916's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 18
lol...

i kno... but ummmm... i really do need help with this....

any suggestions?

my next help question is gonna be about transmitting tables thru the addon channel.... im sure i could figure that out... but its gonna be crazy...


what would really help my current situation, How can i give an addon a CONCREET name that is a variable decided by both addons... and it cannot be changed!? until relog or reloadUI ???
  Reply With Quote
05-27-11, 01:54 AM   #6
Myke916
A Deviate Faerie Dragon
 
Myke916's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 18
ok... finnallly made some progress.... just need'd to distinguish the characteristic of the queue a little better... as in:

add to queue

move forward in queue

reset queue

then---> queue function --> function of queue...

damn...!
  Reply With Quote
05-27-11, 06:09 AM   #7
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
A queue is also an established data structure in programming, so perhaps this Wikipedia article can be helpful.

http://en.wikipedia.org/wiki/Queue_%28data_structure%29
__________________
Oh, the simulated horror!
  Reply With Quote
05-27-11, 12:47 PM   #8
Myke916
A Deviate Faerie Dragon
 
Myke916's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 18
Originally Posted by Ailae View Post
A queue is also an established data structure in programming, so perhaps this Wikipedia article can be helpful.

http://en.wikipedia.org/wiki/Queue_%28data_structure%29
informational...

kinda like this one, its kinda handy...
http://en.wikipedia.org/wiki/Priority_queue

thus i can add a priority to the queue, such as, GuildMaster=0, Officer=1, Verteran=2, Member=3 ...etc

higher priority = faster response time in processing.. thus lower number being higher in this case..
  Reply With Quote
05-27-11, 03:02 PM   #9
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by Myke916 View Post
NO... that was all a HUGE MISUNDERSTANDING.... i was talking about wowbench... a testbench software..... we were talking about style and coding programs, and that stupid word came up... im not even going to say it... in fact i allready forgot....

next question...
Technically, you're referring to two different threads. The wowbench thread was not closed. The one where you said you were running your own private server to test your addon was closed. And I said that I would close threads here having to do with private servers (even coding on private servers).

As you yourself haven't mentioned it yet, I'll give you the benefit of the doubt that you wised up and are coding/testing the legitimate way - the way that the rest of us do. But the moment that private servers get brought up, or if it is revealed that you're still using one, this thread will need to be closed as well.

In the meantime, I have moved your thread to the correct forum.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
05-27-11, 03:18 PM   #10
Myke916
A Deviate Faerie Dragon
 
Myke916's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 18
ok... well wiki has an example

here is the wiki example: javascript not lua

Code:
function Queue(){
    this.data = [];
    this.head = 0;
    this.size = 0;
 
    this.size = function(){
        return this.size < 0 ? 0 : this.size;
    }
 
    this.queue = function(obj){
        this.data[this.size++] = obj;
    }
 
    this.dequeue = function(){
        //Amortices the shrink frequency of the queue
        if(--this.size < this.data.length*0.9){
            this.data = this.data.slice(this.head);
            this.head = 0;
        }
        return this.data[this.head++];
    }
 
    this.peek = function(){
        return this.data[this.head];
    }
 
    this.isEmpety = function(){
        return this.size <= 0;
    }
}
so how do i format this in Lua? the code is a little different...

seccond.. well... if i had a lua example of this code i could figure out what is next, i would assume sharing the queue on the addon channel to process information...

i believe that would be in the dequeue or isempty function...

Basically this is supposed to tell me when a user is online, and if they are in the queue... if they are not in the queue AddQueue() then loop the normal function of scanning for users online with the addon running... if the user goes offline, remove them from the queue...

but like i said this is java, i have made 3 attempts to build this in lua, and failed the first time, the seccond time was 30% working but had a few minor errors... mostly script wise....

BUT the main importance is that this queue needs to be in constant communications with others using this addon, so its not a local script... its shared between users... and thus, it cannot read local variables must read shared variables... (where i got lost on the 2nd attempt..)

thus comes the part where the active queue user ... say for example:

Client1 = 0
Client3 = 1
Client2 = 2
Client4 = 3

Client 0 send the kill command addon_name:UnregisterEvent("THISEVENT") to client 3,2,4 - but! Client 3,2,4 continue to check the queue if client1 is online like this:

Code:
if UnitIsConnected(Client1) == 1 then
--do nothing - continue waiting for offline
elseif UnitIsConnected(Client1) == 0 then
addon_name:RegisterEvent("THISEVENT")
but it has to be brodcast on the addon channel so we use this:
Code:
    SendAddonMessage("ADDONNAME", QUEUESTATUS, "GUILD", "SENDER")
of coarse the event has to be properly registered, and it is said specifically that the "SENDER" can be omited and is only used when communicating on the WHISPER channel, but i found that it can be helpful in identifying other users who send data on a larger number basis on the guild channel... (re-inventing the wheel?!)

IVE WRITTEN THIS CODE 3 TIMES, i need some help please.. i fail'd... i wasted 3 days... and countless hours yelling at my laptop... and it kept yelling back...
  Reply With Quote
05-27-11, 03:20 PM   #11
Myke916
A Deviate Faerie Dragon
 
Myke916's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 18
Originally Posted by Seerah View Post
And I said that I would close threads here having to do with private servers (even coding on private servers).
i wont even say that "p" word anymore, thats how serious i am...

were running your own private server to test your addon was closed
and i specifically said, i am not running a private server (i hate them also, wow rules..), it was a missunderstanding about using the software to testbench... before going public... i do not have a server in my basement if that is what you are saying... it was a way of saying using emulation to testbench... and then i even asked the moderator that froze my thread if i could decompile that software, and build a testbench program that would be safe.. IE: not connect to the networks and send and recieve client server code, just run locally on the client and stay on the client for BENCHTESTING... and add'd to say, that it probly would still be against blizz's eula. it was never about running a server... and if you go back to that thread and read it you will specifically see the words "DOUBLE EDGED SWORD" .... and then the post gets frozen cause someone jumped to the conclusion that i was running a server... i never said anything like that!!

Now this is the 5th time someone has said i am running a server, WHICH I AM NOT! can we PLEASE stop talking about this now that i have try'd to clear things up... im trying to be nice so i dont get banned...

i am truely an honest person that is trying to produce an idea that no-one has seen before... im contributing to the team, someone may find my software valuable like i did... IN fact, i have had requests for my addon in other languages allready... and 50 downloads a day is pretty good if u ask me.. i dont have the time or resources to run a server anyways... the cost of ocx beyond my budget.. and i wouldnt pay for hosting...

(i hate discussing this... cause im different from most people i know, it takes a while for people to understand me, and when they do see my point... if they choose to understand it... they then realize that there is many ways to get a single job done... kinda like how a dictionary has one word that means 100 different things... i dont have to explain this but i will share.. i was kinda autistic growing up, so i kinda live in a bubble world that is only familiar to me, alien to others.... i do things differently, maybe not the way they should be done, but it gets done, and its something that everyone can learn from, believe it or not! ok, yes i do need help with puctuation, but that just emotion in word form...)

Last edited by Myke916 : 05-27-11 at 03:55 PM.
  Reply With Quote
05-27-11, 07:46 PM   #12
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
I work with and teach autistic and asperger kids every day - I know about the bubble you speak of. We'll discontinue the above topic.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
05-27-11, 08:50 PM   #13
Myke916
A Deviate Faerie Dragon
 
Myke916's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 18
tyvm... hope u dont mean to discontinue the fact that i still need a queue... joking...
__________________
author of:
-=GuildBot=-
  Reply With Quote
05-27-11, 11:16 PM   #14
Crissa
A Flamescale Wyrmkin
 
Crissa's Avatar
Join Date: May 2008
Posts: 136
No wonder you have so much patience, Seerah! ...And that you seem to be able to read some of these posts.

And Mike, been there, with the bubble.

This is just a sympathy post. I haven't anything useful to add.

-Crissa
  Reply With Quote
05-27-11, 11:31 PM   #15
Myke916
A Deviate Faerie Dragon
 
Myke916's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 18
Originally Posted by Crissa View Post
1)No wonder you have so much patience, Seerah! ...And that you seem to be able to read some of these posts.

2)And Mike, been there, with the bubble.
1)lol... yea sometimes it seems im the only one who understands me, and now if seerah does, that makes two of us that know that i might be incompetent but that guy that sits down on the corner begging for change is just a plain IDIOT! i got a little more self respect than that...

2)oh yea... the whole thing i just said about being incompetent... damn, if i am stupid it makes me wonder about other people sometimes... I know im not stupid.. im just special, and people hate me cause i have a stupid thing called a mental dissorder... i personally call it my special gift... i know im not a retard, you can call me a retard, it doesnt offend me anymore... because its best said like this "maybe some people would like to know what its like not to have an arm or leg for the better part of your damn life... but i manage to appreciate what i am.."

life give u lemons... u make lemonade...
__________________
author of:
-=GuildBot=-

Last edited by Myke916 : 05-27-11 at 11:33 PM.
  Reply With Quote
05-27-11, 11:54 PM   #16
Myke916
A Deviate Faerie Dragon
 
Myke916's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 18
Originally Posted by Seerah View Post
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh
ahhh the tao of pooh.... my psychologist made me read that... kinda like saying... some people think ur crazy if you have a psychologist, others will say your crazy if you dont!

oh yea... last comment about this... not like my medical record anyones business... it is actually federally protected... i hate having to explain myself sometimes...
__________________
author of:
-=GuildBot=-

Last edited by Myke916 : 05-28-11 at 12:13 AM.
  Reply With Quote
05-28-11, 12:35 PM   #17
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Originally Posted by Myke916 View Post
you get 10 people running the addon, 1 person takes lead, and shuts down all the other 9... but, not completely... just addon:UnregisterEvent("guild_chat_msg") and while that one event is dissabled, the addon's script scans for the lead users online status(on the addon channel), so when they log off... any one of the 9 can assume lead....
I'm also looking for exactly this functionality~

I've been trying to follow this thread and the rather technical wiki links, but can still barely understand what it's on about "Queue (data structure)" and "Priority queues"

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?
  Reply With Quote
05-28-11, 01:03 PM   #18
Myke916
A Deviate Faerie Dragon
 
Myke916's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 18
Originally Posted by Ketho View Post
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
__________________
author of:
-=GuildBot=-
  Reply With Quote
05-28-11, 02:59 PM   #19
lilsparky
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Oct 2007
Posts: 117
as a generic system, i think a guild-wide information sharing system would be pretty useful. i've done a bit of dabbling for a specific addon of mine, but debugging code that requires multiple accounts is difficult if you don't actually have multiple accounts.

my approach was to employ a master/client kind of model -- kind of what you are describing... tho i don't understand your use of the word "queue" in this regard.

the easy part is writing the client code and the master code. the clients all just listen for messages and react to them. occasionally, they would report new information to the master. the master would listen for information from the clients and then distribute that information as needed -- either as a broadcast or as individual messages depending on what makes the most sense.

the hard part is electing the master and changing states between master and client....

guess i don't have much to add beyond the interest in seeing a generic guild-wide data sharing system implemented somewhere...

edit: in terms of implementing a queue in lua, i think you're overcomplicating things. use a table.

to add to the end:
myQueue[#myQueue+1] = newEntry

to pull from the head:
firstEntry = table.remove(myQueue,1)

that's really all you need to do.

if you want to check the next entry:
nextEntry = myQueue[1]

Last edited by lilsparky : 05-28-11 at 03:04 PM.
  Reply With Quote
05-28-11, 03:06 PM   #20
Myke916
A Deviate Faerie Dragon
 
Myke916's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 18
Originally Posted by lilsparky View Post
1)my approach was to employ a master/client kind of model -- kind of what you are describing... tho i don't understand your use of the word "queue" in this regard.
..
2)the hard part is electing the master and changing states between master and client....
1) The Queue (just like waiting in line... by definition) is used to Select The master, who ever has lead and remains online, stays at the top of the queue, when logged off, next person in line takes master.. its just a way of forming a line so they dont have to randomly decide or choose by roll... thus, there is not master and client model... its all wrapped into 1 code... it is decided by number of users running the addon itself...

2) i think i explained that above, but i even go a step further in the details of the planning to give Guildmaster priority over Officers and officers priority over veterans and members... etc.. and so on...

ok the next step after i build this queue is to share the data... im not there yet, must get this operational... but id be interesting in hearing about the data sharing, cause i know its gonna be difficult also...

edit:

true true... with the overkill.. but... i guess doing the priority things is a little more complicated...

btw.. can u send tables over the addonchannel? never tried.. just wondering...

oh yea... another thing... Ive tryed this before... and that code might work for the table, BUT... the data has to be shared... by numerous users... so the addon isnt talking to itself and making itself Priority in the queue... that was the problem i was having on the 2nd re-write... being able to have a shared queue and not talk to itself...
__________________
author of:
-=GuildBot=-

Last edited by Myke916 : 05-28-11 at 04:42 PM.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Need Help Building a Queue

Thread Tools
Display Modes

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