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
➜ VBscript
➜ pulling from a variable list
pulling from a variable list
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| ErockMahan
(81 posts) Bio
|
Date
| Wed 30 Jun 2010 02:48 PM (UTC) |
Message
| In a single variable I'm going to call "jerks," I am storing a list of names (manually inserted):
<variables>
<variable name="jerks">Bob
Bill
Steven the Slayer
Unlucky Thompson</variable>
</variables>
I want to be able to create a trigger that will check to see if one of the wildcards holds that variable:
* gives you the corpse of *.
if %2 = @jerks, then world.note he was a jerk anyway
I want to do it this way because the 'jerk' list is over 100 names long in some cases (it isn't actually a 'jerk' list, this is just for my example). | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #1 on Wed 30 Jun 2010 10:18 PM (UTC) |
Message
| You could do this instead and make it easier on yourself:
<variables>
<variable name="jerks">Bob|Bill|Steven the Slayer|Unlucky Thompson</variable>
</variables>
Then make your match line a regular expression like:
^(.*?) gives you the corpse of (@!jerks)\.$
The @!variable syntax is a special addition by MUSHclient that lets you use a pipe-separated list from a variable within the regexp. So when a match is attempted, the above is expanded to read:
^(.*?) gives you the corpse of (Bob|Bill|Steven the Slayer|Unlucky Thompson)\.$
Which is a valid regular expression. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| ErockMahan
(81 posts) Bio
|
Date
| Reply #2 on Thu 01 Jul 2010 05:44 AM (UTC) |
Message
| It works, thanks for the suggestion. Now let's add a twist.
There are two lists. Jerks and Bots. Is there a way that I can check the item against both lists?
And the coup de etat: I ultimately want to check against a wide selection of lists, determine which one it SHOULD credit to (this group has a higher importance than that one) but only if it belongs to more than one group.
Thanks for your help thus far. I'm enjoying using that with what I've already got in place, so you've already saved me a good deal of work! | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #3 on Thu 01 Jul 2010 06:58 AM (UTC) Amended on Thu 01 Jul 2010 06:59 AM (UTC) by Twisol
|
Message
| For the first thing, yes, but it comes with a risk. You can use (@!jerks|@!bots) to merge the two lists, but if one is empty you'll have (foo|) or (|foo), which AFAIK can cause a crash.
For the "arbitrary lists" thing, you'll be better served by using a MUSHclient Array (see the Array* function documentation) and using ArrayKeyExists() to check if it exists in the list. (It's more of a hash map than a numeric array, so be sure to use the names as keys, not values.) Then just check each array you have, in whatever order you want.
Were you using Lua I'd suggest using its inherent language construct, the 'table', but MUSHclient arrays come close. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | 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.
13,306 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top