Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
snoogans
Novice


Joined: 28 Oct 2001
Posts: 43
Location: USA

PostPosted: Thu May 15, 2003 2:12 am   

Script to track game time
 
OK, the mud i play has every 1 minute = 15 seconds real time, i came up with this alarm to track the time, it works pretty well but it strays quite a bit. Can anyone tell me if theres anything wrong with the alarm or if its something else.

#alarm -(15|30|45|60) {#math minutes @minutes+1;#if (@minutes = 9) {#var minutes 09} {};#if (@minutes = 8) {#var minutes 08} {};#if (@minutes = 7) {#var minutes 07} {};#if (@minutes = 6) {#var minutes 06} {};#if (@minutes = 5) {#var minutes 05} {};#if (@minutes = 4) {#var minutes 04} {};#if (@minutes = 3) {#var minutes 03} {};#if (@minutes = 2) {#var minutes 02} {};#if (@minutes = 1) {#var minutes 01} {};#if (@minutes > 59) {#var minutes 00;#math hours @hours+1} {};#if (@hours > 12) {#if (@ampm = am) {#var ampm pm;#var hours 1} {};#if (@ampm = pm) {#var ampm am;#var hours 1} {}}}

--
BoBB
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu May 15, 2003 3:42 am   
 
Simplify.

#ALA -(15|30|45|0) {#ADD minutes 1;#IF (@minutes = 60) {#VAR minutes 0;#ADD hours 1;#IF (@hours = 12) {#IF (@ampm = am) {#VAR ampm pm} {#VAR ampm am}};#IF (@hours > 12) {#ADD hours -12}}

It's much easier to work with numbers if you just leave them as numbers. If you want to add leading zeros to the minutes, do it in the display script.

LightBulb
Advanced Member
EDIT: Changed ALARM time from 60 to 0
Reply with quote
snoogans
Novice


Joined: 28 Oct 2001
Posts: 43
Location: USA

PostPosted: Fri May 16, 2003 9:42 am   
 
In the display script? I display it in my status bar. Can i still do that?

--
BoBB
Reply with quote
snoogans
Novice


Joined: 28 Oct 2001
Posts: 43
Location: USA

PostPosted: Fri May 16, 2003 10:01 am   
 
Okay for some reason the alarm isn't going off on second #15 ... i checked the trigger everything is typed correctly. After some expirimentation I figured out that its not going off on the first parameter, no matter what it is, I just put an extra value in there and it works fine now, but something tells me its not supposed to do that :P

--
BoBB
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri May 16, 2003 4:42 pm   
 
Leading zeros can easily be added to a status line. Replace @minutes with:
%if(@minutes < 10, "0"@minutes, @minutes)

Actually, string lists don't seem to work for alarm times. Took a bit of testing before I found something that actually worked to my satisfaction:
#ALA clock2 -*15 {#SAY {Time is %time(hh:nn:ss)};#ADD minutes 1;#IF (@minutes = 60) {#VAR minutes 0;#ADD hours 1;#IF (@hours = 12) {#IF (@ampm = am) {#VAR ampm pm} {#VAR ampm am}};#IF (@hours > 12) {#ADD hours -12}}}
#STATUS {@hours:%if(@minutes < 10, "0"@minutes, @minutes) @ampm}

NOTES:
clock2 is just an ID to make deleting/replacing the alarm easier
The #SAY allowed me to tell when (if) the alarm was firing. Once testing is complete, it's not needed.
Added a missing } to the end of the alarm
-*15 is every 15 seconds of connect time
You could also use *15 which would be every 15 seconds of computer time. Since neither connect time nor computer time is synced to the MUD it shouldn't matter which you use.

LightBulb
Advanced Member
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net