Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: dgill on Wed 07/11/2007 03:27:42

Title: Display Functions
Post by: dgill on Wed 07/11/2007 03:27:42
Is there any display functions that isn't a blocking function?  I would like to display a message that remains up while the player is allowed to act.
Title: Re: Display Functions
Post by: monkey0506 on Wed 07/11/2007 04:08:35
There's no built-in function specifically for this, though you could use Character.SayBackground, a textual Overlay, or simply a GUI to produce a similar effect.

Perhaps the easiest way to provide a "display"-type message box would be to use a GUI with a Label on it and then you could set up a custom function to turn the GUI on, set the label text, and then of course some sort of timer mechanism for turning it back off.
Title: Re: Display Functions
Post by: dgill on Wed 07/11/2007 04:39:27
I thought about doing the gui thing, but the only problem is I want this text to include a variable and the gui label doesn't allow that.  My intention is to use this as an HP meter for a battle scene so I have a variable that stores their HP values.  I tried the character.SayBackground but since I have more than character in the battle and you can't change the location of where you want the text to go, it will only show one of them.  Right now I have it display the health and then it disappears and you attack and then redisplay the health.  I think that looks all right but do you have any other ideas.
Title: Re: Display Functions
Post by: monkey0506 on Wed 07/11/2007 04:54:32
You can always use the String.Format function for inserting variables into Strings!

lblMessage.Text = String.Format("Your current HP is: %d", HP);

Where lblMessage is the script o-name of your Label and HP would be the variable you've stored the player's current hit points into.

You can use String.Format anywhere you can use a String, for properties like Label.Text and also as function parameters (specifically functions that don't allow formatting themselves ;)) such as Character.SayBackground.
Title: Re: Display Functions
Post by: dgill on Wed 07/11/2007 05:37:30
Thanks. That was also of great help.
Title: Re: Display Functions
Post by: dgill on Wed 07/11/2007 06:22:03
I figured out how to get the label to work but I have a new problem.  The HP doesn't update until after both sides attack.  The user attacks through the text parser.  Here is what I am doing:

In the activate function of the text parser I display text, update the HP variables, call a function called DisplayHP, and then call a function called SailorAttack (enemy attack system)
Inside the SailorAttack  function I do the same thing - display text, update the HP of the user, then call DisplayHP
Inside the DisplayHP function is where I change the text of label - depending on who attacks changes which label gets altered.

After the first message is displayed I would like to show updated HP value of the enemy that was just attacked.  I am not sure why but it waits until the enemy attacks back and that message is displayed and updates them both at the same time.
Title: Re: Display Functions
Post by: Radiant on Wed 07/11/2007 10:57:37
As I recall, DisplayTopBar() isn't actually blocking.