Why does this code work...
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...
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.
Create a region (around the couch) and when you interact with it (the couch) use:
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.
Thanks Creator, that did work. I'll mark this one as solved.