Grabbing a variable from a line of text?

Posted by Dacrian on Thu 20 Sep 2007 06:42 AM — 4 posts, 19,477 views.

Australia #0
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
Amended on Thu 20 Sep 2007 06:53 AM by Dacrian
Australia Forum Administrator #1
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>

USA #2
(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
Amended on Thu 20 Sep 2007 07:23 AM by Onoitsu2
Australia #3
awesome!

works beautifully.

(although now i find the answers by doing a search ;))

thanks
D