SOLVED: Nothing happens with region[1].RunInteraction(1)

Started by Volcan, Sun 21/07/2013 18:39:34

Previous topic - Next topic

Volcan

There is two exits in bottom line and I want to go to different rooms when touching the bottom edge.

Code: AGS
function room_LeaveBottom()
{
 if (region[1].RunInteraction(1)){
  player.ChangeRoom(20, 231,  115);
 }
}


Maybe this is the wrong way to code.

geork

It sounds like you want
Code: AGS
Region.GetAtRoomXY(int x, int y)
to check whether the character is standing on the region when he crosses the bottom edge. Your code would look something like:
Code: AGS
function room_LeaveBottom()
{
 if (Region.GetAtRoomXY(player.x, player.y) == region[1]){ //if the player is on region 1...
   player.ChangeRoom(20, 231,  115);
 }
}


RunInteraction is used when you want to execute the same code that is executed when the player  stands on/walks on/walks off the region, so if you have the room function
Code: AGS
function region1_WalksOnto()
{
  //Some Code
}

Then whenever you call
Code: AGS
region[1].RunInteraction(1)

You're actually executing
Code: AGS
//Some Code

...I think anyway - I haven't ever used RunInteraction (I usually just stick things in separate functions if they are going to be used multiple time) but that's the impression the manual gives...

Hope that helps!

Volcan


johanvepa

You could simplify by not using the room_LeaveBottom function at all but simply put in two regions near the bottom of the screen and then execute player.ChangeRoom in both region_Walksonto functions.

SMF spam blocked by CleanTalk