Display a working clock
MaxVK
18 Aug 2009, 12:44Hi everyone, I'm very new to Quest and not at all familiar with ASL and I am trying to display a functional clock as a status variable (12 or 24 hour, makes no difference). Iv tried to do this myself but managed to mess things up in a fairly major way (Backups rule!) although I honestly don't know exactly what I did
Iv searched the forums and found a fair bit of code, but unfortunately I'm not at all sure what to do with it (Where/How to put it etc), and ideally Id like the clock to display the current system time, but if it starts from a pre-set time it makes no difference at this stage.
Can anyone help me a bit please.
Regards
Max

Iv searched the forums and found a fair bit of code, but unfortunately I'm not at all sure what to do with it (Where/How to put it etc), and ideally Id like the clock to display the current system time, but if it starts from a pre-set time it makes no difference at this stage.
Can anyone help me a bit please.
Regards
Max
lyteside
18 Aug 2009, 15:57I have a working clock in my game. I do 1 minute game time per 1 second of real time.
here's the display:
here's the code to make the clock work:
then set your variables early in your start up.
if you need your clock to be in real time, just reset the interval to 60 secs instead of 2 sec.
here's the display:
msg <The clock above shows the time to be %hour%:#min# #ampm#.>
here's the code to make the clock work:
define timer <time>
interval <1>
action {
inc <minutes>
if (%minutes% <=9) then set string <min; 0%minutes%>
else set string <min; %minutes%>
if (%hour% = 12) and (%minutes% = 1) then {
if flag <am> then {
set string <ampm; pm>
flag off <am>
}
else {
set string <ampm; am>
flag on <am>
}
}
if (%minutes% >= 60) then {
inc <hour>
set numeric <minutes; 0>
set string <min; 00>
}
if (%hour% = 13) then set numeric <hour; 1>
' ************************* MORNING AND NIGHT *************************
if flag <OUTSIDE> then {
if flag <am> and (%hour% = 5) and (%minutes% = 52) then msg <The dawn is breaking.>
if flag <am> and (%hour% = 7) and (%minutes% = 15) then msg <It is now morning.>
if not flag <am> and (%hour% = 5) and (%minutes% = 45) then msg <The sun begins to set, and dusk approaches.>
if not flag <am> and (%hour% = 7) and (%minutes% = 37) then msg <It is dark outside.>
}
}
disabled
end define
then set your variables early in your start up.
' ---------------------- CLOCK
set numeric <hour; 7>
set numeric <minutes; 00>
set string <min; 0%minutes%>
set string <ampm; am>
flag on <am>
if you need your clock to be in real time, just reset the interval to 60 secs instead of 2 sec.
MaxVK
18 Aug 2009, 18:29That's exactly what I need lyteside, thanks, but...
What do I do with the code? I can edit the ASL document if need be, but where do I paste these bits of code?
regards
Max
What do I do with the code? I can edit the ASL document if need be, but where do I paste these bits of code?
regards
Max
lyteside
18 Aug 2009, 19:09you'll need to post your timer code outside of your room creations in the actual asl file (opened in notepad, etc.) I would suggest making a comment line so you can find your timers. Place them at the end of your file, after your room creations, and that closing "end define" tag you see. Here is an example:
your variables need to be defined in your start script code section when you open it up:
define room <control room>
script {
if flag <water> then msg <The sound of |irushing water|xi is very strong in this room.>
}
alias <control room>
prefix <a>
look <There are pipes above you that go from this room to the previous one. There is a small door on the west wall.>
east <Factory South Assembly Chamber>
define object <Control Room Door>
alias <small door>
alt <door; small>
look <There is a lock on the door from the other side. Once you go out, you may not be able to come back in.>
examine <There is a lock on the door from the other side. Once you go out, you may not be able to come back in.>
prefix <a>
article <it>
gender <it>
type <TLTclosable>
action <opened> {
msg <You pull the door open with little effort. You can tell it has a weight on it, so it will close automatically. Once you go to the next room, you won't be able to get back in again.>
create exit west <control room; hallway 5>
}
action <closed> {
msg <You let go of the door handle and it closes automatically.>
create exit west <control room;>
}
properties <closedDesc=The door is shut.; isClosedDesc=The door is shut.; closingDesc=You close the door and a latch secures it firmly.; isOpenDesc=The door is already open.; openingDesc=With little effort, you manage to pull the large door open.>
end define
end define
' ****************************TIMERS *******************
' ****************************TIMERS *******************
' ****************************TIMERS *******************
define timer <Seduce>
interval <10>
action {
set interval <seduce; $rand(15;50)$>
set numeric <taunting; $rand(1;4)$>
if here <Morulan Steamer> then {
foreground <white>
if flag <meet_veronica> then msg <$displayname(Morulan Steamer)$ |xn>
else msg <The $displayname(Morulan Steamer)$ |xn>
foreground <white>
do <Veronica_ConvoProc>
msg <#Veronica_C#>
}
}
disabled
end define
your variables need to be defined in your start script code section when you open it up:
define game <The Art>
asl-version <400>
gametype singleplayer
startscript {
' ---------------------- CLOCK
set numeric <hour; 7>
set numeric <minutes; 00>
set string <min; 0%minutes%>
set string <ampm; am>
}
MaxVK
18 Aug 2009, 19:37Thanks lyteside, Ill give that a go ASAP
regards
Max
regards
Max