Newbie Scripter

Started by George, Tue 28/12/2004 12:58:57

Previous topic - Next topic

George

Scripting is something I've been dreading for a while now, and only now have I decided to give it a whirl…
What I want the Game to do is play a simple Intro:
Fade Into Screen One… Display for a while…Fade Out….
Fade Into Screen Three…Display for a while…Fade Out…
Fade Into Screen Two (Title Screen)…

The Script is as follows for Room 1…
// room script file
FadeIn(40);
Wait(60);
FadeOut(40);
ChangeRoom (3);
FadeIn(40);
Wait(60);
FadeOut(40);
ChangeRoom (2);
FadeIn(40)

But comes up with:
Compile Error: there was an error compiling your script.
The problem was in: ‘Main Script'
Error (line 2): Parse error unexpected ‘FadeIn'
Do you want to fix the script now?

Did I write it in the wrong script spot? Didn't I specify something? I dunno… Feedback will be appreciated.
"The world is my oyster...but i don't like sea food"

Bernie

I think it's best to use the room interactions (the button with the i on it).
Add a 'run script' to 'player enters after fade in'. Double click the run script thing to edit it, then add your code.

You could set the screen transitions to fade out/in, so you don't have to use FadeIn/Out. You can change them at any time with SetScreenTransition.
If you still want to use FadeIn/Out, set the transitions to instant so the 'player enters after fade in' happens instantly when the new room is displayed.

In room 1, you'd do:

Wait(60);
NewRoom(3);

And in room 3:

Wait(60);
NewRoom(2);

RickJ

Bernie is right about the interactions.  Let me explain about them further.

AGS is what is called "event driven".  The player does something like clicking the mouse on something on the screen or pressing a key on the keyboard.   The interaction editor allows you to assign actions that are executed in response to such events.  The reason he compiler complained about your current code is that FadeIn() was not within the bounds of a function.  If it's not within the bounds of a function it won't get executed.  So you need to use the interaction editor to create interaction functions (sometimes called event handlers).

One of the options the interaction editor provides is "Run Script".   For each of the rooms setup the "Player Enters After Fadin" interaction to "Run Script".   Now when you edit the Room Script you will see an empty function that will be exeuted whenever the player enters the room.   So you would have the following scripts in the three in your example. 

Room-1 Script
#sectionstart room_a  // DO NOT EDIT OR REMOVE THIS LINE
function room_a() {
   // script for room: Player enters screen (after fadein)
   Wait(60);
   ChngeRoom(3);  
}
#sectionend room_a  // DO NOT EDIT OR REMOVE THIS LINE

Room-2 Script

#sectionstart room_a  // DO NOT EDIT OR REMOVE THIS LINE
function room_a() {
   // script for room: Player enters screen (after fadein)
   Wait(60);
   Display("Finished Intro"):
}
#sectionend room_a  // DO NOT EDIT OR REMOVE THIS LINE


Room-3 Script
#sectionstart room_a  // DO NOT EDIT OR REMOVE THIS LINE
function room_a() {
   // script for room: Player enters screen (after fadein)
   Wait(60);
   ChangeRoom(2);  
}
#sectionend room_a  // DO NOT EDIT OR REMOVE THIS LINE


For the FadeIn/Out goto GameSettings->Room Transistion Style and select  the FadeIn/Out option.  Or if you prefer to play around with this in the script select the Instant option as Bernie suggests.

Hope this helps.  Cheers ...

SMF spam blocked by CleanTalk