[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Help with capturing multi-line text
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Help with capturing multi-line text

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Silco69   Australia  (3 posts)  [Biography] bio
Date Wed 09 Dec 2015 08:21 AM (UTC)

Amended on Wed 09 Dec 2015 04:48 PM (UTC) by Fiendish

Message
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
[Go to top] top

Posted by Fiendish   USA  (1,641 posts)  [Biography] bio   Global Moderator
Date Reply #1 on Wed 09 Dec 2015 04:51 PM (UTC)

Amended on Wed 09 Dec 2015 04:52 PM (UTC) by Fiendish

Message
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.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Wed 09 Dec 2015 09:26 PM (UTC)
Message
Template:faq=37 Please read the MUSHclient FAQ - point 37.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


2,405 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]