Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Ambelghan
Novice


Joined: 04 Apr 2010
Posts: 49

PostPosted: 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.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: 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
Reply with quote
Ambelghan
Novice


Joined: 04 Apr 2010
Posts: 49

PostPosted: 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?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: 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
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net