[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]  General
. . -> [Subject]  Saving to a log file via script?
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Saving to a log file via script?

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


Posted by Dragoness   (9 posts)  [Biography] bio
Date Sat 30 Oct 2004 05:56 PM (UTC)
Message
Hi there, I am a newbie about this so I have no clue how to do what I need.

I need to capture a specific line:

Warmth flows through you as the chants of this circle reach the gods, restoring <exp amount> experience to <player>.

to a logfile, with the time if possible. The line is output when I type in the command lifechant <person name> Can this be done? If so can anyone please tell me how to do this.

Thanks in advance.
Dragoness.
[Go to top] top

Posted by Meerclar   USA  (733 posts)  [Biography] bio
Date Reply #1 on Sat 30 Oct 2004 06:03 PM (UTC)
Message
I believe the standard send_to_notepad does exactly that. There should be dozens of examples here on the board and at least 1 in the scripting/trigger helpfiles.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #2 on Sat 30 Oct 2004 06:10 PM (UTC)
Message
It's sendtonotepad, no underscores. And the problem with that is you have to 'remember' to save it (which you CAN do via scripting, so its not nessisarily a large problem), well and the fact that you have an open window.

A better solution (albeit more complicated) would be to use FSO and just append to the file.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Dragoness   (9 posts)  [Biography] bio
Date Reply #3 on Sat 30 Oct 2004 06:22 PM (UTC)
Message
Ok thanks, I had a look at the examples but I am not sure how to incorporate them into anything, where to put what.

What is the FSO thingy?

Thanks again
Dragoness.
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #4 on Sat 30 Oct 2004 06:50 PM (UTC)
Message
FSO is File Scripting Object. Search the forums, and the VBscript help file (you can download it from the same page you downloaded the other script languages on the MC site) and youll get a lot of examples.

As for using it, depending on how youre going about it, it'll be different.

Your trigger however, will be something like this (not accounting for spaces, and youd probably be better off with a regexp):
Warmth flows through you as the chants of this circle reach the gods, restoring * experience to *.

and then you either put your script (like sendtonotepad and savenotepad in the send box and then the "send to" box gets set to script, or you put it in a scriptfile and then use the "script" box to call the routine.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Dragoness   (9 posts)  [Biography] bio
Date Reply #5 on Sat 30 Oct 2004 07:40 PM (UTC)
Message
Thanks for your information, but do you know how to setup those sendtonotepad and savenotepad in mushclient? I have been trying to find instructions but I can't seem to figure it out. Do I copy those functions to the varibles in mushclient or is that the wrong track?

Thanks again
Dragoness.
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #6 on Sat 30 Oct 2004 08:10 PM (UTC)
Message
Youd put them in your "send" box (of the trigger) and "send to" script.

So itd be...
SendToNotepad "LogWindow", "Lets start a log" & VBCRLF
to send to it (and start it)
So if you had a trigger itd be:
SendToNotepad "LogWindow", "%0" & VBCRLF
(%0 is the full line that matched)

and then to save (whether you want to do it at the same time, or in a seperate thing) use this:
SaveNotepad "LogWindow", "C:\Path\logfile.txt", 1
That will save over the old one, so if you start a new session, you'll lose older stuff (unless you change the log name accordingly).

I believe OpenLog (I was perusing the function lits) opens a log, and then writes things to it (all the output), but if it doesnt, then that would be better. Or you could open the log, write to it, and then close it again. Then you could append, and not worry about overwriting stuff.
(Like this:
OpenLog "logfile.txt", true
writelog "%0"
CloseLog
that... should work. Assuming you have no other log file open. And that would be better, and cleaner. And you wouldn't have to worry about the next paragraph.

Also, notepad windows fill up over time. Theres a plugin regarding this I believe... Search for "notepad full" or something in this forum.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Dragoness   (9 posts)  [Biography] bio
Date Reply #7 on Sat 30 Oct 2004 09:22 PM (UTC)
Message
Hi there,
I set this in my send box:

OpenLog "C:\path\logfile1.txt", true
writelog "%0"
CloseLog

with the trigger set to
Warmth flows through you as the chants of this circle reach the gods, restoring * experience to *.

But I am not getting anything in the directory I assigned.

I have send to set to script and enable scripting is checked and it is set to vbscript.

Did I miss something?

Thanks again
Dragoness.
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #8 on Sat 30 Oct 2004 09:36 PM (UTC)
Message
Do you have the logging menu set up?
I dont know why it might be an issue. But with it you can also add the time to the beginning of the line.

Check to see if your trigger is matching. Either change it to change the line's color, or turn on trace. I suggest the former.

But no, assuming you actually have a path instead of 'path', and that its a valid one (I dont know if MC will make a directory or not) then I don't think that that is the problem.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Dragoness   (9 posts)  [Biography] bio
Date Reply #9 on Sat 30 Oct 2004 09:41 PM (UTC)
Message
Humm I haven't turned a log on if that is what you mean, if it is not I am not sure. If it is then doh :P
Dragoness
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #10 on Sat 30 Oct 2004 11:50 PM (UTC)
Message
You say you want to log certain messages, so turning on the log file would be a logical first step.

You could go to File menu -> Log Session, to turn logging on.

However if you only want to log certain lines then (in the dialog box that appears) uncheck "log output", "log commands" and "log notes". (In other words, log nothing). A confirmation dialog will appear asking if this is what you meant.

Then, make a trigger that matches the lines you want to capture, eg.


Match: Warmth flows through you as the chants of this circle reach the gods, restoring * experience to *.

Send: writelog now & " %0"
Send to: script


This will send the matching lines to the log file, with the date and time in front of them.

- Nick Gammon

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

Posted by Dragoness   (9 posts)  [Biography] bio
Date Reply #11 on Sun 31 Oct 2004 12:12 AM (UTC)
Message
Ok thanks, got it working.

You have been wonderful!

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


8,051 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]