Showing Game Time / Creating Highscore

Is there a way to create a visible clock that shows how long the player takes to finish the game?
Or can I at least show that as an end result when the game ends?

Can I create a highscore list (or low-score, actually) showing the players who finished it the fastest?


Hello.

Is there a way to create a visible clock that shows how long the player takes to finish the game?
Or can I at least show that as an end result when the game ends?

Yes.

game.timeelapsed is a default integer attribute which keeps track of the seconds since play began.


Can I create a highscore list (or low-score, actually) showing the players who finished it the fastest?

There is not an easy way of which I am aware.

...but that doesn't mean it's not possible.


Like this?
player.score=0
cup.score=5
cup.got=False
[player pick's up the cup]
player.score=player.score+(cup.score * cup.got)
cup.got=True
This way, the player doesn't get 5 points every time he pick's up the cup.


Create 1 timer with 2 attributes.

Put this in the game start script.

game.minute = 0
game.hour = 1

Make a timer that goes off every 60 seconds and have it start at the start of the game.
The code goes like this.

game.minute = game.minute + 1
if (game.minute = 60) {
  game.hour = game.hour + 1
  game.minute = 0
}
if (game.hour = 25) {
  game.hour = 0
}

You can also create an object like a clock. Looking at it can give the time!
The code should look like this:

msg ("The time is " + game.hour + " hours and " + game.minute + " minutes.")

If you're just displaying a clock at the end of the game, or when the player runs a certain command, it should be simple enough to do.

If you want it to be always displayed, there are a few options.

You could set it as a status attribute, to always be visible. But then you would need to update it using either a turnscript (updates whenever the player takes a turn), or a timer (probably a bad idea, as any verb menus the player has open would disappear when the clock changes).

If you want it to update in real time, the better option is probably using Javascript. This runs in the browser, and doesn't require the Quest backend to do any work.

If that's what you're after, I could try writing some code when I'm less busy. For now, just a response to the previous reply:

Create 1 timer with 2 attributes.

This seems a lot of work to do something simple.

I think it would be simpler not to bother with a timer, or a start script, and just use something like:

msg ("You have been playing for " + (game.timeelapsed / 3600) + " hours and " + ((game.timeelapsed/60)%60) + " minutes.")

or the same code spread out a bit more so it's easier to understand:

seconds = game.timeelapsed
minutes = seconds / 60
seconds = seconds % 60
hours = minutes / 60
minutes = minutes % 60
msg ("You have been playing for " + hours + " hours and " + minutes + " minutes.")

Or a really fancy version that hides the zeros:

units = NewStringList()
seconds = game.timeelapsed % 60
minutes = (game.timeelapsed / 60) % 60
hours = (game.timeelapsed / 3600)
if (hours >= 48) {
  list add (units, ToWords(hours/24) + " days")
  hours = hours % 24
}
if (hours > 1) {
  list add (units, hours + " hours")
}
else if (hours = 1) {
  list add (units, "an hour")
}
if (minutes > 1) {
  list add (units, minutes + " minutes")
}
else if (minutes = 1) {
  list add (units, "a minute")
}
if (seconds > 1) {
  list add (units, seconds + " seconds")
}
else if (seconds = 1) {
  list add (units, "a second")
}
msg ("You have been playing for " + FormatList (units, ", ", "and", "no time at all") + ".")

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

Support

Forums