Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Moox on Thu 08/07/2004 23:56:19

Title: Gui Labels
Post by: Moox on Thu 08/07/2004 23:56:19
From the Guide:
QuoteInterface text
You can easily display static text on interfaces. For example, the Sierra-style interface displays the score in the status bar.
To add text to a GUI, you add a label. Click the "Add label" button, then drag out a rectangle like you did when adding a button. You can change the text displayed in the label by editing the "Text" property. Notice that the text automatically wraps round to fit inside the rectangle you drew.

As well as typing normal text into the label, you can add some special markers which allow the text to change during the game. The following tokens will be replaced with the relevant values in the game:

@GAMENAME@Ã,  Ã,  The game's name, specified on the Game Settings pane
@OVERHOTSPOT@ Name of the hotspot which the cursor is over
@SCORE@Ã,  Ã,  Ã,  Ã, The player's current score
@SCORETEXT@Ã,  Ã, The text "Score: X of XX" with the relevant numbers filled in.
@TOTALSCORE@Ã,  The maximum possible score, specified on the Game Settings pane

Example: You have @SCORE@ out of @TOTALSCORE@ points.
The Properties window also allows you to align the text to left, right or centre, as well as change its font and colour.


I created a variable, exported and imported it into the script header. Now I want this variable to be displayed in a gui. How do I do it. From what I have tried it appears that @@ only applys to the listed variables.
Title: Re: Gui Labels
Post by: Ashen on Fri 09/07/2004 00:06:47
I think you have to use SetLabelText to display your own variables. If it's an int, you'll need StrFormat as well.
Title: Re: Gui Labels
Post by: Moox on Fri 09/07/2004 00:35:10
I get a undefined symbol error, this script is probably completely wrong


// script for room: Player enters screen (before fadein)

string HPDISP;
StrFormat (HPDISP, "%d", HP);
}

function room_e() {
// script for room: Repeatedly execute

SetLabelText(4, 0, HPDISP); 
}

function room_f() {
}


function room_i() {

  // script for room: First time player enters screen
HP=100; 
}

Title: Re: Gui Labels
Post by: Ashen on Fri 09/07/2004 00:43:53
It all needs to be in rep_ex, for some reason:

function room_e() {
// script for room: Repeatedly execute
Ã,  string HPDISP;
Ã,  StrFormat (HPDISP, "%d", HP);
Ã,  SetLabelText(4, 0, HPDISP);Ã, 
}

It doesn't like strings or int declared in other functions. I guess HP is a globally declared int?
Title: Re: Gui Labels
Post by: Moox on Fri 09/07/2004 01:33:23
I would never have goten that, Thank You.
Title: Re: Gui Labels
Post by: Pumaman on Sun 11/07/2004 00:11:59
The other solution is to declare HPDISP as a global variable so that it can be accessed from multiple functions.