Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: barefoot on Tue 18/01/2011 07:50:21

Title: SOLVED: Cross-eyed.... ELSE problem
Post by: barefoot on Tue 18/01/2011 07:50:21
Hi

I'm crosseyed this morning and i cant get the ELSE to work.. Rest ok..

Sorry to be a pain  ???


function cClaudia_Interact()
{
 
 if (player.HasInventory (iKey))
 {
 
 
 
  if ((cClaudia.x - cPaul.x <=90 && cClaudia.x >= cPaul.x) || (cPaul.x - cClaudia.x < 90 && cPaul.x > cClaudia.x))
   {
 
  cClaudia.FaceLocation(996, 249);
  cPaul.FaceCharacter(cClaudia);
  cPaul.Say("This place is desolate. I could mug her!!");
  Display("With an almighty punch you land a left hook on her chin and she falls down like a sack of spuds!");
  cClaudia.ChangeView(15);
  if (cClaudia.x > 299)
{
 cClaudia.StopMoving();
}


  cPaul.Say("I'de better get her out of sight!");
  Display("You drag her down a small alley");
  cPaul.Say("Mm, Credit cards, a pearl necklace and a wad of cash. That should help me a bit!!");
  Display("You leave the woman in the alley and look for more cash and stuff");
  cClaudia.Transparency=100;
 
 
  }


}

else
 {
   
   Display("She's too far away!!");
 }
}



All eagle eyed replies welcomed

cheers

barefoot


Title: Re: Cross-eyed.... ELSE problem
Post by: Unai on Tue 18/01/2011 08:10:06
Let's see if I got this right...

Your else is acting with the
if (player.HasInventory (iKey))
statement, and I think you want it to work with the distance statements.

look at this clean up:


function cClaudia_Interact()
{
  if (player.HasInventory (iKey))
{
if ((cClaudia.x - cPaul.x <=90 && cClaudia.x >= cPaul.x) || (cPaul.x - cClaudia.x < 90 && cPaul.x > cClaudia.x))
{
cClaudia.FaceLocation(996, 249);
cPaul.FaceCharacter(cClaudia);
cPaul.Say("This place is desolate. I could mug her!!");
Display("With an almighty punch you land a left hook on her chin and she falls down like a sack of spuds!");
cClaudia.ChangeView(15);
if (cClaudia.x > 299)
{
cClaudia.StopMoving();
}
cPaul.Say("I'de better get her out of sight!");
Display("You drag her down a small alley");
cPaul.Say("Mm, Credit cards, a pearl necklace and a wad of cash. That should help me a bit!!");
Display("You leave the woman in the alley and look for more cash and stuff");
cClaudia.Transparency=100;
}
}
else
{
Display("She's too far away!!");
}
}



What you need is:

function cClaudia_Interact()
{
  if (player.HasInventory (iKey))
{
if ((cClaudia.x - cPaul.x <=90 && cClaudia.x >= cPaul.x) || (cPaul.x - cClaudia.x < 90 && cPaul.x > cClaudia.x))
{
cClaudia.FaceLocation(996, 249);
cPaul.FaceCharacter(cClaudia);
cPaul.Say("This place is desolate. I could mug her!!");
Display("With an almighty punch you land a left hook on her chin and she falls down like a sack of spuds!");
cClaudia.ChangeView(15);
if (cClaudia.x > 299)
{
cClaudia.StopMoving();
}
cPaul.Say("I'de better get her out of sight!");
Display("You drag her down a small alley");
cPaul.Say("Mm, Credit cards, a pearl necklace and a wad of cash. That should help me a bit!!");
Display("You leave the woman in the alley and look for more cash and stuff");
cClaudia.Transparency=100;
}
else
{
Display("She's too far away!!");
}
}
}
Title: Re: Cross-eyed.... ELSE problem
Post by: barefoot on Tue 18/01/2011 08:21:05
Cheers Unai... back on track  :=

barefoot