Ok, after some thought into it, and seeing recent attempts at re-doing the dream statistics code. I decided to write a much more robust system that utilizes some of the more recent changes in DS, including but not limited to PS.
This code is untested as of yet. When I get a chance to test it, i'll fix any bugs i find. Meantime, please feel free to post any bug reports, comments, or questions.
Thank you.
[ds]* Dream Statistics By Rafkin
* This code is copyrighted by Rafkin. Any code based off of this code, or direct copying of this code must contain this comment giving credit to Rafkin.
* Credit for the "Average Visitors Per Day" addition goes to Calite.
** INITIALIZATION **
* First we setup some variables
(0:0) When everything is starting up,
(5:300) set variable %up_minute to the value 0.
(5:300) set variable %up_hour to the value 0.
(5:300) set variable %up_day to the value 0.
* This checks if dream has been initialized for first time, and if not, initializes the PS
(0:0) When everything is starting up,
(1:621) and the PhoenixSpeak info {initialized} about this dream is not equal to 99,
(5:602) memorize that the PhoenixSpeak info {initialized} about this dream will now be 99.
(5:602) memorize that the PhoenixSpeak info {UpMinutes} about this dream will now be 0.
(5:602) memorize that the PhoenixSpeak info {UpHours} about this dream will now be 0.
(5:602) memorize that the PhoenixSpeak info {UpDays} about this dream will now be 0.
(5:602) memorize that the PhoenixSpeak info {TotalVisitors} about this dream will now be 0.
(5:602) memorize that the PhoenixSpeak info {TotalToday} about this dream will now be 0.
(5:602) memorize that the PhoenixSpeak info {MaxTotal} about this dream will now be 0.
(5:602) memorize that the PhoenixSpeak info {MaxToday} about this dream will now be 0.
(5:602) memorize that the PhoenixSpeak info {MaxMax} about this dream will now be 0.
(5:602) memorize that the PhoenixSpeak info {MaxDays} about this dream will now be 0.
(5:602) memorize that the PhoenixSpeak info {Incompletes} about this dream will now be 0.
(5:602) memorize that the PhoenixSpeak info {IncompletesToday} about this dream will now be 0.
** UPDATE UPTIME **
* Update the uptime. We'll go every minute instead of every second, for less stress on the server.
(0:101) When the time is 99:99 FST
(5:612) remember the PhoenixSpeak info {UpMinutes} about this dream, and put it in variable %upminutes.
(5:302) take variable %upminutes and add 1 to it.
(5:302) take variable %up_minute and add 1 to it.
(5:602) memorize that the PhoenixSpeak info {UpMinutes} about this dream will now be %upminutes.
(0:101) When the time is 99:99 FST
(1:620) and the PhoenixSpeak info {UpMinutes} about this dream is equal to 60,
(5:612) remember the PhoenixSpeak info {UpHours} about this dream, and put it in variable %uphours.
(5:302) take variable %uphours and add 1 to it.
(5:302) take variable %up_hour and add 1 to it.
(5:602) memorize that the PhoenixSpeak info {UpHours} about this dream will now be %uphours.
(5:602) memorize that the PhoenixSpeak info {UpMinutes} about this dream will now be 0.
(0:101) When the time is 99:99 FST
(1:620) and the PhoenixSpeak info {UpHours} about this dream is equal to 24,
(5:612) remember the PhoenixSpeak info {UpDays} about this dream, and put it in variable %updays.
(5:302) take variable %updays and add 1 to it.
(5:302) take variable %up_day and add 1 to it.
(5:602) memorize that the PhoenixSpeak info {UpDays} about this dream will now be %updays.
(5:602) memorize that the PhoenixSpeak info {UpHours} about this dream will now be 0.
** VISTOR COUNT
* This section simply updates the total number of visitors to the dream.
(0:9) When a furre arrives in the dream,
(5:612) remember the PhoenixSpeak info {TotalVisitors} about this dream, and put it in variable %totalvisitors.
(5:612) remember the PhoenixSpeak info {TotalToday} about this dream, and put it in variable %totaltoday.
(5:302) take variable %totalvisitors and add 1 to it.
(5:302) take variable %totaltoday and add 1 to it.
(5:602) memorize that the PhoenixSpeak info {TotalVisitors} about this dream will now be %totalvisitors.
(5:602) memorize that the PhoenixSpeak info {TotalToday} about this dream will now be %totaltoday.
** This line sets up the following trigger.
(5:612) remember the PhoenixSpeak info {MaxTotal} about this dream, and put it in variable %maxtotal.
** This line just sets up the Max Furres section below.
(5:318) set variable %current to the number of furres in the dream.
(0:9) When a furre arrives in the dream,
(1:204) and variable %totaltoday is greater than variable %maxtotal,
(5:602) memorize that the PhoenixSpeak info {MaxTotal} about this dream will now be %totaltoday.
** MAX FURRES
* This section keeps track of max number of visitors to the dream at the same time.
(0:9) When a furre arrives in the dream,
(1:623) and the PhoenixSpeak info {MaxToday} about this dream is less than %current,
(5:602) memorize that the PhoenixSpeak info {MaxToday} about this dream will now be %current.
(0:9) When a furre arrives in the dream,
(1:623) and the PhoenixSpeak info {MaxMax} about this dream is less than %current,
(5:602) memorize that the PhoenixSpeak info {MaxMax} about this dream will now be %current.
(0:9) When a furre arrives in the dream,
(1:620) and the PhoenixSpeak info {MaxMax} about this dream is equal to %current,
(5:602) memorize that the PhoenixSpeak info {MaxDays} about this dream will now be 0.
** INCOMPLETES
* This section keeps track of the number of furres who enter the dream but leave without finishing downloading
(0:10) When a furre leaves the dream,
(1:19) and the triggering furre (moved from/is standing at) position (0,0),
(5:612) remember the PhoenixSpeak info {Incompletes} about this dream, and put it in variable %incompletes.
(5:612) remember the PhoenixSpeak info {IncompletesToday} about this dream, and put it in variable %incompletestoday.
(5:302) take variable %incompletes and add 1 to it.
(5:302) take variable %incompletestoday and add 1 to it.
(5:602) memorize that the PhoenixSpeak info {Incompletes} about this dream will now be %incompletes.
(5:602) memorize that the PhoenixSpeak info {IncompletesToday} about this dream will now be %incompletestoday.
** NEW DAY
* This section resets the values for the new day
(0:101) When the time is 00:00 FST
(5:612) remember the PhoenixSpeak info {MaxDays} about this dream, and put it in variable %maxdays.
(5:318) set variable %current to the number of furres in the dream.
(5:302) take variable %maxdays and add 1 to it.
(5:602) memorize that the PhoenixSpeak info {TotalToday} about this dream will now be %current.
(5:602) memorize that the PhoenixSpeak info {MaxToday} about this dream will now be %current.
(5:602) memorize that the PhoenixSpeak info {IncompletesToday} about this dream will now be 0.
(5:602) memorize that the PhoenixSpeak info {MaxDays} about this dream will now be %maxdays.
** STATISTICS REPORT
* Finally, give the information to the requesting furre.
(0:31) When a furre says {!Stats},
(5:318) set variable %current to the number of furres in the dream.
(5:612) remember the PhoenixSpeak info {UpDays} about this dream, and put it in variable %updays.
(5:612) remember the PhoenixSpeak info {UpHours} about this dream, and put it in variable %uphours.
(5:612) remember the PhoenixSpeak info {UpMinutes} about this dream, and put it in variable %upminutes.
(5:612) remember the PhoenixSpeak info {TotalToday} about this dream, and put it in variable %totaltoday.
(5:612) remember the PhoenixSpeak info {MaxToday} about this dream, and put it in variable %maxtoday.
(5:612) remember the PhoenixSpeak info {IncompletesToday} about this dream, and put it in variable %incompletestoday.
(5:200) emit message {## Dream Statistics: Overview ##} to the triggering furre.
(5:200) emit message {Dream Uptime: %updays days, %uphours hours, %upminutes minutes.} to the triggering furre.
(5:200) emit message {**********************} to the triggering furre.
(5:200) emit message {Current Visitor Count: %current } to the triggering furre.
(5:200) emit message {Total Visitors Today: %totaltoday } to the triggering furre.
(5:200) emit message {Maximum Visitor Count Today: %maxtoday } to the triggering furre.
(5:200) emit message {%incompletestoday furres left before finishing dream download today.} to the triggering furre.
(5:200) emit message {**********************} to the triggering furre.
(5:200) emit message {Use '!Stats Uptime', '!Stats Total', '!Stats Max', or '!Stats Incompletes' for a more comprehensive report.} to the triggering furre.
(5:200) emit message {## End Dream Statistics Report ##} to the triggering furre.
(0:31) When a furre says {!Stats Uptime},
(5:612) remember the PhoenixSpeak info {UpDays} about this dream, and put it in variable %updays.
(5:612) remember the PhoenixSpeak info {UpHours} about this dream, and put it in variable %uphours.
(5:612) remember the PhoenixSpeak info {UpMinutes} about this dream, and put it in variable %upminutes.
(5:200) emit message {## Dream Statistics: Dream Uptime ##} to the triggering furre.
(5:200) emit message {Dream Uptime: %updays days, %uphours hours, %upminutes minutes.} to the triggering furre.
(5:200) emit message {%up_day days, %up_hour hours, %up_minute minutes since last upload/restart.} to the triggering furre.
(5:200) emit message {## End Dream Statistics Report ##} to the triggering furre.
(0:31) When a furre says {!Stats Total},
(5:612) remember the PhoenixSpeak info {TotalVisitors} about this dream, and put it in variable %totalvisitors.
(5:612) remember the PhoenixSpeak info {TotalToday} about this dream, and put it in variable %totaltoday.
(5:612) remember the PhoenixSpeak info {MaxTotal} about this dream, and put it in variable %maxtotal.
(5:612) remember the PhoenixSpeak info {UpDays} about this dream, and put it in variable %updays.
(5:200) emit message {## Dream Statistics: Total Visitors ##} to the triggering furre.
(5:200) emit message {This dream has seen %totalvisitors visitors total.} to the triggering furre.
(5:200) emit message {%totaltoday visitors have arrived today.} to the triggering furre.
(5:200) emit message {This dream has had a maximum of %maxtotal visitors in one day.} to the triggering furre.
(5:302) take variable %updays and add 1 to it.
(5:309) divide variable %totalvisitors by variable %updays and put the remainder in variable %unused.
(5:200) emit message {And an average visitor total of %totalvisitors per day.} to the triggering furre.
(5:200) emit message {## End Dream Statistics Report ##} to the triggering furre.
(0:31) When a furre says {!Stats Max},
(5:612) remember the PhoenixSpeak info {MaxToday} about this dream, and put it in variable %maxtoday.
(5:612) remember the PhoenixSpeak info {MaxMax} about this dream, and put it in variable %maxmax.
(5:612) remember the PhoenixSpeak info {MaxDays} about this dream, and put it in variable %maxdays.
(5:200) emit message {## Dream Statistics: Maximum Visitor Count ##} to the triggering furre.
(5:200) emit message {This dream has had %maxtoday simultaneous visitors today.} to the triggering furre.
(5:200) emit message {The record for number of simultaneous visitors is %maxmax } to the triggering furre.
(5:200) emit message {Which occured %maxdays days ago.} to the triggering furre.
(5:200) emit message {## End Dream Statistics Report ##} to the triggering furre.
(0:31) When a furre says {!Stats Incompletes},
(5:612) remember the PhoenixSpeak info {Incompletes} about this dream, and put it in variable %incompletes.
(5:612) remember the PhoenixSpeak info {IncompletesToday} about this dream, and put it in variable %incompletestoday.
(5:200) emit message {## Dream Statistics: Incomplete Downloads ##} to the triggering furre.
(5:200) emit message {%incompletestoday furres have left before finishing the dream download, today.} to the triggering furre.
(5:200) emit message {This makes for a total of %incompletes prospective visitors who changed their minds.} to the triggering furre.
(5:200) emit message {## End Dream Statistics Report ##} to the triggering furre.[/ds]
Edited to add average furres and days since MaxMax was reached.
Edited to fix average furres section. Also added credit for average furres suggestion to Calite.
Edited to fix a bug. unused variable