[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Tips and tricks
. . -> [Subject]  Timing an event

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Timing an event

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by ErockMahan   (76 posts)  [Biography] bio
Date Sat 20 Aug 2005 07:48 PM (UTC)  quote  ]
Message
I know, I know, this seems like it would be something covered elsewhere, but to be honest, I can't find it. I found a plugin that will time how long it takes to get to the next level, but I couldn't modify that plugin sufficiently for my needs.

I want to create an experience/time calculator. Meaning, when a fight beins, I want to start a timer that will stop when the fight ends, then divide the number of experience points by that time.

It would be helpful if the result could be appended to a notepad too, but if everything else is script oriented, I should be able to do that (thank you for help with that, by the way).

For the sake of examples, let's say that something simple happens at the beginning of every fight like:

The fight has begun!

and ends with:

You recieve * experience points.

Thanks for all your help!
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #1 on Sun 21 Aug 2005 05:39 AM (UTC)  quote  ]
Message
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=3362
That talks about Now and Time and stuff (for VBScript, other scripts deal with time in different ways).

But it also talks about how it works (and there are a lot of links, I havent followed any of them though).

If youre doing it by a timer, you're thinking about it wrong. Timers are like alarm clocks, not a stopwatch.
To act as a stopwatch, you need to store the start time, and then get the end time, and subtract.

Which script language you use depends on how exact you want to be. Some languages deal with time in milliseconds, some in seconds.

I wrote a plugin to append time differences (its only a plugin because it needs to tweak packets before interpretation). You can use the logic (or the subroutine to calculate) to do what you want. It's in JScript (since it needed milliseconds).
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=5567

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by ErockMahan   (76 posts)  [Biography] bio
Date Reply #2 on Mon 22 Aug 2005 01:48 PM (UTC)  quote  ]
Message
Wow, it took a lot of reading and lots of trying things, but I got it. It didn't come from any one source, so my thanks goes to many people, including you and Nick Gammon.

Now I just need to tweak it to perfection. It's nice that it all works, but now I'd like to change it to round off to two decimal places instead of floating. Here is the more important part of the code I wrote:


AppendToNotepad "stuff",vbcrlf
AppendToNotepad "stuff","%1 xp"
dim durationA
dim durationB
dim durationC
durationA = datediff("s",getvariable("durationstart"),time)
World.SetVariable "durationA", durationA
durationB = (Fix(durationA / 60))
durationC = (durationA - (durationB * 60))
world.EchoInput = 0
world.send "gt the fight took " & durationB & "mins " & durationC & "secs "
world.send "gt that is about " & %1 / durationA & " xp/sec"
world.EchoInput = 1




Thanks :)
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #3 on Mon 22 Aug 2005 09:46 PM (UTC)  quote  ]
Message
You can use SendNoEcho instead of toggling the echo value.

And you can use the function Round to round.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[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.


2,934 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]