Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: harmonicapress on Mon 30/12/2013 22:45:21

Title: Read Letter Cutscene SOLVED
Post by: harmonicapress on Mon 30/12/2013 22:45:21
I'm trying to run a small cutscene where my character reads a letter as soon as I interact with it. I created a the letter as a room, set my characters visibility to false and tried to use ChangeRoom to make it come up, but I keep getting the watch icon then the game crashes and tells me that there is a NewRoom command already open. I poured through the forums looking for an answer for this and couldn't find an older post with the exact same issue, most were examining letters in their inventory.
Here is my code. Thanks Gurus!

Code (AGS) Select

function oLetter_Interact()
{
cSam.Walk(104, 178, eBlock, eWalkableAreas);
oLetter.Visible = false;
cSam.Say("Looks like it's from my brother J.B.");
cSam.ChangeRoom(5, 0, 0);
Wait(600);
cSam.ChangeRoom(cSam.PreviousRoom);
cSam.AddInventory(iLetter);
}
Title: Re: Read Letter Cutscene
Post by: Khris on Mon 30/12/2013 22:53:37
Here's what the manual has to say about ChangeRoom():
QuoteIMPORTANT: This command does not change the room immediately; instead, it will perform the actual room change once your script function has finished (This is to avoid problems with unloading the script while it is still running). This means that you should not use any other commands which rely on the new room (object positionings, and so on) after this command within the same function.

Basically, move everything after the first ChangeRoom to the letter room's after fadein event.

If you don't want the watch icon during the Wait(600), use mouse.Visible = false;, then turn it back to true afterwards.
Title: Re: Read Letter Cutscene
Post by: harmonicapress on Tue 31/12/2013 00:33:52
Awesome! that worked with one little hitch...when the room fades back after the letter is read, my character is gone. How can I fix that?
Title: Re: Read Letter Cutscene
Post by: Khris on Tue 31/12/2013 06:48:12
Instead of this: cSam.ChangeRoom(5, 0, 0);
Use cSam.ChangeRoom(5);

Then open the letter room and in the properties, turn ShowPlayerCharacter to false.
Title: Re: Read Letter Cutscene
Post by: Dualnames on Tue 31/12/2013 07:43:56
And if you would be so kind as to edit the first post replacing with [code =A GS] (without the space between A and G) that would be great, to help future searches of other people.
Title: Re: Read Letter Cutscene
Post by: harmonicapress on Tue 31/12/2013 19:36:42
Awesome. Thanks Khris!  The zero's in the x y coordinates were keeping my character from returning to the previous room. SOLVED!