Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: NsMn on Sun 30/08/2009 16:59:19

Title: Score "count up"?
Post by: NsMn on Sun 30/08/2009 16:59:19
Hello again,

This time, I need help with a (two) scripts which I can completely not figure out.

1. I wanted to have the score on a label to "count up" like in LSL3. The only thing I could "figure out" was how to set the text on the label. But, the real thing is only possible when it's blocking, which is very disturbin if it's about 100 points added to the score.

2. In one of SSH's modules, a text box with yes/no could be displayed - that's not something hard, but, the function that called the option window also returned the value the player selected. How is that possible?
Title: Re: Score "count up"?
Post by: Khris on Sun 30/08/2009 18:09:11
1. Use a timer to increment the displayed score by 1 every few frames & reactive it when displayed_score < actual_score.

2. Use a while loop and check for IsButtonDown && GUIObject.GetAtScreenXY.
Title: Re: Score "count up"?
Post by: Scavenger on Sun 30/08/2009 18:10:39
For the counting up for the score. Very rough, not tested, but should work.


//Put at top of global or module script.
int apparentscore = game.score;
int scoretickdelay = 20; //The amount of game loops you want to pass between counting up.

//Put this code in repeatedly_execute_always(), or add this function if you don't have one.
function repeatedly_execute_always () {
String labeltext = "Score: ";
if (IsTimerExpired(20) && apparentscore < game.score)
{
apparentscore++;
labeltext.Append ("%d",apparentscore);
GUIScorelabel.Text = labeltext;
SetTimer (20, scoretickdelay);
}
}

//put this in your on_event function, or the entire function if you haven't got one.
function on_event (EventType event, int data)
{
if (event == eEventGotScore) SetTimer (20,scoretickdelay);
}
Title: Re: Score "count up"?
Post by: NsMn on Sun 30/08/2009 20:52:48
Thanks Scavenger, it works perfectly (only that you can't set apparentscore to game.score at the beginning of the global script)