Help with capturing multi-line text

Posted by Silco69 on Wed 09 Dec 2015 08:21 AM — 3 posts, 16,298 views.

Australia #0
Hello again!

I'm attempting to create a calculator to determine the total amount of mindspace your spells take up in the discworld MUD.

The problem I'm currently facing, is capturing the spells you have in your head. It is currently displayed as follows


You know the following defensive magic spells:
Chrenedict's Corporeal Covering         Grisald's Reanimated Guardian
Endorphin's Floating Friend             Transcendent Pneumatic Alleviator

You know the following offensive magic spells:
Doctor Kelleflump's Deadly Demon        Pragi's Fiery Gaze
Effermhor's Hypersonic Assault          Wungle's Great Sucking
Myrandil's Vicious Seizure              

You know the following misc magic spells:
Collatrap's Instant Pickling Stick
Fabrication Classification Identification
Floron's Fabulous Mirror
Fyodor's Nimbus of Porterage
Gryntard's Feathery Reliever
Jogloran's Portal of Cheaper Travel
Worstler's Advanced Metallurgical Glance


Would anyone have any suggestions as to how I might capture multi-line text that appears to be split into columns or if it is at all possible?

Thank you in advance!

* I see that copy/pasting it here formats the tabs inbetween the spells. If needed I could upload a screenshot

[EDIT] moderator's note: I added code tags - Fiendish
Amended on Wed 09 Dec 2015 04:48 PM by Fiendish
USA Global Moderator #1
Break the problem into sections of work. Let's start with the defensive spells, for instance.

You want two triggers. One that captures "You know the following defensive magic spells:", call it DEFENSIVE_START,
and one that captures "*" (otherwise known as a catchall), call it DEFENSIVE_CAPTURE.

Now you only want DEFENSIVE_CAPTURE to get enabled when DEFENSIVE_START fires and you only want it to stay active until the next blank line. So the first thing that DEFENSIVE_START does should be to EnableTrigger("DEFENSIVE_CAPTURE"). And the first thing that DEFENSIVE_CAPTURE does should be to disable itself if it has just matched a blank line. And that covers making sure that the capture is only active when you want it to be.

Now you need to make DEFENSIVE_CAPTURE do something. There are two obvious cases. The first case is if it captures a blank line. In that case, as stated above, it should immediately disable itself from capturing future lines via EnableTrigger("DEFENSIVE_CAPTURE", false). The second case is if it captures something other than a blank line. By constructive definition, everything else is defensive spell data, so you want to parse the line appropriately and do something with the information.
Amended on Wed 09 Dec 2015 04:52 PM by Fiendish
Australia Forum Administrator #2
Template:faq=37
Please read the MUSHclient FAQ - point 37.