|
TesterOfLimitz Novice
Joined: 02 Jun 2007 Posts: 37
|
Posted: Sat Jun 02, 2007 2:30 am
Recurring Timer at Midnight |
Ok, Basically what I'm trying to do is create a system that keeps track of how much I win by gambling on the MUD Achaea
My problem is though, I'd like to have a Daily Winnings, Which resets the @dailywin variable every night at Midnight, whether Zmud is Open or not, because I come and go, logging in and out quite often, so resetting it that way wouldnt be accurate.
Id appreciate you guy's tips and any help you could provide, Id be more than happy to code everything else myself (and already have coded the vast majority of it) Im just kinda looking for help with that one bit
Thanks in Advance
--Tester |
|
|
|
TesterOfLimitz Novice
Joined: 02 Jun 2007 Posts: 37
|
Posted: Sat Jun 02, 2007 2:40 am |
Oh, sorry for the double post, But I could also use some help with perhaps storing the @Dailywin variable, so I can use the numbers to run a daily average, Im a complete novice when it comes to storing multiple variables like that, so any information regarding it would be vastly appreciated.
Thanks Again
--Tester |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Jun 02, 2007 3:05 am |
Sounds like you want to use a datarecord variable where the keys are some sort of time string created with the %time function and the values are your winnings that day. You can construct it like so:
#addkey DailyWinnings %time(yyyy-mm-dd) @Dailywin
then you can retrieve a certain day's winnings with %db(@DailyWinnings,2007-06-02) and loop through all the days you've collected with the #loopdb command.
As for resetting the Dailywin variable at midnight, it sounds like you need two systems - one to reset the counter if you're actually logged in at midnight, and one to check if midnight has passed while you were logged out. The former can be done with an alarm:
#alarm 23:59:59 {ResetWin %time(yyyy-mm-dd)}
(Note: it's significant that the alarm go off just before the OS changes its date. See the ResetWin alias). The latter can be done with the atconnect and atdisconnect aliases:
#var LastLog ""
#alias atconnect {#if (@LastLog != %time(yyyy-mm-dd)) {ResetWin @LastLog}}
#alias atdisconnect {LastLog = %time(yyyy-mm-dd)}
then you have an alias to add the winnings to the database and reset the variable:
#alias ResetWin {#addkey DailyWinnings {%1} @Dailywin};Dailywin=0} |
|
|
|
TesterOfLimitz Novice
Joined: 02 Jun 2007 Posts: 37
|
Posted: Sat Jun 02, 2007 10:44 am |
Seems to work great! Its kept track of the last two days worth of gambling. Now Im just working on finding a way to take add all of the values for each day up, and then divide by the number of total values to get my average wins/losses. Thanks for the help mate
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Jun 02, 2007 11:48 am |
You can compile your current daily average by doing something like this:
#var _ 0
#loopdb @DailyWinnings {#add _ %val}
#var _ @_/%numkeys(@DailyWinnings)
#say @_ |
|
|
|
TesterOfLimitz Novice
Joined: 02 Jun 2007 Posts: 37
|
Posted: Sun Jun 03, 2007 9:39 am |
Worked great mate...I appreciate the help, and actually, im going back and working on consolidating all of my major variables now, like Pack#'s and Weapon#'s onto one list, so they'll be easier to keep track of and change now that I know how to use the databases.
Anyways, Thanks again for the help!
--Tester |
|
|
|
|
|