Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: FanOfHumor on Thu 03/02/2022 23:02:24

Title: (SOLVED)How to script if "room before fade in" is activated from globalscript?
Post by: FanOfHumor on Thu 03/02/2022 23:02:24
      I want the game to read some script when the room changes or is just activating the event room_beforefadein for all rooms.
I tried using callroomscript but that doesn't seem to read.I know that I could just paste this script to all rooms but I would rather take a shortcut if possible.The reason I have it this way is because I need the script to run before fade in.
Code (ags) Select

function game_start()
{
 
//place character
if(CallRoomScript(eEventEnterRoomBeforeFadein))
{
if(player.Room==5)
{}
else
{
player.x=960;
player.y=1080;
}
}
}

I have also tried
Code (ags) Select


        if(player.ChangeRoom(player.Room, player.x, player.y))
{
if(player.Room==5)
{}
else
{
player.x=960;
player.y=1080;
}
}

Thanks in advance
Title: Re: How to script if the event "room before fade in" is activated from globalscript?
Post by: Crimson Wizard on Thu 03/02/2022 23:11:03
If you want something to happen anytime any room is started, there's a "on_event" function (in global script):
https://adventuregamestudio.github.io/ags-manual/Globalfunctions_Event.html#on_event

Code (ags) Select

function on_event(EventType event, int data)
{
     if (event == eEventEnterRoomBeforeFadein)
     {
           // do something
     }
}
Title: Re: How to script if the event "room before fade in" is activated from globalscript?
Post by: FanOfHumor on Thu 03/02/2022 23:25:36
Thanks I'll do that.