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
zelenik
Beginner


Joined: 23 Sep 2006
Posts: 11

PostPosted: Tue Mar 03, 2020 11:29 pm   

Trying to develop triggers to store item records
 
I am struggling to figure out a good approach to make a record of item that I have identified in game the following is a snippet of the mud output

Quote:

You utter the words, 'Spellword'.
This is &itemName , a &itemSize &itemMaterial &itemType, weighing
approximately &itemWeight lbs. It is of &itemQuality quality and is worth
approximately &itemValue silver. It bears an innate endowment to moderately
increase fortitude. It bears an innate endowment to slightly increase
magical protection.


The word wrapping is forced by the game and results in a variable number of lines of output with different starting words after line 2 based on the attributes of the item. I've written a number of triggers. I've managed to capture pieces and parts, but can't get a good capture of the output because of the wordwrap and my amateur scripting ability. Currently, I'd accept capturing the lines to a txt file but I cant figure out how to get all of the lines.[/quote]
Reply with quote
shalimar
GURU


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

PostPosted: Wed Mar 04, 2020 1:09 am   
 
You need to use a state-based trigger to cobble all the lines together into a single string, then run the string through a %match to get your details.

Code:
#TR {You utter the words, 'Spellword'.} {identified=""}
#COND {*} {
  identified=%concat(%trim(@identified), " ", %trim(%line))
  #IF (%ends(%trim(%line), ".")) {#PRINT Now you can parse: @identified} {#STATE 1}
  }


Something like that will cobble the string together for you.
_________________
Discord: Shalimarwildcat
Reply with quote
zelenik
Beginner


Joined: 23 Sep 2006
Posts: 11

PostPosted: Wed Mar 04, 2020 11:47 pm   
 
Thanks a lot, Shalimar! This works well. I’ve had to figure out how the %match works. I’ve had success outputting to a .txt file. I think I’m going to work on slinging the variables into a database next.
Reply with quote
zelenik
Beginner


Joined: 23 Sep 2006
Posts: 11

PostPosted: Thu Mar 05, 2020 6:31 am   
 
I have another question. How would I update this to continue capturing text until a blank line is returned from the mud? It seems to be looking for a line that ends with a period and that sometimes breaks when multiple lines received from the mud end with a period.
Reply with quote
shalimar
GURU


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

PostPosted: Thu Mar 05, 2020 1:59 pm   
 
Edit the #IF statement so it better matches your needs:

#IF (%len(%trim(%line))<2)
#IF (%trim(%line)=%null)

Both of these should do what you are after.
_________________
Discord: Shalimarwildcat
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