Displaying a variable (SOLVED)

Started by Matti, Thu 31/01/2008 15:25:45

Previous topic - Next topic

Matti

Okay, this is very easy, but I just don't get it reading the manual.

I want my character to have money as a permanent Inventory item. This is no problem, but I want to display a variable for the current amount of money.

So I want to define the variable "money", set it to 5 at the beginning of the game and show it over the money-item.

Matti

I only find the display-function, which blocks animations and actions while the variable is shown in a text box. I want neither of that to happen.

Khris

Please don't double-post all the time. Somebody will answer sooner or later. To edit your post, click modify in its top right corner.

Do you want the amount to be displayed as part of the inventory item graphic? Or is it enough if there's maybe a text in the statusline saying "$: 400:"?

Matti

Sorry about the double-posting. Of course I know how to modify the post.

For I don't have a statusline it would be nicer if the amount is just written over the itempicture..

Shane 'ProgZmax' Stevens

#4
If you're not too worried about how the amount is displayed you can simply have a gui label over that particular slot (since money is a permanent fixture, it seems) and set the .Text property with the running money total whenever the amount is changed (don't have it setting the value constantly, only whenever money is gained or lost).  If you wanted to be more elaborate (have the word dollars, deutschmarks, yen after it each time) you would simply append to his running total a string holding the currency name and then set that equal to the label.Text property.  In the AGS help file you'll find a wealth of string manipulation functions to help you with this (search in particular for String.Append and String.Format).

Matti

The money should not be gained or lost in a straight order, it depends on what the main character does with it. So I definitely need to display a variable.

If you meant that too, how do I put a variable into a GUI? As I realized I can't do it like it's done with @SCORE@ for example.

Khris

This is probably one of the most numerously explained issues of all times in the whole board.
Add a label to the GUI, then use labelname.Text = String.Format("$%d", money); everytime the amount changes.

The alternative is to use a DynamicSprite as InvItem Graphic and RawDraw the text onto it. A bit more complicated, but also has definitely a higher neat-o factor ;)

SMF spam blocked by CleanTalk