Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Mkt2015 on Wed 15/12/2004 07:19:09

Title: problem with while loop [SOLVED]
Post by: Mkt2015 on Wed 15/12/2004 07:19:09
I have to have a while loop for my sort of turn-based combat. I have it set up in the "repeatedly execute" portion of the global script.

Every time I try to have a while loop it says undefined token. I looked up token, but I'm still confused. From what the manuel said it sounds like I have to define it, but why would I have to define a while loop statement?
Title: Re: problem with while loop
Post by: strazer on Wed 15/12/2004 07:25:39
It should have said "undefined token xxx" where xxx is the word it doesn't recognize.
Please post your actual code so we can help you better.
Title: Re: problem with while loop
Post by: Mkt2015 on Wed 15/12/2004 07:39:41
It says that 'While' is undefined.

While ((HP>0) && (HP1>0))
{
  DisplayAt(200,200,100, "(f)ight/(w)eapon/(i)tem/(e)scape");
  if ((IsKeyPressed(70)==1) && (IsKeyPressed(87)==0) && (IsKeyPressed(73)==0) && (IsKeyPressed(69)==0)) {
    if (player_s > e1s) {
      int hit=Random(1);
      if (hit == 1) {
        if (equip==0) {
          Display("You hit for 10 damage with your axe.");
          HP1-=equip;}
        else {
          Display("You miss.");}
    }
    else if (player_s < e1s) {
      int hit2=Random(9);
      if (hit2 == (1 || 3 || 5 || 7 || 9)) {
        Display("The Rotweiler hit you for 15 damage.");
        HP-=e1d;}
      else if (hit2 == (0 || 2 || 4 || 6 || 8)) {
        Display("The Rotweiler missed.");}
    }
Title: Re: problem with while loop
Post by: strazer on Wed 15/12/2004 07:43:27
AGS is case-sensitive, so you have to write "while" in lowercase.
Title: Re: problem with while loop
Post by: Mkt2015 on Wed 15/12/2004 07:50:28
I feel so stupid. I suppose everyone has to have a stupid moment every now and again.
Title: Re: problem with while loop
Post by: strazer on Wed 15/12/2004 07:55:20
Hehe, don't worry, it happens to all of us. :)
Title: Re: problem with while loop
Post by: Gilbert on Wed 15/12/2004 08:28:14
I'm not quite sure of what you're going to archive, but if you want that check to happen every game loop (as you put it in repeatedly execute) you shouldn't need to use while, you can just change the while to 'if'.