Repeating Functions [SOLVED]

Started by Valentine, Sun 05/08/2007 23:21:38

Previous topic - Next topic

Valentine

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.

Khris

That's what while is for.

Code: ags
  while (x<5) {
    player.Say("Yo.");
    x++;
  }
  x=0;

Valentine

Thankyou very much  :) I'll do some reading up on it in the manual.

SMF spam blocked by CleanTalk