Change player view depending on location...(Solved)

Started by J.E.S., Tue 16/09/2008 06:10:44

Previous topic - Next topic

J.E.S.

Why does this code work...

Code: ags

function hBedroomDoor_Interact()
{
if(Character.GetAtScreenXY(90, 210)==cSlade)
{
  player.ChangeRoom(2, 200, 265);
}
else if (player.View==2)
{
  player.ChangeView(1);
  player.Walk(90, 210);
}
else
{
  player.Walk(90, 210);
}

}



But this code doesn't...

Code: ags


function hSladesCouch_Interact()
{
  if(Character.GetAtScreenXY(210, 260)==cSlade)
  {
    player.ChangeView(2); //to sit on couch
    SetWalkBehindBase(1, 200);
  }
  else
  {
    player.Walk(210, 260);
  }

}



I want the script to check the position of my character before he can sit on the couch. If he is close enough he will be able to sit on the couch when it is clicked again. This code works fine when I want to change rooms and I also like the freedom of walking without eblock.

Creator

#1
Create a region (around the couch) and when you interact with it (the couch) use:
Code: ags

function hSladesCouch_Interact() {
if (Region.GetAtRoomXY(cSlade.x, cSlade.y) == region[1]) {
   player.ChangeView(2); //to sit on couch
    SetWalkBehindBase(1, 200);
  }
  else {
    player.Walk(210, 260);
  }
}


Easiest way I could think of.

J.E.S.

Thanks Creator, that did work. I'll mark this one as solved.

SMF spam blocked by CleanTalk