 |
Ambelghan Novice
Joined: 04 Apr 2010 Posts: 49
|
Posted: Mon Apr 05, 2010 8:09 pm
Help:Multi line capture |
Hi, this is in DragonRealms, I want to try to capture all the armor my character is wearing through Trigger {i armor} the output looks like this:
| Quote: |
All of your armor:
a visored chain helm
some mail gloves
a lightened chain shirt
some serpentine chain greaves
an ordinary shield
[Type INVENTORY HELP for more options]
|
I tried:
| Quote: |
| All of your armor: * ~[Type INVENTORY HELP for more options~] |
but that didn't do it and I honestly have no idea how to start searching the forms for this one. |
|
|
|
 |
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Mon Apr 05, 2010 8:38 pm |
When you think multiple lines, think multiple-state triggers. In your case, you would have one trigger with 2 or 3 states:
| Code: |
#trigger "tWornArmor" {^All of your armor:$} {armor = ""}
#condition {^$} {}
#condition {^(*)$} {
#if (%begins(%1,"[Type")) {
//this is the [] line, not part of the inventory list
#state tWornArmor 0
//anything else you might want to do
} {
WornArmor = %additem(%1,@WornArmor)
}
} {manual} |
You CAN still use $ for carriage returns, but it's not really something we encourage anymore. |
|
_________________ EDIT: I didn't like my old signature |
|
|
 |
Ambelghan Novice
Joined: 04 Apr 2010 Posts: 49
|
Posted: Tue Apr 06, 2010 10:46 pm |
Wow that works well, but I don't quite understand it. the first trigger starts to capture anything that appears after "All of your armor:" into "armor"? What is the 2nd condition doing? And how did it know to break them up like that?
|
|
|
|
 |
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Wed Apr 07, 2010 12:37 am |
Whoops, that's a typo. The armor = "" part should be wornarmor = "". The idea here is that we no longer need the old list so we just get rid of it before the new list is handled. This pattern is necessary as an anchor point as well.
The second #condition figures out what kind of line is matching (that is, an item in the list or the [] line that comes after). If the line is an item in the list, it adds that item to the WornArmor variable as a stringlist element. If it's not, it just resets the trigger so that it's looking for the #trigger pattern again. |
|
_________________ EDIT: I didn't like my old signature |
|
|
 |
|
|
|