Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Valentine on Sun 05/08/2007 23:21:38

Title: Repeating Functions [SOLVED]
Post by: Valentine on Sun 05/08/2007 23:21:38
Hi, I'm wondering if theres a way to tell AGS to keep repeating a series of functions until certain qualifications are met. For example (using psuedo-AGS code):

I click on 'Monitor'. (X has been set to 0).

if X is < 5, cEgo.Say("Yo.");
Set X + 1;
REPEAT.
(whereas) if X is = 5, set X to 0 and leave this interaction.

So in this case, Ego would say Yo five times. But if the player has interacted with 'Cupboard', X would have been set to 2 already, and interacting with 'Monitor' would have only caused Ego to say Yo three times.

Now I'm assuming this does not involve the Repeating Execute part of the room code, because its only initiated when the player does something specific.

Hopefully theres some advice somebody could give me  :-\.
Thanks in advance.
Title: Re: Repeating Functions
Post by: Khris on Sun 05/08/2007 23:27:54
That's what while is for.

  while (x<5) {
    player.Say("Yo.");
    x++;
  }
  x=0;
Title: Re: Repeating Functions
Post by: Valentine on Sun 05/08/2007 23:31:41
Thankyou very much  :) I'll do some reading up on it in the manual.