Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: picklegreen on Thu 19/05/2011 10:45:09

Title: displaying variable (money)
Post by: picklegreen on Thu 19/05/2011 10:45:09
I am trying to use money in my game.
I have read the tutorial on variables and now understand how to add and subtract from a variable that I could call "money" or "cash".
What I now need is a way to show how much money I have in the game rather than the player have to try remembering.

I want the simplest way of doing this either in the gui or just as text on the screen.

Thanks.
Title: Re: displaying variable (money)
Post by: barefoot on Thu 19/05/2011 11:06:10
Hi

There are a number of ways.. You could have it as a label on a gui... In events pane for that label: Change text to @SCORE@ ..  you could have it as £ @SCORE@ for example.

There is also a Set maximum score in the General Tab of the game if you need it.

To award the player money use:

GiveScore (0); // score to add or subtract
SetGlobalInt (0, 0); // Index,value

The total would be updated and shown on the gui via the label.

Check these out in the manual for more info..

There are other ways others may explain to you if you are using a variable etc

barefoot


Title: Re: displaying variable (money)
Post by: Matti on Thu 19/05/2011 13:34:31
If you don't want to use SCORE but some custom variable (e.g cash), just create a label and call this whenever the amount is changing (or just put it somewhere in the repeatedly execute):


Labelname.Text = String.Format("%d", cash);
Title: Re: displaying variable (money)
Post by: picklegreen on Thu 19/05/2011 16:25:35
Thanks barefoot that's exactly what I needed, so can I use the variable commands += and -= to raise and lower the gamer score?
Title: Re: displaying variable (money)
Post by: barefoot on Thu 19/05/2011 17:02:55
Hi

Just put the amount you want to add/subtract at whatever point you want it to be (eg gaining an inventory item, clicking something... whatever...)    

GiveScore (1)  adds 1
GiveScore (5)  adds 5
GiveScore (-1) subtracts 1 etc etc

Eg


Display("You have sold your motor bike");
GiveScore (1000) ;


The label will be updated if you have it done correctly (using @SCORE@..


barefoot