Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: FanOfHumor on Wed 30/03/2022 05:09:50

Title: (Solved)How to determine if character changes to any room.
Post by: FanOfHumor on Wed 30/03/2022 05:09:50
I don't know if I've asked this before or not but whatever the case it still isn't solved.If I could make a condition that if the character changes the room I could save much time.Is there a way to have something like.
if(player.ChangeRoom==true)
{}
Now I know this doesn't work but is there anything similar that works?
Title: Re: How to determine if character changes to any room.
Post by: Matti on Wed 30/03/2022 10:53:54
You can check if the player enters or leaves a room in the on_event (https://adventuregamestudio.github.io/ags-manual/Globalfunctions_Event.html#on_event) function in the global script.

Code (ags) Select

function on_event(EventType event, int data)
{
  if (event == eEventLeaveRoom)
  {
    // do something
  }
}


Title: Re: How to determine if character changes to any room.
Post by: FanOfHumor on Wed 30/03/2022 14:37:20
Iv'e tried that but for some reason it doesn't always recognise if they leave.Sometimes it works but sometimes it doesn't until you enter the room again and leave.
Title: Re: How to determine if character changes to any room.
Post by: Khris on Wed 30/03/2022 15:25:02
If you've already tried something, please always show your code.
Title: Re: How to determine if character changes to any room.
Post by: FanOfHumor on Wed 30/03/2022 17:24:37
I don't have access to the code anymore.I'm just gonna assume that it's just something I did wrong.Thanks anyways.