Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Salzi on Fri 25/01/2019 12:50:41

Title: Room Script doesn't do anything!
Post by: Salzi on Fri 25/01/2019 12:50:41
Hey guys, absolute beginner here.

I am trying to have a dialog (dDialog5) start right when the room loads.
I used this code in the room script:

Code (ags) Select

function room_AfterFadeIn()
{
  dDialog5.Start();
}


This code works when clicking on a character in this room and others, but nothing is happening when I put a command in this room directly. I tried multiple options, like:

Code (ags) Select

function room_AfterFadeIn()
{
  Speech.Style = eSpeechSierraWithBackground;
  aMusic1.Play();
  gBuch.Visible = true;
}


But none of those commands work when I start up the room.
Anyone got an idea? :-[
Title: Re: Room Script doesn't do anything!
Post by: Crimson Wizard on Fri 25/01/2019 12:53:59
First thing to check, have you just pasted this function there, or connected to real event in room Events panel?

Connecting functions with events is explained here: https://www.adventuregamestudio.co.uk/manual/acintro3.htm
Title: Re: Room Script doesn't do anything!
Post by: Salzi on Fri 25/01/2019 12:55:53
I thought about that already, but what kind of event would it be? I don't want the player to have to click on anything, I want the events to start right when the room loads - it works with starting the music etc in other rooms, just not in this one.
Title: Re: Room Script doesn't do anything!
Post by: Matti on Fri 25/01/2019 13:06:27
I think Crimson asked if you properly linked the room_AfterFadeIn()-event via the room's properties panel (instead of just copy-pasting it for example). Does it look like this:

(http://ags.pics/y5S5.png)
Title: Re: Room Script doesn't do anything!
Post by: Salzi on Fri 25/01/2019 13:20:53
Ohh thank you so much, it works now! This small thing has given me such a headache! :-D
Title: Re: Room Script doesn't do anything!
Post by: ManicMatt on Fri 25/01/2019 15:41:43
Just incase you haven't realised this, there's no need to type in the room function code room_AfterFadeIn and so on. The first time you need it, click on those dots (...) and ags will automatically generate the required code for you to type your script events into and jump to the room script page. If you already have the function code in place, ags will just jump to the room function code already in place, which is handy to quickly find that part of the code.

Its best imo to get into this habit because then you won't ever forget to enter the code in the properties panel.