Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: barefoot on Wed 02/02/2011 06:44:06

Title: SOLVED: Reset Score to 0...
Post by: barefoot on Wed 02/02/2011 06:44:06
UPDATE:

This seems to work:


 game.score=0;


Typical!  Unless you know better..

-----------------------------------------------------




Hi

I have made this a new entry..

Once my game is finished it goes to a credits screen and if the user decides to play again from a Play button the score remains as it was.. what is the best way to reset the score to o..  All the Rooms have been Reset.

I am using the GiveScore (global)

Have tried:

if (HasPlayerBeenInRoom(5))
 game.score=0;


and then:


if (HasPlayerBeenInRoom(14))
   GiveScore(-38950);


But the score could of been anything! I just need it to return to 0

can anyone assist?

cheers

barefoot




Title: Re: SOLVED: GiveScore Total
Post by: Khris on Wed 02/02/2011 08:18:13
Why a second thread...?

Putting game.score and game.total_score in there doesn't make sense if you only use %d once.

If you want to tell the player how much money in total they can collect, you could use this:

  Display("So far you have collected $%d of a total of $%d.", game.score, game.total_score);

See, the first %d is replaced with the value of the first variable, the second %d with the value of the second variable, etc.
Title: Re: SOLVED: GiveScore Total
Post by: barefoot on Wed 02/02/2011 09:14:32
Hi Khris

Not a second thread, but a slightly different issue..

I used script as it was which included game.score and game.total_score

Also i do not want to display 'collected $%d of a total of $%d'.. which can be useful for other uses.

I just wanted to check what the player has accumulated ($) and then do an if/else function depending on how much he had accumulated.

what I have:

   cfence.Say("I estimate your Grand Total to be: $%d", game.score, game.total_score);


It seems to work ok and of course the possibilities are endless.

thank you for your comments... and i will be looking further into this..

barefoot


Title: Re: SOLVED: GiveScore Total
Post by: Khris on Wed 02/02/2011 09:38:27
You didn't get what I was trying to tell you:
you are listing two variables inside the .Say command but the message contains only one %d.
In other words, you don't need to put game.total_score at the end since it will be ignored.

But since you put it there in the first place I thought you maybe wanted to put that inside the message, too.
Title: Re: SOLVED: GiveScore Total
Post by: barefoot on Wed 02/02/2011 09:59:03
That makes sense

cheers Khris

barefooy
Title: Re: Reset Score to 0...
Post by: barefoot on Thu 03/02/2011 13:58:44
UPDATE:

This seems to work:


  game.score=0;


Typical!  Unless you know better..

-----------------------------------------------------

Once my game is finished it goes to a credits screen and if the user decides to play again from a Play button the score remains as it was.. what is the best way to reset the score to o..  All the Rooms have been Reset.

I am using the GiveScore (global)

Have tried:

if (HasPlayerBeenInRoom(5))
 game.score=0;


and then:


if (HasPlayerBeenInRoom(14))
   GiveScore(-38950);


But the score could of been anything! the 38950 was what the player has to have to win. I just need it to return to 0 whatever the players score is..

can anyone assist?

cheers

barefoot
Title: Re: SOLVED: Reset Score to 0...
Post by: Akatosh on Thu 03/02/2011 15:15:53
That does work. However, there is a global function that might save you a lot of trouble (http://www.adventuregamestudio.co.uk/manual/RestartGame.htm)...