Clock library for handling game time

The Pixie
I have created a library for Quest 5 for handling time. Includes a brief demo (four rooms and one item).Comments are invited.

From the readme:

The Pixie Clock Library

This library will help you to track time during the game. Time is incremented whenever the player takes a turn, starting from midnight on day 1. By default, moving to another room will take 5 minutes, any other action will take 1 minute. If the player types "clock" she will discover the time.


What you can also do:

Set the start time
In the game.start script, call IncTime to set the time in game starts in minutes past midnight.

Have the time displayed as a status variable
Add the attribute "clock" to the player, and set it to string. Then add it as a status variable. It will automatically track the time.

Have long distance exits
You can change the time that passes when a specific exit is used by calling the LongExit function. Call the function in a script on the exit, with the parameters, this, and the time to elapse.

<exit alias="north" to="distance_room">
<inherit name="northdirection" />
<script type="script">
LongExit (this, 45)
</script>
</exit>

Have exits open at different times
You can also have exits that can only be used at certain times. There is not a lot of control over this. The day is divided into six hour slots, and you can specify which are open with the third parameter to the BusinessExit function. This should be a 4 character string, each character corresponding to a six hour slot, n indicates not open, y indicates yes it is.

<exit alias="west" to="business_room">
<inherit name="westdirection" />
<script type="script">
BusinessExit (this, 5, "nynn")
</script>
</exit>


Convenience functions

In addition, there are a number of functions available that will hopefully make life easier for others..

GetTime
IncTime(int)
IsAfternoon
IsBusinessClosed(string)
IsEvening
IsDusk
IsMorning
IsNight
PartOfDay
TimeAsString

ender
Awsome! I was just thinking about needing this the other day ... thank you ...

mws257
Hi
I'm interested in using the clock feature and I've downloaded the demo and run it through Quest 5. Unfortunately I'm getting

Error running script: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

The screen shows the clock as day 1 11:50 and when I type in 'clock' it tells me the current time. But, if I try to use any of the cardinal points I get

Error running script: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

I am not an experienced programmer and I am simply lost on this one...

My system is windows 7 and 64 bit (does that help)

The other demos I have tried work well and I'm able to explore and learn but this one has me 'stumped'.

I haven't touched any setting, merely loaded the demo into Quest and the very first line on the screen is the error.

Anybody help?

Thanks

Penny

Pertex
Here is a new version of this library

@Alex, could you replace the old version on the Resourcespage? The Pixie overrode the function onenterroom so there was the bug with the new Q5-Version. I replaced this function now.

Alex
OK I have now updated the file.

demonboy
I've just implemented this and it's great. I simply copied the function in the library to have an office open during the day and closed at night, and then the bar next door do the opposite. Very simple but great library, thanks.

Time is quite important in my game. I'd be interested to know how easy it would be to let the player know that 'The sun is setting' only when they are in certain rooms (obviously at a certain time).

TextingStories
Interesting... can you have time run when you are simply standing there instead? Like if you are moving or not moving the time keeps flowing? Like I could be beating up on guards or I could be just talking with one and time will move at the same speed? Even if I run from room to room the time still moves the same? If so how would I go about implementing that?

Pertex
TextingStories wrote:Interesting... can you have time run when you are simply standing there instead?

I am sure you could do this with timers

TextingStories wrote: If so how would I go about implementing that?

I think, the first step would be learning scripting :D This can't be done without scripting

TextingStories
Pertex wrote:
I think, the first step would be learning scripting :D This can't be done without scripting


And how does one do that or at least with in Quest it self?

Pertex
Yes you can do it in Quest

TextingStories
Pertex wrote:Yes you can do it in Quest


No, I meant how does one learn to script. But I think it was answered in another post somewhere else.

The Pixie


I have a minor update for this, basicaly adding a function to display the time in words ("It's five past twelve in the afternoon"), as well as adding noon and midnight.

Thanks Pertex for the ealier update, by the way.

xordevoreaux
I've a clock as well but it's based on a timer, so you can walk away from the game for a while and time will continue around you. I use this to change the flavor text that randomly appears. For instance, if you're outside and it's morning, then the flavor text refers to "cool morning air" and things like that, or if outdoors and afternoon, "birds sail through the afternoon breeze," etc. etc.

Because I have morning, day, afternoon, evening, and night, plus indoors and outdoors, and different outdoor areas (urban, forest) have different sights and sounds, and I'm randomizing them, there's a fair number of combinations to program, but I think it's worth it, it'll give the game a bit more feeling of things being alive around you.

I've also done it all just using the editor interface. I don't hand-code at all.

Siset
Hello, first of all I must say that your library is great. I would like to include in my game some events that only occur at a certain time, for example, 8 a.m, but I am having problems with that because I don't know how to do it. If it's possible, I would like a piece of advice.

Thank you for your time.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums