Register forum user name Search FAQ

Gammon Forum

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 ➜ General ➜ Saving to a log file via script?

Saving to a log file via script?

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


Posted by Dragoness   (9 posts)  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.
Top

Posted by Meerclar   USA  (733 posts)  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
Top

Posted by Flannel   USA  (1,230 posts)  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.
Top

Posted by Dragoness   (9 posts)  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.
Top

Posted by Flannel   USA  (1,230 posts)  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.
Top

Posted by Dragoness   (9 posts)  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.
Top

Posted by Flannel   USA  (1,230 posts)  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.
Top

Posted by Dragoness   (9 posts)  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.
Top

Posted by Flannel   USA  (1,230 posts)  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.
Top

Posted by Dragoness   (9 posts)  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
Top

Posted by Nick Gammon   Australia  (23,158 posts)  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
Top

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

You have been wonderful!

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


31,830 views.

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

Go to topic:           Search the forum


[Go to top] top

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