Points Total

Started by Jon, Fri 10/11/2006 18:02:42

Previous topic - Next topic

Jon

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?

R4L

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

Khris

#2
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:
Code: ags
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.)

Ashen

I think this 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.
I know what you're thinking ... Don't think that.

Jon

Ok It's working now  :D
Cheers guys.

gypsysnail

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 :)
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

Ubel

Gypsynail, the Z-order of the score GUI must have a smaller value than the Z-order of the pop-up GUI.

gypsysnail

Aha! Thanks :) so thats what the z order was for. I understand. Cheers :)
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

Jon

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

Khris

Code: ags
function on_event(EventType event, int data) {
  if (event=eEventGotScore) {
    if (game.score==100) player.ChangeRoom(...);
  }
}

Jon


Jon

Quote from: KhrisMUC on Fri 24/11/2006 22:09:57
Code: ags
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.

Ashen

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.
I know what you're thinking ... Don't think that.

Jon

#13
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!

SMF spam blocked by CleanTalk