Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: acha1993 on Fri 18/01/2008 04:19:16

Title: Simple question about videos
Post by: acha1993 on Fri 18/01/2008 04:19:16
I've read the manual, but there's something I don't understand. I know the code required to insert videos into the game, but when I write the code and try to test the game AGS tells me that there is a script mistake.
My doubt is "how to insert a video that has to play when the game starts?"
Thats everything I need.

Thank You
Acha1993
Title: Re: Simple question about videos
Post by: Baron on Fri 18/01/2008 04:34:50
What is the exact script mistake (error report)?  What commands does your script contain?  What type of video are you trying to play (i.e. format - like .avi, etc.)?  You will need to post more information before you'll get much help.
Title: Re: Simple question about videos
Post by: monkey0506 on Fri 18/01/2008 04:55:55
You're probably making one of the most common of all scripting mistakes. You're most likely trying to put the code outside of all functions.

AGS doesn't accept commands outside of functions. You can define variables there, but you can't run any commands.

What you'll probably want to do is put this command in your "Player enters room (before fade-in)" event in the room script or the game_start function in the global script. However it may not properly be able to play the video before the room is loaded, so you may have to use the after fade-in event for your room.
Title: Re: Simple question about videos
Post by: acha1993 on Fri 18/01/2008 05:03:44
This is what it happens. I enter on the game_start script and I put this:

#sectionstart game_start  // DO NOT EDIT OR REMOVE THIS LINE
function game_start() {playvideo (intro.wmv, 0, 1)}

and I get this error: Undefined token: Playvideo
Title: Re: Simple question about videos
Post by: Gilbert on Fri 18/01/2008 05:14:06
The text scripts are case sensitive, it is PlayVideo().
Also, I'm not sure whether a function containing only one line code must end with a semicolon, but it's always safer to add it, so:
PlayVideo (intro.wmv, 0, 1);

HOWEVER, I never tested but I'll expect calling PlayVideo() in game_start() will probably make the game crash or ends with an error, since when game_start() is called the game environment has not been set up properly yet (game_start() is meant to be used only for simple stuff like initialising variables, etc.).

If you want to play the movie upon loading the game, put that line in the "player enters room after fade in" interaction of the room script for the starting room instead.
Title: Re: Simple question about videos
Post by: acha1993 on Fri 18/01/2008 13:31:51
Thank you very much, it worked