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
Clifton
Newbie


Joined: 10 Mar 2015
Posts: 2

PostPosted: Tue Mar 10, 2015 3:29 pm   

Multi-line MSDP capture
 
I've been trying to get MSDP to work. The challenge is that the data is coming over the telnet subchannel.

I have a variable that contains <CR><LF>s. So the pattern is only capturing a single line. I want it to capture all of the lines before the <IAC><SE>.

Does anyone have any experience/luck with this?

For example

Code:
 <IAC><SB><69><1>QUESTOR<2>1. Lore of cities (Timaran)<LF><CR>
[   ] - Greet Xerties the Mystic in Timaran.<LF><CR>
2. Fell the Oaken Beasts (Armageddon Sanctuary)<LF><CR>
[   ] - Slay 20 oaken beasts. (0/20)<LF><CR>
3. Nexus crystals (Seringale)<LF><CR>
[   ] - Retrieve the green crystal shards from Linde the gleeman of Seringale.<LF><CR>
<IAC><SE>
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri Mar 13, 2015 7:05 am   
 
Working from the help files for ATCP, I would guess that the following might come close to providing you with what you need:
Code:
<trigger type="Telnet" param="69" priority="10" regex="true">
  <pattern>\A((?:.*$?)+)\Z</pattern>
  <value>VijCapturedText=%1</value>
</trigger>
The idea is to tell the trigger that it can keep matching multiple lines. The period symbol in regex is generally not allowed to match end of line symbols, and cMud definitely does not deviate from that default. zScript patterns are converted into regex behind the scenes, so I jumped straight to the regex level that allows a more complex pattern. The pattern says start at the beginning and capture (1 or more groups of (?:0 or more symbols that might be followed by an EOL marker)) until the end of the available text.
I think the way the Telnet triggers work includes being presented with the entire block of text between and in a single matching operation.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
glister
Beginner


Joined: 06 Mar 2014
Posts: 12

PostPosted: Tue Dec 31, 2019 8:30 pm   
 
So I put this together this will initialize MSDP on any mud and setup reporting for every available msdpvar

Code:
<class name="Initialize" id="209">
  <trigger type="Telnet" param="69" priority="10" regex="true" id="208">
    <pattern>[\x01]REPORTABLE_VARIABLES[\x02][\x05][\x02]</pattern>
    <value>#T+ BeginInit

</value>
  </trigger>
  <trigger name="BeginInit" type="Telnet" param="69" priority="11" repeat="true" regex="true" enabled="false" id="210">
    <pattern>[\x02]([a-z,_,\s]+)</pattern>
    <value>#SENDSB 69 %CHAR(1)REPORT%CHAR(2)%1
#T- BeginInit</value>
  </trigger>
  <alias name="LoadMSDP" id="211">
    <value>#sendsb 69 %CHAR(1)LIST%CHAR(2)REPORTABLE_VARIABLES
</value>
  </alias>
</class>


This one has two sets of triggers. The main ones parses through all of the msdp vars and maps them to variables. The second one puts all of the values of a sublist called group into a CMUD varaible database record. This can be used to capture content out of any custom lists that may be setup on your mud. Keep in mind you will need to modify this to work with the specific sublist.
Code:
<class name="Prod" id="189">
  <trigger name="Main" type="Telnet" param="69" priority="19" regex="true" newline="false" prompt="true" id="113">
    <pattern>^[\x01]([a-z,_]+)[\x02]([a-z,0-9,\s]+)</pattern>
    <value>#clr Combat</value>
  </trigger>
  <trigger name="Main2" type="Telnet" param="69" priority="20" regex="true" newline="false" prompt="true" id="195">
    <pattern>^[\x01]([a-z,_]+)[\x02]([a-z,0-9,\s]+)</pattern>
    <value>#VAR %1 %2

#Win Combat Tank: @Tank_Name
#Win Combat Enemy: @OPPONENT_NAME HP: @OPPONENT_HEALTH/@OPPONENT_Health_MAX</value>
  </trigger>
  <trigger type="Telnet" param="69" priority="1990" regex="true" id="199">
    <pattern>[\x01](GROUP)[\x02][\x05][\x02][\x03]</pattern>
    <value>CurMSDPTable = %1
#T+ GroupOpen
MSDPCounter = 1

</value>
  </trigger>
  <trigger name="GroupOpen" type="Telnet" param="69" priority="1991" repeat="true" regex="true" enabled="false" id="201">
    <pattern>[\x01]([a-z,_]+)[\x02]([a-z,0-9,\s]+)</pattern>
    <value>#ADDKEY @curMSDPTable @MSDPCounter {%1|%2}
MSDPCounter = @MSDPCounter + 1

#clr group
GroupSize = @MSDPCounter
#T+ GroupClose
</value>
  </trigger>
  <trigger name="GroupClose" type="Telnet" param="69" priority="1992" regex="true" enabled="false" id="202">
    <pattern>[\x01](GROUP)[\x02][\x05][\x02][\x03].*[\x04][\x06]</pattern>
    <value>//#say g2 activeated

//               NAME         

A = 1
#WHILE (@A < @GroupSize) {
#win Group @GROUP.@A.2 LvL:@GROUP.%eval(@A+1).2
#win Group HP:@GROUP.%eval(@A+3).2/@GROUP.%eval(@A+4).2 MV:@GROUP.%eval(@A+5).2;#ADD A 7}

//#win Group @GROUP.1.2 LvL:@GROUP.2.2 HP:@GROUP.4.2/@GROUP.5.2 MV:@GROUP.6.2

#T- GroupOpen
#T- GroupClose</value>
  </trigger>
</class>


Please note: The group triggers also have the syntax for pulling information out of the database variable. I'm pushing information to a windows named group. All of that isn't necessary however I left it here to have a great example of how it works.
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