bl791's picture
download
raw
3.91 kB
Here are the changes I made to STD.T to display the time and day of the week
on the status line instead of "score/moves". Feel free to use these this code
in your games or modify it as you see fit. Enjoy!
Add the following to the "init" function:
init: function
{
scoreStatus(global.hours, global.minutes);
setdaemon( timeDaemon, nil ); // start the clock daemon
}
Add the following to the "global" object:
global: object
hours = 9 // set the time to Saturday at 9:00 PM
minutes = 0
PMtime = true // true if PM, nil if AM
DayNum = 7 // 1 = Sunday, 2= Monday, etc.
DayofWeek = ' / Saturday' // set the initial day of the week
;
Add the following code:
timeDaemon : function ( parm )
{
global.minutes := global.minutes + 1;
if (global.minutes > 59)
{
global.minutes := 0;
global.hours := global.hours + 1;
}
if (global.hours > 12)
global.hours := 1;
if (global.hours = 12 and global.minutes = 0)
global.PMtime := not global.PMtime;
if (global.hours = 12 and global.minutes = 0 and global.PMtime = nil)
{
global.DayNum := global.DayNum + 1;
if (global.DayNum > 7)
global.DayNum := 1;
switch(global.DayNum)
{
case 1:
global.DayofWeek := ' / Sunday';
break;
case 2:
global.DayofWeek := ' / Monday';
break;
case 3:
global.DayofWeek := ' / Tuesday';
break;
case 4:
global.DayofWeek := ' / Wednesday';
break;
case 5:
global.DayofWeek := ' / Thurday';
break;
case 6:
global.DayofWeek := ' / Friday';
break;
case 7:
global.DayofWeek := ' / Saturday';
break;
}
}
}
;
replace scoreStatus: function(hours, minutes)
{
if (minutes < 10)
setscore('Score: ' + cvtstr(global.score) +
' Time: ' + cvtstr(hours) + ':0' + cvtstr(minutes) +
(global.PMtime ? ' PM' : ' AM') + global.DayofWeek);
else
setscore('Score: ' + cvtstr(global.score) +
' Time: ' + cvtstr(hours) + ':' + cvtstr(minutes) +
(global.PMtime ? ' PM' : ' AM') + global.DayofWeek);
}
;
replace turncount: function( parm )
{
scoreStatus(global.hours, global.minutes);
}
;
timeVerb: sysverb
verb = 'time'
action( actor ) =
{
displayTime(global.hours, global.minutes);
}
;
displayTime : function (hours, minutes)
{
"It is ";
if (minutes < 10)
{
say(cvtstr(hours) + ':0' + cvtstr(minutes) +
(global.PMtime ? ' PM' : ' AM'));
}
else
{
say(cvtstr(hours) + ':' + cvtstr(minutes) +
(global.PMtime ? ' PM' : ' AM'));
}
say(global.DayofWeek);
}
;
replace undoVerb: sysverb
verb = 'undo'
action(actor) =
{
/* do TWO undo's - one for this 'undo', one for previous command */
if (undo() and undo())
{
"(Undoing one command)\b";
Me.location.lookAround(true);
scoreStatus(global.hours, global.minutes);
}
else
"No more undo information is available. ";
abort;
}
;
replace restoreVerb: sysverb
verb = 'restore'
sdesc = "restore"
doAction = 'Restore'
action( actor ) =
{
local savefile;
savefile := askfile( 'File to restore game from' );
if ( savefile = nil or savefile = '' )
"Failed. ";
else if (restore( savefile ))
"Restore failed. ";
else
{
scoreStatus(global.hours, global.minutes);
"Restored.\b";
Me.location.lookAround(true);
}
abort;
}
;
Well, that's all there is to it. Please let me know if there is anything I
missed or if there are any bugs. I can be reached here or on GEnie at my
e-mail address of J.MENICHELLI.

Xet Storage Details

Size:
3.91 kB
·
Xet hash:
a66bb41415b33bd707fa915f973ec09d452be52bf774f738fe01af2f97873bcd

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.