Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, 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.
Entire forum
➜ MUSHclient
➜ General
➜ Grabbing a variable from a line of text?
Grabbing a variable from a line of text?
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Dacrian
Australia (18 posts) Bio
|
Date
| Thu 20 Sep 2007 06:42 AM (UTC) Amended on Thu 20 Sep 2007 06:53 AM (UTC) by Dacrian
|
Message
| Hi all, first post!
I'm new to MUSH - well, i've been using it for a few months now, and am just starting to slowly add all the "features" I had in my previous client. What I liked best was the ability to grab a bit of a line and use it as a variable, and wanted to know if I could do it here. Bear in mind I know nothing about coding anything ;)
for example:
One of the lines is:
A mysterious stone door solidifies with a satisfying thump.
I'd like to grab "mysterious stone door" (or whatever alternative it turns out to be, there's maybe 5 or 6 different types of door, they type that shows is random) and put it in an alias, say:
od
which sends:
open <variable>
look <variable>
is this possible? If it's possible for this, I can adapt it to all the other things I did with this feature.
thanks in advance!
Dacrian
Discworld MUD
EDIT:
I might have found it, but i'll need to have a play tomorrow - I may be able to use the "expand variable" checkbox? D | Top |
|
Posted by
| Nick Gammon
Australia (23,046 posts) Bio
Forum Administrator |
Date
| Reply #1 on Thu 20 Sep 2007 07:11 AM (UTC) |
Message
| Trigger to find the door type:
<triggers>
<trigger
custom_colour="2"
enabled="y"
match="A * solidifies with a satisfying thump."
send_to="9"
sequence="100"
variable="door_type"
>
<send>%1</send>
</trigger>
</triggers>
Alias to use that variable:
<aliases>
<alias
match="od"
enabled="y"
expand_variables="y"
sequence="100"
>
<send>
open @door_type
look @door_type
</send>
</alias>
</aliases>
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Onoitsu2
USA (248 posts) Bio
|
Date
| Reply #2 on Thu 20 Sep 2007 07:22 AM (UTC) Amended on Thu 20 Sep 2007 07:23 AM (UTC) by Onoitsu2
|
Message
| (Edit: Nick replied while I was typing this ... lol)
I would do this in this manner...
Trigger that matches (regular expression checked)
^A (.*?) solidifies with a satisfying thump\.$
Send To pulldown set to Script
SetVariable("door","%1")
Alias that matches (regular expression)
^od$
Send To pulldown set to Script
Send("open " .. GetVariable("door"))
Send("look " .. GetVariable("door"))
And that is that :)
As you can tell I like using regular expressions better than I do normal matching, so you can also use a normal match and do the same thing.
Hope this helps
-Onoitsu2 | Top |
|
Posted by
| Dacrian
Australia (18 posts) Bio
|
Date
| Reply #3 on Thu 20 Sep 2007 11:05 PM (UTC) Amended on Fri 21 Sep 2007 01:42 AM (UTC) by Dacrian
|
Message
| awesome!
works beautifully.
(although now i find the answers by doing a search ;))
thanks
D | 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.
14,630 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top