Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: metalmario991 on Sat 07/02/2015 00:52:08

Title: A SCORE Gui
Post by: metalmario991 on Sat 07/02/2015 00:52:08
Excuse me but I want to have points in my game and I would like to know if and how I can but a display for it in the the options box and bar at the top of the screen.
(Also what is the name of the script function for adding the score?)
Title: Re: A SCORE Gui
Post by: Slasher on Sat 07/02/2015 04:54:34
Hi

ags has a built-in score system (though you can make your own).

Basic:

make a Lable on your gui, name it something like LPoints.

In Global asc add this in the repeatedly_execute_always:

Code (ags) Select

function repeatedly_execute_always() {
LPoints.Text=String.Format("%d",game.score)
}


To add a score simpy add: 
Code (ags) Select

GiveScore(15); //at the appropriate places in the scripts. In this case 15 points is added to the score.



Title: Re: A SCORE Gui
Post by: Vincent on Sat 07/02/2015 12:53:31
As slasher said before, you can make it easily by your own.
You should check this sections on the manual if you want to use the default one by AGS

game.score
The player's score. To modify the score, use the GiveScore script function.

game.score_sound
Sound effect to play when the player gets points, originally set in the editor.

game.total_score
Maximum possible score, initially set in the editor. 

GiveScore
Adds SCORE to the player's score. This is preferable to directly modifying the variable since it will play the score sound,
update any status lines and call the GOT_SCORE on_event function.


function on_event (EventType event, int data)

      eEventGotScore 
      called whenever the player's score changes
      DATA = number of points they got



String formatting
You will find many times in your game when you need to create a string based on the values of variables,
and functions like Display and String.Format allow you to do so.