Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Jon on Fri 10/11/2006 18:02:42

Title: Points Total
Post by: Jon on Fri 10/11/2006 18:02:42
Hi everyone!
I'm new to the forums and I have read the manual but i'm puzzled by something.
In a game I am making I will be awarding points, but I don't know how to have a Points total ( something like 10/100 ), this would be on the GUI when the mouse is not moving over it.
Can someone please help with my problem?
Title: Re: Points Total
Post by: R4L on Fri 10/11/2006 18:24:41
Its in the manual but yeah it kinda hard to find stuff in the manual isn't it?  :)

First make a label on the GUI you want your score displayed on. Then rename the label to @SCORETEXT@ and voila!

R4L
Title: Re: Points Total
Post by: Khris on Fri 10/11/2006 18:50:11
EDIT: I didn't know that there are all those @s available, so please ignore my post (unless you want to customize the way the score is displayed by adding a percentage bar or the like)

Add this to the end of your global script:
function on_event(EventType event, int data) {
  if (event=eEventGotScore) {
    score_label.Text=String.Format("Score: %d/100", game.score);
  }
}


You need to change "score_label" to whatever the script name of the label is.
(If there already is an on_event function, just insert the if (..) {...}, don't create another one, of course.)
Title: Re: Points Total
Post by: Ashen on Fri 10/11/2006 19:06:56
I think this (http://www.adventuregamestudio.co.uk/manual/Interface%20text.htm) is the manual entry R4L was talking about.

Setting the Label text to @SCORETEXT@ in the editor should display about the same as KhrisMUC's code ("Score : 10 of 100") and will automatically update itself, or you can use @SCORE@ and @TOTALSCORE@ for a different layout.
Title: Re: Points Total
Post by: Jon on Sat 11/11/2006 13:00:25
Ok It's working now  :D
Cheers guys.
Title: Re: Points Total
Post by: gypsysnail on Sat 11/11/2006 13:57:34
I have just been reading this thread and I did the score gui bar but there is one problem with my score bar, it wont stay under the main pop up gui bar (where you can select walk look talk etc cursors from), instead the score bar stays on top of the main pop up one. How can this be resolved? I set the score bar is normal and have tried other options, but nothing will stop it from being over the pop up one. Any ideas? Thanks :)
Title: Re: Points Total
Post by: Ubel on Sat 11/11/2006 14:03:11
Gypsynail, the Z-order of the score GUI must have a smaller value than the Z-order of the pop-up GUI.
Title: Re: Points Total
Post by: gypsysnail on Sat 11/11/2006 14:08:33
Aha! Thanks :) so thats what the z order was for. I understand. Cheers :)
Title: Re: Points Total
Post by: Jon on Fri 24/11/2006 19:01:09
Hi guys it's me again
I've figured out how to get the total up, but what do i do to make the character go to another room if it has for example 100/100?
thanks again
Title: Re: Points Total
Post by: Khris on Fri 24/11/2006 22:09:57
function on_event(EventType event, int data) {
  if (event=eEventGotScore) {
    if (game.score==100) player.ChangeRoom(...);
  }
}
Title: Re: Points Total
Post by: Jon on Sat 25/11/2006 13:06:45
thanks Khris
Title: Re: Points Total
Post by: Jon on Thu 21/12/2006 17:44:31
Quote from: KhrisMUC on Fri 24/11/2006 22:09:57
function on_event(EventType event, int data) {
Ã,  if (event=eEventGotScore) {
Ã,  Ã,  if (game.score==100) player.ChangeRoom(...);
Ã,  }
}


Hi again, I have recently done the 'bulk' of my game, and I have tried to put this code in. However, when I do so the message appears, 'expected ' ( '  ' and if I add the '(' the message appears 'Unexpected ' ( '  '.
I have placed this code at the bottom of the global script, exactly as Khris has put, except I changed the number '100' with '140', and I have also changed the '...' next to the word 'ChangeRoom' to '14'. But it does not seem to work, can anybody help me with this problem?

Thanks.
Title: Re: Points Total
Post by: Ashen on Thu 21/12/2006 17:52:16
Apart from the fact it should be event == eEventGotScore ( two '='s) KhrisMUC's code looks sound and should survive those changes. Which line generates the error, and where have you added the '('? It would help to see the code you're actually using, and not Khris' example.
Title: Re: Points Total
Post by: Jon on Thu 21/12/2006 19:53:17
My code is:

function on_event(EventType event, int data) {
Ã,  if (event=eEventGotScore) {
Ã,  Ã,  if (game.score==140) player.ChangeRoom(14);
Ã,  }
}

The error message for the '(' is the line where the 'function on_event' is (can't remember line number).

I shall try that code with the extra '=' now Ashen, will edit ASAP.

EDIT: works perfectly now, thanks Ashen, have a merry christmas!