(SOLVED)How to script if "room before fade in" is activated from globalscript?

Started by FanOfHumor, Thu 03/02/2022 23:02:24

Previous topic - Next topic

FanOfHumor

      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

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
	

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

Thanks in advance

Crimson Wizard

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

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

FanOfHumor


SMF spam blocked by CleanTalk