Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: beenf on Wed 08/06/2011 19:34:49

Title: [SOLVED] How can I make item work only if player reaches the hotspot
Post by: beenf on Wed 08/06/2011 19:34:49
So I have a map with a river in the middle. The hotspot is on one side of the river and player on other.
My goal is that when person is other side of the river from where hotspot is he can't use a item on it. If he tries to use it he walks straight forward to the hotspot but gets stopped by river. But if he gets to the other side of the river and uses then the item it works and magic happen.
I tried simple if player uses the item on hotspot
player.Walk(x, y);
Display("The door has opened);
But if I do that player would walk to river, be stopped by it and still show the message. I hope you smarter guys understand what I try to do here and can help me.
Title: Re: How can I make item work only if player reaches the hotspot
Post by: Matti on Wed 08/06/2011 20:14:41
Put a region on the other side of the river (where the hotspot is):

if (Region.GetAtRoomXY(player.x, player.y) == region[1]){
 player.Walk(x, y);
 Display("The door has opened");
}

else player.Walk(x, y);
Title: Re: How can I make item work only if player reaches the hotspot
Post by: beenf on Wed 08/06/2011 20:32:36
Thnx Worked ^^
Title: Re: [SOLVED] How can I make item work only if player reaches the hotspot
Post by: Matti on Wed 08/06/2011 20:51:38
Btw, you can shorten it a bit:

player.Walk(x, y);
if (Region.GetAtRoomXY(player.x, player.y) == region[1]) Display("The door has opened");