Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: steptoe on Fri 15/06/2012 20:47:13

Title: SOLVED: Text Label display problems on GUI
Post by: steptoe on Fri 15/06/2012 20:47:13
Hi

I am right at the end of a scene and my brain feels like it's scrambled!!

I have a problem that is bugging me and need a clearer brain to help me.

I have an object that moves from A to B via squares (the main player just shakes a tumbler and the dice rolls out.) The object moves in relation to the dice number that has been thrown.

If the object lands on a square with a goodie it takes it and a GiveScore added. This continues until the object  is at the end of the board.
At that point the object stops, the player says something and then a GUI opens.

Up to this point it all works until the GUI shows.

This GUI shows the players Score on a label along with another label that divides the Score by 5.

I used AGS @SCORE@ to keep track of the score and I made int cube.

I have put below code in Room:

function repeatedly_execute_always()
{
if  (PPColliding.OWithO(object[7], object[11]))
{
gSCORES.Visible=true;
Lscore.Text = String.Format("You have %d Sweet Power",SCORES);
Lcubes.Text=String.Format("You have %d Cube Power",SCORES /5);
}
}


Lscore shows but it displays 15 for the score and the lcubes label displays 3 (SCORE/ 5) it does not seem to give the real score. I then added GiveScore(300) on room load to boost the score and it shows in main @SCORE@ but not on GUI which still displays 15.

Hope you understand what I have put and can help me sort it out.

cheers



Title: Re: Text Label display problems on GUI
Post by: on Fri 15/06/2012 20:53:43
Could be possible that SCORE doesn't allow maths being used on it? Are you using game.score to retrieve it? @SCORE@ is just a tag that allows you to automatically make a label display the score, without you having to update it.

As a workaround, you can always create an int as a temporary placeholder:

int i;
i = game.score;
i = i/5;

and then just display i in a formatted string.
Title: Re: Text Label display problems on GUI
Post by: Andail on Fri 15/06/2012 20:57:13
Is there a reason you're using SCORES instead of game.score?
Also, you're changing between SCORE and SCORES, is this deliberate?
Title: Re: Text Label display problems on GUI
Post by: monkey0506 on Fri 15/06/2012 20:58:44
Quote from: Red Belly on Fri 15/06/2012 20:47:13I used AGS @SCORE@ to keep track of the score and I made int cube.

Code (ags) Select
// ...code that clearly doesn't use @SCORE@...

Uh... No. You haven't.

Quote from: Red Belly on Fri 15/06/2012 20:47:13
Code (ags) Select
function repeatedly_execute_always()
{
if  (PPColliding.OWithO(object[7], object[11]))
{
gSCORES.Visible=true;
Lscore.Text = String.Format("You have %d Sweet Power",SCORES);
Lcubes.Text=String.Format("You have %d Cube Power",SCORES /5);
}
}


Lscore shows but it displays 15 for the score and the lcubes label displays 3 (SCORE/ 5) it does not seem to give the real score.

Seeing as you have a GUI named gSCORES then the macro SCORES is identical to gSCORES.ID. In this case, gSCORES is your 15th GUI, hence "SCORES" is always being reflected as 15.

I get what you're going for, but I don't know how you decided that the game score is stored in a global variable called SCORES. It's not.

Quote from: Red Belly on Fri 15/06/2012 20:47:13I then added GiveScore(300) on room load to boost the score and it shows in main @SCORE@ but not on GUI which still displays 15.

Ah, okay. So you have multiple different GUIs which are supposed to show the score simultaneously? Okay. Although...why are you now calling gSCORES "GUI". Its name isn't GUI. It is a GUI, but so is the GUI that holds the label that shows the "main @SCORE@".

So, I get the general idea of what you're going for here.

Code (ags) Select
function repeatedly_execute_always()
{
  // I fixed that indentation problem for you
  // (You know, the one AGS handles automatically)
  if (PPColliding.OWithO(object[7], object[11])) // if this is in a room script, why not use the actual object names?
  {
    gSCORES.Visible = true;
    Lscore.Text = String.Format("You have %d Sweet Power", game.score);
    Lcubes.Text = String.Format("You have %d Cube Power", game.score / 5);
  }
}


Two new replies while I was typing. :D Oh wells.
Title: Re: Text Label display problems on GUI
Post by: steptoe on Fri 15/06/2012 20:59:13
Ghost, Monkey.

EDIT: What was I doing :(

Fancy not using games.score !! How could I forget this????.  I have also renamed gSCORE GUI to gend.

Feel stupid, as I said, my brain's scrambled this evening!

Thank you both,

Monkey I have add your code and all's well.

Thank you so much :) 8-)

Job done.







Title: Re: Text Label display problems on GUI
Post by: monkey0506 on Fri 15/06/2012 21:03:57
No offense to Ghost, but there's not any reason to store game.score before using it here.

The only reason he suggested that though is because you were confusing everyone by trying to use the GUI gSCORES, the predefined macro SCORES which is the same as gSCORES.ID, and the built-in tag @SCORE@ almost interchangeably. They're completely different things serving different purposes. You need to learn that. And as stated, none of them are the same as game.score.
Title: Re: SOLVED: Text Label display problems on GUI
Post by: steptoe on Fri 15/06/2012 21:15:06
I have noted all this for future reference.

cheers