Score "count up"?

Started by NsMn, Sun 30/08/2009 16:59:19

Previous topic - Next topic

NsMn

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?

Khris

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.

Scavenger

For the counting up for the score. Very rough, not tested, but should work.

Code: ags

//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);
}

NsMn

Thanks Scavenger, it works perfectly (only that you can't set apparentscore to game.score at the beginning of the global script)

SMF spam blocked by CleanTalk