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


Joined: 12 Jan 2003
Posts: 13
Location: Australia

PostPosted: Sat Sep 15, 2012 7:26 am   

captureing lines after a trigger line
 
Hi
I am useing cmud. I am trying to capture multipul lines after a line I can use as the trigger upto another line that I can use as the ending trigger. The output from the mud is.


You know the following defensive magic spells:
Endorphin's Floating Friend Transcendent Pneumatic Alleviator

You know the following offensive magic spells:
Kamikaze Oryctolagus Flammula Narquin's Mist of Doom
Nargl'frob's Empyrean Spear Pragi's Fiery Gaze

You know the following misc magic spells:
Collatrap's Instant Pickling Stick Jogloran's Portal of Cheaper Travel
Floron's Fabulous Mirror Master Woddeley's Luminescent Companion


I would like to have the line You know the following defensive magic spells: as the starting trigger and capture all the words upto You know the following offensive magic spells I would be putting the words Endorphin's Floating Friend Transcendent Pneumatic Alleviator into a variable and from there I would like to put them into a database. I would like to be able to repeat the process on the other sections so I can collect the infomation between offensive spells and misc spellsl. I would be collecting the information Kamikaze Oryctolagus Flammula Narquin's Mist of Doom Nargl'frob's Empyrean Spear Pragi's Fiery Gaze which in over several lines and do the same for the misc spells.

The information changes depending on what spells I have.

I have spent some time on trying to figure out how to get this information and have tryed things like cond command makeing string lists and other ways. My problem is I can't work out how to get the lines that follow a tigger line into a variable which I hope I can then phase to put into a database and build up infomation on all my spells so I can be informed about them. I can then gather further infomaiton from other trigger lines but for now I am stuck on getting the lines that follow in the above starting example.

Please advise on the commands and format to do this

Thank you
Yipfur[/i]
Reply with quote
meddlesome
Wanderer


Joined: 24 Aug 2012
Posts: 70

PostPosted: Sun Sep 30, 2012 2:39 am   
 
I like this question and it opened up a complete world of scripting for me.

I just got through posting a suedo example here: http://forums.zuggsoft.com/forums/viewtopic.php?t=37918

For the above example, I had a trigger that started it all, and it started it with the #T+ command. It is most effective when the collection triggers are in a separate CLASS. My example was DESCRIPTION.

In description I used {(%*)} as my trigger line. It captures the line and sends it to the predefined variable %1.

When the following lines are concatenated, I know I am done when I get to "Obvious exits:".

So I set this trigger line to disable the DESCRIPTION class thus turning off the ability to capture every line.

#TRIGGER {Obvious exits:} {#T- {DESCRIPTION}}
_________________
Intel Core 2 Quad Q9450 @2.66GHz
MDAC 2.8 SP1 ON WINDOWS XP SP3
Msjet40.dll ver 4.0.9511.0 + Security Bulletin MS08-028
CMUD v237
Order number: **7829
Reply with quote
meddlesome
Wanderer


Joined: 24 Aug 2012
Posts: 70

PostPosted: Sun Sep 30, 2012 3:01 am   
 
Oh, and I didn't just avoid answering your question, it just that your situation is not completely divulged. What are you going to do with this variable? Is the information going into a database? Are you keeping it resident in memory? Without that, I can't tell you how to do it in your situation. I can show you more on how I did it. Here is an item collection database script I use.

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
 <trigger priority="66310">
    <pattern>Your divination is complete...</pattern>
    <value>#T+ identify</value>
  </trigger>
  <class name="identify" enabled="false">
    <trigger priority="66330">
      <pattern>Object: &amp;Item.Object ~[&amp;Item.Names~]</pattern>
    </trigger>
    <trigger priority="66340">
      <pattern>Item Type: &amp;Item.ItemType Effects: &amp;Item.Effects</pattern>
    </trigger>
    <trigger priority="66350">
      <pattern>Equipable Location~(s~): &amp;Item.EquipLocs</pattern>
    </trigger>
    <trigger priority="66360">
      <pattern>Weight: &amp;Item.Weight Value: &amp;Item.Value Level Restriction: &amp;Item.LvlRestriction</pattern>
    </trigger>
    <trigger priority="66370">
      <pattern>Attributes: &amp;Item.Attributes</pattern>
    </trigger>
    <trigger priority="66380">
      <pattern>Damage Dice of &amp;Item.DamageDice</pattern>
    </trigger>
    <trigger priority="66390">
      <pattern>&amp;Item.Mana to MANA</pattern>
    </trigger>
    <trigger priority="66400">
      <pattern>&amp;Item.AGE to AGE</pattern>
    </trigger>
    <trigger priority="66410">
      <pattern>&amp;Item.STR to STR</pattern>
    </trigger>
    <trigger priority="66420">
      <pattern>&amp;Item.DEX to DEX</pattern>
    </trigger>
    <trigger priority="66430">
      <pattern>&amp;Item.CON to CON</pattern>
    </trigger>
    <trigger priority="66440">
      <pattern>&amp;Item.WIS to WIS</pattern>
    </trigger>
    <trigger priority="66450">
      <pattern>&amp;Item.INT to INT</pattern>
    </trigger>
    <trigger priority="66460">
      <pattern>&amp;Item.STA to STA</pattern>
    </trigger>
    <trigger priority="66470">
      <pattern>&amp;Item.DAMROLL to DAMROLL</pattern>
    </trigger>
    <trigger priority="66480">
      <pattern>&amp;Item.MOVE to MOVE</pattern>
    </trigger>
    <trigger priority="66490">
      <pattern>&amp;Item.HIT_POINTS to HIT_POINTS</pattern>
    </trigger>
    <trigger priority="66500">
      <pattern>&amp;Item.HITROLL to HITROLL</pattern>
    </trigger>
    <trigger priority="66510">
      <pattern>&amp;Item.SAVING_SPELL to SAVING_SPELL</pattern>
    </trigger>
    <trigger priority="66520">
      <pattern>Level &amp;Item.SpellLvl spell of &amp;Item.SpellName.</pattern>
    </trigger>
    <trigger priority="66530">
      <pattern>$</pattern>
      <value>#T- identify
#DBLOAD all_items
#NEW All @Item
#DBSAVE all_items
#DBCLOSE all_items
#PRINT {Item added to Database.}
#UNV Item</value>
    </trigger>
  </class>
</cmud>
_________________
Intel Core 2 Quad Q9450 @2.66GHz
MDAC 2.8 SP1 ON WINDOWS XP SP3
Msjet40.dll ver 4.0.9511.0 + Security Bulletin MS08-028
CMUD v237
Order number: **7829
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sat Oct 06, 2012 9:21 am   
 
What is your prompt line? You have to have someway to disable the capture trigger after each list and you wouldn't want the next list to do the job because there is no next list after the last one.

I assume it would look like the following using > as the prompt:

You know the following defensive magic spells:
Endorphin's Floating Friend Transcendent Pneumatic Alleviator
>
You know the following offensive magic spells:
Kamikaze Oryctolagus Flammula Narquin's Mist of Doom
Nargl'frob's Empyrean Spear Pragi's Fiery Gaze
>
You know the following misc magic spells:
Collatrap's Instant Pickling Stick Jogloran's Portal of Cheaper Travel
Floron's Fabulous Mirror Master Woddeley's Luminescent Companion
>


Try something like the following which would capture and add each spell to a corresponding list variable.

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <var name="DefensiveSpells" copy="yes"/>
  <var name="MiscSpells" copy="yes"/>
  <var name="OffensiveSpells" copy="yes"/>
  <trigger name="spellCaptureDefensive" priority="30" regex="true" enabled="false" copy="yes">
    <pattern>^(.+)</pattern>
    <value>#additem DefensiveSpells %1</value>
  </trigger>
  <trigger name="spellCaptureMisc" priority="50" regex="true" enabled="false" copy="yes">
    <pattern>^(.+)</pattern>
    <value>#additem MiscSpells %1</value>
  </trigger>
  <trigger name="spellCaptureOffensive" priority="40" regex="true" enabled="false" copy="yes">
    <pattern>^(.+)</pattern>
    <value>#additem OffensiveSpells %1</value>
  </trigger>
  <trigger name="spellListing" priority="10" regex="true" copy="yes">
    <pattern>^You know the following (defensive|offensive|misc) magic spells\:</pattern>
    <value>$type = %1
#switch ($type)
  ("defensive") {#T+ spellCaptureDefensive}
  ("offensive") {#T+ spellCaptureOffensive}
  ("misc") {#T+ spellCaptureMisc}</value>
    <trigger name="spellListPrompt" regex="true" newline="false" prompt="true">
      <pattern>^\>$</pattern>
      <value>#T- spellCaptureDefensive
#T- spellCaptureMisc
#T- spellCaptureOffensive</value>
      <notes>Enter your prompt pattern for this trigger. Currently it is set to match > prompt character.</notes>
    </trigger>
  </trigger>
</cmud>
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