[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]  Capturing Lines and printing them to a file
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Capturing Lines and printing them to a file

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


Posted by Dpw3868   (6 posts)  [Biography] bio
Date Fri 11 Dec 2009 10:14 PM (UTC)
Message
I want to be able to capture information from the mud and print it to a text file. I know that Mushclient has this ability built in, but i want to be able to send certain lines to different files ect.

Once i understand how this is done i think i can work on making all the other ones I need/want.

To do this will I need to trigger off the text and pass the line to a script? I am guessing lua has some built in input/output functions i will need to open a file and write to it?

The pattern is

Joe tells you 'hello'

Trigger --> * tells you '*'

I want to capture this line to a file called tells.txt
and i do not want to omit it from the output to the screen.

Thanks in advanced

[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sat 12 Dec 2009 12:28 AM (UTC)
Message
Have you looked at logging? Or "send to notepad"?

You just make a trigger, send the matching text to "notepad" and one or more notepad windows can be written (you have to save them yourself).

Or, using logging, it is saved on-the-fly.

Or if you want to script the whole thing, see:

http://www.gammon.com.au/scripts/doc.php?lua=io.output

You could use f:write to write data on a matching trigger, making sure you open the file at some point.

- Nick Gammon

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

Posted by Dpw3868   (6 posts)  [Biography] bio
Date Reply #2 on Wed 16 Dec 2009 06:28 PM (UTC)
Message
Okay, so i started to work on this and i set something up that will log chat (says,tells,group tells, clan tells, shouts, ect.) to a notepad.

I also made another trigger that outputs gear worn by characters and mobs, as well as gear i have that decays into another notepad.

Finally I created a notepad that receives group information. If someone gets effected by something in a fight and gets lost in spam ect its output the the notepad.

I than made a script to resize all the windows, it worked.

The problem is my output to the notepads was not adding a new line.

This is what the trigger and code looks like for one example.

Trigger : <(@!gear_slot)>\s+(.+) -- matches a gear slot and whats worn i have a variable gear_slot with all the gear slots listed

Script:
AppendToNotepad("Gear_stuff","<","%1",">","\\t","%2","\\n")

This however does not print a newline.

When trying to resolve this I noticed some people use dummy worlds to receive output. I tried this and it takes care of the newline issue. However i am at a loss on how to resize multiple world windows in lua scripting.

Thanks
Dan
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Wed 16 Dec 2009 06:41 PM (UTC)
Message
Notepad windows need \r\n to make a new line (or in send-to-script it would be \\r\\n).

- Nick Gammon

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

Posted by Dpw3868   (6 posts)  [Biography] bio
Date Reply #4 on Wed 16 Dec 2009 08:38 PM (UTC)
Message
Thank you Nick.

Worked perfectly, now I don't need to worry about resizing and moving multiple worlds.

-Dan
[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.


3,416 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]