[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Jscript
. . -> [Subject]  Queue's And Functions
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Queue's And Functions

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Nexes   (65 posts)  [Biography] bio
Date Sat 16 Apr 2005 05:43 PM (UTC)

Amended on Sat 16 Apr 2005 05:46 PM (UTC) by Nexes

Message
My first question, can I call a function in a script with a string of its name?
Ie. call "aFunction()" will call aFunction()

Say I want a first in first out queue, or last in last out if you prefer. Is there an easy way of taking something out from the middle of the queue efficiently? Or will I have to just take out the middle and move all the array elements down as needed?

Is there a function that will sort an array of strings? If not is there a function that will compare them?
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #1 on Sat 16 Apr 2005 06:14 PM (UTC)
Message
Eval will execute an arbitrary string.

As for arrays, there are a few functions, I suggest you download the JScript help file (it's technically the 'windows scripting host' help file, it includes JScript and VBScript), you can find it on the same page that you download more script engines from (check the top of the mushclient forum for a link to "script functions" and then 'script engines you can download').

You can use GetQueue to return the WHOLE thing to an array, and then you can get an arbitrary item out of it (and then discard queue and requeue the rest of the array). Check the script function documentation for specifics and examples (the mushclient one, list of inbuilt script functions).

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Nexes   (65 posts)  [Biography] bio
Date Reply #2 on Sun 17 Apr 2005 12:12 AM (UTC)

Amended on Sun 17 Apr 2005 12:13 AM (UTC) by Nexes

Message
The mushclient functions GetQueue, Queue, DoCommand, ect, are all based on a "speed walking" queue. This doesn't suit my purposes as I need a more general purpose queue that I can add to and remove elements from when I need to and not at a certain set time.

Thanks for eval though and I also found a sort method that sorts by ASCII order.
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #3 on Sun 17 Apr 2005 07:10 AM (UTC)
Message
You don't have to use the queue for speedwalking (I've never done so, I just command stack for speedwalking), it was just designed that way.
Erm, nevermind. I thought you could stop the queue from going.

Nick, is there any way we can get the queue to stop being proccessed? Like setting the delay to a negative number or something? That way we can use it as a stack, and not just for speedwalking.

I suppose you'll just have to use an array for the time being.
And, DoCommand isn't for speedwalking, but Im sure that just got in there on accident.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] bio
Date Reply #4 on Sun 17 Apr 2005 10:14 AM (UTC)
Message
You can just save the contents of the queue, save the delay value, set the delay to something like 1 second, load the speedwalking queue with arbitrary values, perform any operations you want on it, and then discard the queue and restore the original delay (as well as original contents), all in one go. That way nothing will ever be sent to the world since the script will block until it finished executing your statements, and when you exit from it the queue will be in its virgin state as if nothing was done to it.
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #5 on Sun 17 Apr 2005 05:54 PM (UTC)
Message
Doing that basically defeats the benefits of using mushclients queue.

Instead of reloading it and then saving it off again (and setting delay and such) you might as well just code your own pop/push functions for the array that you already have to store (and manipulate manually anyway if you're looking to get something out of the middle).

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Nexes   (65 posts)  [Biography] bio
Date Reply #6 on Wed 18 May 2005 07:59 AM (UTC)
Message
Ugh, time to look at what kind of class suppoert javascript has (guesses its minimal). These scripting languages are so different from C++ or Java...C++ it would be easy with th STL, and Java the ArrayList would work. *grumble* Stupid arrays, stupid Queues....

Btw, I know its a looong time since I responded.
[Go to top] top

Posted by Larkin   (278 posts)  [Biography] bio
Date Reply #7 on Thu 19 May 2005 07:59 PM (UTC)
Message
I implemented my own "action" queues for various types of balance, and it works amazingly well. Since I implemented my own queues, I have full control over pausing them, clearing them, or triggering them off of various affliction states or balances. Running them all at once is a form of parallel processing, and I'm impressed with MUSHclient's speed at executing things like this so far.
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


7,003 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]