Timestamp to output

Posted by Ashass on Mon 06 Feb 2012 01:00 AM — 5 posts, 22,571 views.

#0
Hey Nick, (or anybody who might know)

Currently I am utilizing the timestamp code (located at http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=10625)

I have need to put this into output so that it can be selected (or have the timestamp window changed in such a way it can be selected along with the text)

This will allow for better log parsing when it comes to pk logs, rp logs, etc. And will allow me to play back items in a real time format to emulate the occurrence.

Any suggestions how to approach this? I really like the fact that the timestamps are colored for normal world output, commands sent to mud, and scripts that are executed, and preserving that would be highly ideal.
Australia Forum Administrator #1
My suggestion is to amend the line preamble in the logging part (since you mention logs). That way you can stamp the date/time/whatever as part of the logs as saved to disk.
#2
Polite way of saying there's no clean way to save it in the raw output to world?
Australia Forum Administrator #3
I always try to be polite. :)

The fact is that that date/time is stored internally as part of the array entry for each line. And when you enable that option the output routine is configured to show it. And if you disable it, it isn't shown.

To actually add the date to the lines would corrupt the behaviour of many things like triggers that match on prompts, so it isn't actually part of the text of the line.

However ...

Template:function=GetLineInfo
GetLineInfo

The documentation for the GetLineInfo script function is available online. It is also in the MUSHclient help file.



It wouldn't take much effort for you to write a small script that uses that to get the text of the line, plus the date/time it was created, plus the information about whether it is input/output/note and make your "copy" of the output buffer. You can even put it on the Clipboard:

Template:function=SetClipboard
SetClipboard

The documentation for the SetClipboard script function is available online. It is also in the MUSHclient help file.



So yes, there's a clean way of saving it, with timestamps, if you do a small script to do it.
#4
Great reference! In spirit of keeping things simple, here's what it ultimately turned in to, and I am providing this as a sample for anyone else who might want a peek. My script is already capturing my prompt for health/mana/etc and outputting my condition based on that.

Output:
<122/122hp, 116/116m, 130/130mv, (Room of Holy Ceremony)[ES-SE]> 1:30pm.
[2/6/2012 4:58:49 PM] - You are in excellent condition.

The first line of output is my mud prompt, the second line of output is the result of that script you provided.

Trigger:
<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   keep_evaluating="y"
   match="&lt;*/*hp, */*m, */*mv, *&gt; *. *"
   send_to="12"
   sequence="100"
   variable="health"
  >
  <send>Dim percent 
dim line, total_lines
total_lines = world.GetLinesInBufferCount
SetVariable "current_hp", "%1"
SetVariable "total_hp",  "%2"

percent = (%1/%2 * 100)

if(percent &gt;= 100) then

world.tell "[" &amp; world.GetLineInfo (total_lines, 9) &amp; "] " 
 
Note "You are in excellent condition."
end if

if(percent &lt; 100 and percent &gt;= 90) then
Note "You have a few scratches."
end if

if(percent &lt; 90 and percent &gt;= 75) then
Note "You have some small wounds and bruises"
end if

if(percent &lt; 75 and percent &gt;= 50) then
Note "You have quite a few wounds"
end if

if(percent &lt; 50 and percent &gt;= 30) then
Note "You have some big &amp; nasty wounds"
end if

if(percent &lt; 30 and percent &gt;= 15) then
Note "You are pretty hurt"
end if

if(percent &lt; 15 and percent &gt; 0) then
Note "You are in awful condition"
end if

if(percent = 0) then
Note "You are dead!"
end if</send>
  </trigger>
</triggers>


Thanks for your help Nick!