Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Lua
➜ Capturing Lines and printing them to a file
|
Capturing Lines and printing them to a file
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Dpw3868
(6 posts) 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
| | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) 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 | | Top |
|
| Posted by
| Dpw3868
(6 posts) 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 | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) 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 | | Top |
|
| Posted by
| Dpw3868
(6 posts) 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 | | 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.
20,416 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top