|
Articnal Apprentice
Joined: 19 Jan 2002 Posts: 107
|
Posted: Fri Dec 12, 2003 11:17 am
Which is the good way... |
Hi.
I got something like this on my mud:
^^^The^^^white^^^dog^^^
Id like to add every word which appears me that way into a variable.
I tryed next trigger:
#tr {~^~^~^(%w)~^~^~^} {#additem Variable %1}
How to do this works with all the words which appear between the ^^^?
Thank you |
|
|
|
Articnal Apprentice
Joined: 19 Jan 2002 Posts: 107
|
Posted: Fri Dec 12, 2003 1:19 pm |
Another little question,is there any way of using a variable with the name of another variable? i mean:
I got variable1 named The big apple
I got variable2 named zone
then,id like to do something like:
#var variable3 @@variable2
Is there any way to making zmud know @@variable2 will be a variable? |
|
|
|
Danlo Magician
Joined: 28 Nov 2003 Posts: 313 Location: Australia
|
Posted: Fri Dec 12, 2003 2:49 pm |
If you want Variable3 to contain the value of variable2, you'd just go: #var variable3 {@Variable2}. If you want Variable3 to contain the value of a variable, who's name is contained in Variable2, you'd go: #var variable3 {@<@variable2>}
As for the capturing of the words, you could go:
#trigger {~^~^~^(%w)} {#var wordstring {%line};#var wordstring {%replace(@wordstring,^,"")}} |
|
|
|
Articnal Apprentice
Joined: 19 Jan 2002 Posts: 107
|
Posted: Fri Dec 12, 2003 5:50 pm |
Wow thankyou! but i got another thing harder yet...
What if the variable has a name with spaces on it? |
|
|
|
Toetag Magician
Joined: 10 Oct 2000 Posts: 356 Location: USA
|
Posted: Fri Dec 12, 2003 6:10 pm |
Look up pattern matching in the help files. You've a good start on this stuff now.
Taken right out of the help files, searching for "pattern matching".
Patterns can contain several special character for wild-card matching.
* match any number (even none) of characters or white space
? match a single character
%d match any number of digits (0-9)
%n match a number that starts with a + or - sign
%w match any number of alpha characters (a-z) (a word)
%a match any number of alphanumeric characters (a-z,0-9)
%s match any amount of white space (spaces, tabs)
%x match any amount of non-white space
%y match any amount of non-white space (same as %x but matches start and end of line)
%p match any punctuation
%q match any punctuation (same as %p but matches start and end of line)
%t match a direction command
%e match ESC character for ansi patterns
That's just some of your options. |
|
|
|
Danlo Magician
Joined: 28 Nov 2003 Posts: 313 Location: Australia
|
Posted: Fri Dec 12, 2003 6:11 pm |
variables can't have names containing spaces.
|
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Fri Dec 12, 2003 6:52 pm |
Variable names can have spaces. They just aren't convenient because there's no way to use them.
#VA {The big apple} {New York}
#VA {The big apple}
displays (.'s added for spacing)
Variable: The big apple ..... New York
but there's no way I know of to address it.
#VA The {This is the}
#SH @The big apple
gives @The plus " big apple", or
This is the big apple
#SH @{The big apple}
also gives
This is the big apple
So, while it's possible to make a variable named "The big apple" it doesn't have any use.
Articnal, you seem to spend a lot of time and energy on finding the hardest ways to do things. I'd suggest you put some of that time and energy on making things simpler instead.
As for your first question, you've certainly been reading this forum long enough to know that triggers which do what you want only fire ONCE per line and that you'll have to parse the line yourself to account for the multiple words.
EDIT: Removed unpaired { from second #SHow. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Fri Dec 12, 2003 8:32 pm |
Sample trigger.
#TR sample1 {~^~^~^(%w*)~^~^~^} {#VAR LB1 {%1};#LOOP 1,%numwords( {@LB1}, "^^^") {#ADDI LB2 {%word( {@LB1}, %i, "^^^")}}} |
|
|
|
Articnal Apprentice
Joined: 19 Jan 2002 Posts: 107
|
Posted: Fri Dec 12, 2003 8:43 pm |
Ok, thank you,and especially thanks for the tip... Ill try to allways remember it.
|
|
|
|
|
|