|
yipfur Beginner
Joined: 12 Jan 2003 Posts: 13 Location: Australia
|
Posted: 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] |
|
|
|
meddlesome Wanderer
Joined: 24 Aug 2012 Posts: 70
|
Posted: 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 |
|
|
|
meddlesome Wanderer
Joined: 24 Aug 2012 Posts: 70
|
Posted: 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: &Item.Object ~[&Item.Names~]</pattern>
</trigger>
<trigger priority="66340">
<pattern>Item Type: &Item.ItemType Effects: &Item.Effects</pattern>
</trigger>
<trigger priority="66350">
<pattern>Equipable Location~(s~): &Item.EquipLocs</pattern>
</trigger>
<trigger priority="66360">
<pattern>Weight: &Item.Weight Value: &Item.Value Level Restriction: &Item.LvlRestriction</pattern>
</trigger>
<trigger priority="66370">
<pattern>Attributes: &Item.Attributes</pattern>
</trigger>
<trigger priority="66380">
<pattern>Damage Dice of &Item.DamageDice</pattern>
</trigger>
<trigger priority="66390">
<pattern>&Item.Mana to MANA</pattern>
</trigger>
<trigger priority="66400">
<pattern>&Item.AGE to AGE</pattern>
</trigger>
<trigger priority="66410">
<pattern>&Item.STR to STR</pattern>
</trigger>
<trigger priority="66420">
<pattern>&Item.DEX to DEX</pattern>
</trigger>
<trigger priority="66430">
<pattern>&Item.CON to CON</pattern>
</trigger>
<trigger priority="66440">
<pattern>&Item.WIS to WIS</pattern>
</trigger>
<trigger priority="66450">
<pattern>&Item.INT to INT</pattern>
</trigger>
<trigger priority="66460">
<pattern>&Item.STA to STA</pattern>
</trigger>
<trigger priority="66470">
<pattern>&Item.DAMROLL to DAMROLL</pattern>
</trigger>
<trigger priority="66480">
<pattern>&Item.MOVE to MOVE</pattern>
</trigger>
<trigger priority="66490">
<pattern>&Item.HIT_POINTS to HIT_POINTS</pattern>
</trigger>
<trigger priority="66500">
<pattern>&Item.HITROLL to HITROLL</pattern>
</trigger>
<trigger priority="66510">
<pattern>&Item.SAVING_SPELL to SAVING_SPELL</pattern>
</trigger>
<trigger priority="66520">
<pattern>Level &Item.SpellLvl spell of &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 |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: 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>
|
|
|
|
|
|
|