Player HasInventory yet ends up going to else statement

Started by barefoot, Mon 11/01/2010 10:48:19

Previous topic - Next topic

barefoot

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...


Code: ags


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

Code: ags

}

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
I May Not Be Perfect but I Have A Big Heart ..

ThreeOhFour

I'd say this is because the player.ChangeRoom command isn't actually linked to that else statement.

Try this:

Code: ags


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);
  }
}


barefoot

Thanks Ben

Miscoded.. it happens i suppose..

thanks again

barefoot
I May Not Be Perfect but I Have A Big Heart ..

SMF spam blocked by CleanTalk