Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Bryan_abos on Mon 28/08/2017 19:28:36

Title: 'MyCounter1'
Post by: Bryan_abos on Mon 28/08/2017 19:28:36
Hi guys.

I want to make my character to gather a couple of items (iBola and iMoney) in a room, so she can leave it. I'm using the MI style gui.
The tutorial has taken me this far.

Code (ags) Select

int myCounter1;

function hPuerta_AnyClick()
{
  if (MovePlayer(291, 119))
  player.FaceDirection(eDirectionRight);
  {
    if(UsedAction(eGA_Open)) {
      if (myCounter1 == 0)
      {
        player.Say("No me puedo ir aún. Tengo mucho que hacer.");
      }
      if (myCounter1 == 1)
      {
        player.Say("Ganaste!");
      }
      if ((player.HasInventory(iMoney)) && (player.HasInventory(iBolap)))
      {
      myCounter1 += 1;
      }
    }
  }
}


However, when open the door (open hPuerta) after I got the items (iBola and iMoney) it doesn't display the message wanted (ganaste!), but the same one
it displayed without the items.
Title: Re: undefined symbol 'MyCounter1'
Post by: Snarky on Mon 28/08/2017 19:49:56
The way you've coded it, this is what should happen:
What you probably want is simply:

Code (ags) Select
function hPuerta_AnyClick()
{
  if (MovePlayer(291, 119))
  player.FaceDirection(eDirectionRight);
  {
    if(UsedAction(eGA_Open))
    {
      if (player.HasInventory(iMoney) && player.HasInventory(iBolap))
      {
        player.Say("Ganaste!");
        // TODO: Leave room
      }
      else
        player.Say("No me puedo ir aún. Tengo mucho que hacer.");
    }
  }
}
Title: Re: undefined symbol 'MyCounter1'
Post by: Bryan_abos on Mon 28/08/2017 20:14:40
man, you are the best! :-D
Title: Re: 'MyCounter1'
Post by: Khris on Mon 28/08/2017 23:23:33
You'll also want to swap lines 4 and 5 of that snippet, I guess.