Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: barefoot on Mon 11/01/2010 10:48:19

Title: Player HasInventory yet ends up going to else statement
Post by: barefoot on Mon 11/01/2010 10:48:19
Hi..

When coming off an island where the player has got ichest2 (can't leave until he has got it) I have the following problem:

For some reason the below function is displaying Character.Say but then jumps to Else statement and changes Room .    I have double checked player has ichest2 so it should just have player say that he has eveything he needs.

The function is activated by a region.

Other similar functions i have seem to work ok...




function region1_WalksOnto()

{
if(player.HasInventory(ichest2))
{
 cRedpants.Say("I think we've got everything I need from here");

}
   else cRedpants.Say("You approach Rot Island");
 player.ChangeRoom(15, 44, 441);
}






Where character get ichest2


}

function olockc_UseInv()
{
if(player.ActiveInventory == iscissors) //or whatever the inventory name
  {
      Display("The scissors are just right to go into the Padlock hole and you twist and fiddle");
    Display("The Padlock clicks and uinlocks");
    object[2].Visible = false;
      object[4].Visible = true;
    cRedpants.Say("Yes, got it open");
    player.AddInventory(ichest2);
    Display("You drag the treasure chest out and lower it down the rope and put it onto your raft and set off");
    player.ChangeRoom(14, 487, 202);
}
     else cRedpants.Say("That's not working!");
}



barefoot
Title: Re: Player HasInventory yet ends up going to else statement
Post by: ThreeOhFour on Mon 11/01/2010 10:54:51
I'd say this is because the player.ChangeRoom command isn't actually linked to that else statement.

Try this:



function region1_WalksOnto()
{
  if(player.HasInventory(ichest2))
  {
    cRedpants.Say("I think we've got everything I need from here");
  }
  else
  {
    cRedpants.Say("You approach Rot Island");
    wplayer.ChangeRoom(15, 44, 441);
  }
}

Title: Re: Player HasInventory yet ends up going to else statement
Post by: barefoot on Mon 11/01/2010 11:07:54
Thanks Ben

Miscoded.. it happens i suppose..

thanks again

barefoot