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
miegorengman
Novice


Joined: 05 Sep 2008
Posts: 34

PostPosted: Tue Jul 05, 2022 6:48 am   

converting a large inventory into a list variable
 
I would like to capture all the text following "It Contains:" up to the period, and make it into a single list variable.

A chest made of solid rubber wood.
It contains:
a etched iron greatsword, 27 doritos, a shell, 2 frog teeth, 20 square feet of
tie died cloth, a very smelly sphere, a muddy iron greatsword, a etched iron
greatsword, a muddy iron bastard sword, a etched iron bastard sword, a muddy
iron greatsword, a etched iron greatsword, a muddy iron bastard sword, a etched
iron bastard sword, a muddy iron greatsword, a etched iron greatsword, a
bottle-green glass jug of red giggle juice, a muddy iron bastard sword, a parascope,
73 snaileggs, 11 gutsacks, 5 tropical leather thongs, a somewhat short beaded
rope, a etched iron bastard sword, an etched iron greatsword, a muddy iron
greatsword, a muddy iron greatsword, a etched iron greatsword, a lizardsilk hood,
28 spools of liver thread, an open silted flask, a skin tunic, 9 hunks of funky stuff, a
golden owl tunic, 69 square feet of fresh goldenrod skin.


At this point I have a working trigger that will grab the line immediately following "It Contains:", replace all the commas with a pipe, and remove the period, and assign the list to a string variable. I am just a little confused about how to grab the entire contents of "It Contains:"


Here is what I have so far, which works well as long as the contents are only on the line immediately following "It Contains:"


Code:
<pattern>It contains:$(*)</pattern>
  <value>#var rubberChestList {%remove(".",%replace(%1,", ","|"))}
</trigger>
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4549
Location: Pensacola, FL, USA

PostPosted: Tue Jul 05, 2022 9:18 am   
 
You need a stated trigger, something like this:

Code:
#TR {It contains:} {contents=""}
#COND {*} {
  contents=%concat(@contents, %line)
  #IF (%ends(%trim(%line), ".")) {contents=%remove(".",%replace(@contents,", ","|"))} {#STATE 1}
  } {within|param=1}
_________________
Discord: Shalimar#3679
Reply with quote
miegorengman
Novice


Joined: 05 Sep 2008
Posts: 34

PostPosted: Tue Jul 05, 2022 4:34 pm   
 
it works perfectly...now I just have to understand it. Thanks again shalimar :)
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4549
Location: Pensacola, FL, USA

PostPosted: Thu Jul 07, 2022 4:36 pm   
 
It's a 2 state trigger, only numbering starts at 0.

State 0
Just resets the Variable

State 1
Is of type within, with a param of 1.
This means: check the next one line for this pattern before resetting to state 0.

Adds the current line to the variable.
Then checks to see if the line ends in a period.
-- If it does, it's done and uses the code from your example.
-- If it doesn't, the trigger is told to reset to state 1 so it again checks one line.
_________________
Discord: Shalimar#3679
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