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.
 Entire forum ➜ MUSHclient ➜ VBscript ➜ counting time

counting time

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


Posted by Guest1   USA  (256 posts)
Date Tue 04 Mar 2003 06:40 PM (UTC)
Message
I think I saw a thread on this recently but just a bit of advice needed (or rather just to confirm I'm going about this the best way).

I have a counter that records total experience and coins gained during a group which I report avery so often to the group. Groups on average last for several hours. I have an alias that then resets it back to zero at the end of the group.

What I'm wanting to do is also add a time on that so that when I join a group and I reset my exp & coin counters to zero, it will also start a timer at the same time. When I report to the group the total exp & coin at any given time, it will also give the time taken so far, and calculate experience per hour based on that.

The calculation part is not a problem, I'm just trying to figure the best way to get the total time on it. It does not need to be extremely accurate, but I figured that I could have a timer that fires say every minute which grabs a variable (called total_time for example) and adds 1 to it. This variable would of course reset to zero whenever I reset the exp & coin totals.

The calculation part would then just grab that total_time variable and divide it by 60, then divide the total exp/coins by that result to give an average per hour.

All good, but is that timer firing every minute the best way to do it? I want as little disruption as possible to game play (lags etc when it fires) or would the timer firing have a negligible effect?

Thanks in advance for any advice (even if it's just to say I have the best way to do it).
Top

Posted by Shadowfyr   USA  (1,788 posts)  Bio
Date Reply #1 on Tue 04 Mar 2003 09:39 PM (UTC)

Amended on Tue 04 Mar 2003 09:41 PM (UTC) by Shadowfyr

Message
You could keep the time in a variable as well, something like:

a = DateDiff("n", world.getvariable("StartTime"), now)
world.send "party tell It has been " & a & " minutes since we started."

where:
yyyy = # years
q = # quarters
m = # months
y = day of year (Huh??)
d = # days
w = # weekdays
ww = weeks of year (Huh again???)
h = # hours
n = # minutes
s = # seconds

Though I suspect you would like to leave it at "n". ;)

You would basically just set the StartTime variable like 'world.setvariable "StartTime", now' at the same time that you reset everything else.

However, even calling a sub every x seconds is not a major issue. I have one that executes a call once every 10 seconds. It only becomes noticable on a 300mhz system and then only due to the fact that it calculates a color based on percentage of the spells expected duration and actual time passed and builds a line with about 40 colournote commands. However, that is the display part. The script that updates the actual times runs continuously at two second intervals even when the display itself goes idle (5 minutes after the last time I typed a command) and that script has no noticable effect on the client at all.
Top

Posted by Guest1   USA  (256 posts)
Date Reply #2 on Tue 04 Mar 2003 09:59 PM (UTC)

Amended on Tue 04 Mar 2003 10:02 PM (UTC) by Guest1

Message
hmmm that is true, a timer wouldn't even be needed with your suggestion.. however I've set it up the way I stated in my first post and it's working fine, the main advantage being I can switch the timer off and back on at any time if the group decides to have a 20 minute coffee break or something, which is pretty crucial for the results to be reasonably accurate (just disables the timer so it stops adding 1 to the total time variable every minute).

My main concern was disruption/lag with the timer calling a sub which calls a variable and then sets the variable to a new value every minute, but it doesn't appear to have much effect on gameplay that I can tell so far, so it's all good.

The only other problem I had was when trying to calculate the exp per hour immediately after resetting it ...because the value on reset was zero minutes, it crashed (froze) the client trying to divide 0 by 60 hehe. No worries, I now have it reset to 1 minute and 1 exp point instead of 0 on resets now. :)

thanks for advice Shadowfyr :)
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.


16,977 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.