QeMistry Queue Manager

Share your scripts and packages with other Mudlet users.
User avatar
Oneymus
Posts: 321
Joined: Thu Sep 17, 2009 5:24 am

Re: QeMistry Queue Manager

Post by Oneymus »

QeM was old syntax I used, so you may have the original version. If you throw some code up in pastebin or hastebin, I can take a look at it.

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: QeMistry Queue Manager

Post by icesteruk »

Oneymus wrote:QeM was old syntax I used, so you may have the original version. If you throw some code up in pastebin or hastebin, I can take a look at it.

So, how would I add a 'cantMove()' and 'hasBal()' into this script? Ive' deleted my other QeM and cant seem to get this aspect of it working :/

User avatar
Oneymus
Posts: 321
Joined: Thu Sep 17, 2009 5:24 am

Re: QeMistry Queue Manager

Post by Oneymus »

This is my suggestion: remove your current QeM (which is old and modified), and install the new one. You can then do exactly what you want without having to modify Qemistry at all. You would use the API as it was meant to be used, which means myself and others would be better able to help you better.

As per our PM discussion, I am willing to help you with that. And, given that very little of your system currently relies on QeM, it should be a very easy transition.

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: QeMistry Queue Manager

Post by icesteruk »

I deleted my QeM and installed the one on here.. but I not got a clue how to add the cantmove() and hasBal() function :/

also how do I make it fire? as my original used my OWN variable of mayhem.queue:add ... and mayhem.Queue:act() ....

User avatar
Oneymus
Posts: 321
Joined: Thu Sep 17, 2009 5:24 am

Re: QeMistry Queue Manager

Post by Oneymus »

I just now realized, after about two years, that the usage.txt was outdated for this. Go me! The NaturalDocs documentation, however, was up to date.

Anyway!

First, any queue made in the new Qemistry is stored internally, so you don't need to worry about references. You can, however, if you'd like. To make a new queue, want to do this:
Code: [show] | [select all] lua
local function cantMove ()
  ...
end

local function hasBal ()
  ...
end

my_queue = Qemistry:Queue(
  "my_queue", -- All queues are named in Qemistry, so they can be referenced later.
  {"system.my_balance", cantMove, hasBal} -- These are your conditions, just like QeM.
                                          -- Now you can pass functions!
)
To add new actions, you can do either of these two methods:
Code: [show] | [select all] lua
Qemistry.Queues["my_queue"]:Add(...)
or, if you have a reference variable:
Code: [show] | [select all] lua
my_queue:Add(...)
To make a queue run through its actions, it's very similar:
Code: [show] | [select all] lua
Qemistry.Do("my_queue")

my_queue:Do()
With the exception of minor syntax changes (and forcing queues to be named), Qemistry functions identically to QeM. If you need more help, let me know.

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: QeMistry Queue Manager

Post by icesteruk »

Thanks, I'll put it all into a new profile to test as looking at it I dont understand it

phasma
Posts: 191
Joined: Sat Aug 03, 2013 7:00 pm
Discord: phasma#4694

Re: QeMistry Queue Manager

Post by phasma »

Oh, I was not even aware this had been updated, heh.

Just playing around with this now. I'm loading it via package.preload and everything is working great, but there's just one question I have: What would be your recommended to check for the existence of an item? In short, I am calling the do method on my prompt and obviously only want to call it when there are actually items.

Thanks again for a great piece of software.

User avatar
Oneymus
Posts: 321
Joined: Thu Sep 17, 2009 5:24 am

Re: QeMistry Queue Manager

Post by Oneymus »

You can check if there are any Actions in a queue.
Code: [show] | [select all] lua
if queue:Actions then
  ...
end
That will return nil if the Actions list is empty, otherwise it returns the table of Actions (technically, a copy of the table, so you can modify the Actions themselves, but not the original table).

phasma
Posts: 191
Joined: Sat Aug 03, 2013 7:00 pm
Discord: phasma#4694

Re: QeMistry Queue Manager

Post by phasma »

Yeah, already noticed that. I really need to read more.

Thanks, man.

Post Reply