Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Jscript
➜ Queue's And Functions
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Nexes
(65 posts) 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? | Top |
|
Posted by
| Flannel
USA (1,230 posts) 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. | Top |
|
Posted by
| Nexes
(65 posts) 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. | Top |
|
Posted by
| Flannel
USA (1,230 posts) 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. | Top |
|
Posted by
| Ked
Russia (524 posts) 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. | Top |
|
Posted by
| Flannel
USA (1,230 posts) 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. | Top |
|
Posted by
| Nexes
(65 posts) 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. | Top |
|
Posted by
| Larkin
(278 posts) 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. | 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.
25,715 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top