Timestamps

Posted by Daniel Phillips on Tue 31 May 2005 08:41 PM — 11 posts, 40,924 views.

#0
Is there a way to trigger timestamps on MUSHclient?

I'd like to trigger such actions as...

You hurl a knife a Dingus

You regain your balance.

You jab Dingus

Your mind is now focused.

and many other things of that nature. I would enjoy it if there was set up to look much like[minute:second:milliseconds] if at all possible.

Muchas Nachos!
USA #1
What do you want?

You mean send things at certain times? or do you want to trigger those things, and then display the times they occurred?
Amended on Tue 31 May 2005 08:50 PM by Flannel
Sweden #2
Hmm..like..

Quote:
[Start Timestamp]

Jab Flannel-/00:00:00

You have recovered balance-/02:35:17

Throw dagger at Flannel-/03:58:12

You have recovered balance-/05:58:12

[End Timestamp]


Say, "It takes me 2.35 second to regain balance after a jab"

Like that?

#3
Tsinghahla hit it right on the head. That is exactly what I want.

Something to determine the time it takes to jab and regain focus.
USA #4
So, what resets the timers?

And then do what with that information?
Do you want it to display the time on each line?
Or do you want it to just note it? or put it in the status line? or what?
Sweden #5

on zMUD its just with %time.
%time(ss.zz) is seconds.microseconds
%time(nn:ss.zz) is minutes:seconds.microseconds
%time(hh:nn:ss.zz) is hours:minutes:seconds.microseconds

And I guess you want aliases to turn it on/off and reset it evertime you turn it off?

I believe this is what he's looking for.

No idea how to make it though, but more information to people who knows, if it's doable.
USA #6
If he just wants to know times between events, he doesn't need to go through much of anything.

If he wants to append the timestamp, he has to go through a plugin, and actually edit the line. Which will also have the ill effect of making his current triggers stop working (unless he includes the time in them).

So, it's definitely doable, I'm just trying to figure out if he needs timestamps on each activity, or if he just needs to know a span of time.

Lines already store their timestamp, and he can also simply create a trigger/alias to reset the timer (which would just store a time) and then just have whatever triggers just subtract their time from the stored time, and display that in the status bar, or in a note, or whatever else.

He can even reset the 'connected' time to zero, if he wants a running total.

Like I said though, pre/post fixing a timestamp is infact possible, and not that hard at all either. But it will have adverse affects that reverberate through all the triggers (and having to keep two versions, or an optional time, since you’ll want to be able to match regardless of whether the timestamp is on).
#7
All I want is something to print the time in minutes seconds and milliseconds at the end of a given line. Zmud does it with the %time command and I just throw along a #echo to show me on the main screen. I honestly didn't think it was that hard to understand whe way I put it but I guess I was wrong. I just want it to print the current minute second and millisecond, I can use math to figure out the difference from there.
USA #8
Here's a plugin to append timestamps to lines (I still think there are better ways to get it done, but whatever):
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Friday, June 03, 2005, 10:00 PM -->
<!-- MuClient version 3.66 -->

<!-- Plugin "Timestamp" generated by Plugin Wizard -->

<!--
The reason this is in JScript is because it's the only language in which it's easy to deal with milliseconds.

This is an ugly plugin, because it destroys all sembalance of order in the lines.
I suggest adding color to the timestamp (for the append) do that with the
ANSI function (since we're dealing with packets, you need to insert ANSI sequences).
It's in the OnPluginPacketRecieved function, the only line that does much in that function,
easy enough to find.

I do suggest if you're only using it for a couple of lines, that you just omit a line, and renote it
(or just note the time afterwards or whatnot).
This plugin has functions to do only that as well.
Check the :now alias for a pretty cut and dry example.
Also, you can include hours by toggling the comments in the GetTime function as well.
-->

<muclient>
<plugin
   name="Timestamp"
   author="Flannel"
   id="89596abf2cfcc625086f8255"
   language="JScript"
   purpose="Keep track of times between lines and optionally append a timestamp"
   save_state="y"
   date_written="2005-06-03 21:58:32"
   requires="3.59"
   version="1.0"
   >
<description trim="y">
<![CDATA[
timestamp:on - turn timestamping on
timestamp:off - turn timestamping off
timestamp:reset - reset the start time
timestamp:now - note the current time
timestamp:help - display this page
]]>
</description>

</plugin>


<!--  Get our standard constants -->

<include name="constants.js"/>

<!--  Aliases  -->

<aliases>
  <alias
   name="Reset"
   match="^timestamp:reset$"
   enabled="y"
   regexp="y"
   send_to="12"
   ignore_case="y"
   keep_evaluating="y"
   sequence="100"
  >
  <send>var now = new Date();
setvariable("zerotime", now.getTime());
note("Timestamp Reset to Zero");</send>
  </alias>
  <alias
   name="Toggle"
   match="^timestamp:(on|off)$"
   enabled="y"
   regexp="y"
   send_to="12"
   ignore_case="y"
   keep_evaluating="y"
   sequence="100"
  >
  <send>var toggle = "%1".toLowerCase();
if (toggle == "on")
{
  setvariable("enabled",1);
  note("Timestamp Enabled");
}
else if (toggle == "off")
{
  setvariable("enabled",0);
  note("Timestamp Disabled");
}</send>
  </alias>
  <alias
   name="Now"
   match="^timestamp:now$"
   enabled="y"
   regexp="y"
   send_to="12"
   omit_from_output="y"
   ignore_case="y"
   keep_evaluating="y"
   sequence="100"
  >
  <send>note(GetTime());</send>
  </alias>
</aliases>

<!--  Variables  -->

<variables>
</variables>

<!--  Script  -->


<script>
<![CDATA[

function OnPluginPacketReceived (s)
{
  if (GetVariable("enabled") == 1)
  {
    s = s.replace(/(\r\n|\r|\n)/g," - " + GetTime() + "$1");
  }
  return(s);
}

function FormatNumber (i,d)
{ //i is integer, d is digits (min)
  //returns a string
  var str = i.toString();
  var digits = str.length;
  for (var j = digits; j < d;j++)
  {
    str = "0" + str;
  }
  return (str);
}

function GetTime ()
{
  var now = new Date();
  var then = getvariable("zerotime");
  var diff = now.getTime()-then;
  var mill = diff % 1000;
  diff = Math.round(diff / 1000);
  var sec = diff % 60;
  diff = Math.round(diff / 60);
  /* //if you want hours, uncomment this
   * var min = diff % 60;
   * diff = Math.round(diff / 60);
   * note(diff + ":" + FormatNumber(min,2) + ":" + FormatNumber(sec,2) + "." + FormatNumber(mill,3));
   */
  return (diff + ":" + FormatNumber(sec,2) + "." + FormatNumber(mill,3));
}
]]>
</script>


<!--  Plugin help  -->

<aliases>
  <alias
   script="OnHelp"
   match="^timestamp:help$"
   enabled="y"
   regexp="y"
   ignore_case="y"
  >
  </alias>
</aliases>

<script>
<![CDATA[
function OnHelp (sName, sLine, wildcards)
  {
  world.Note (world.GetPluginInfo (world.GetPluginID, 3));
  }
]]>
</script>

</muclient>
#9
Does he mean TIMESTAMP or does he just want to know the duration?
USA #10
He wants it stamped, the line appended with a time, but he wants to be able to zero it. So yeah, it really is a 'timer' type thing, but it's stamped onto the line.

If you want the time itself stamped, the plugin should be easy enough to modify (it actually makes the whole thing a lot simpler).