Scripting Problem: Animation after ChangeRoom (SOLVED)

Started by Tadanobu, Sat 23/08/2008 09:12:48

Previous topic - Next topic

Tadanobu

Hi everyone,

I'm almost finished with the first act of my first attempt at a very short game.
I just got AGS and read through the manual and forums quite a bit, and managed to work my way past and figure out all of the solutions to all of the problems I've had so far.

The problem I have now, is this:

In my game, the floor beneath my character breaks and they fall through into a cave-like area below.
I animated that successfully, and did a room change.
Directly after the room change, I have an animation I want to use of the character laying on the ground (after having fell) and then simply stand up, and then switch back to the normal walking view.

I tried the same code I used before for the animation of the character falling through the floor, with cPlayer.Animate and the Lock/Unlock view but this time it gives me a parse error and says "unexpected cPla..."

What am I missing?
I tried to use the StartCutscene code as well, but that also gives me the parse error "unexpected.." message..

I'm sorry if the answer to this is somewhere in the open here, but the problem is, I don't really know WHAT to look for.. I've combed through everything about room changes, animations, cutscenes and just about everything else I could think of, but it's difficult when I'm not sure what to look for.
So I finally gave in and thought I'd ask for help here.  :)
I know it's going to be something small that I'm missing... or maybe something big that I really should have learned at this point..  :-[

The good news is, in search of the solution to this problem, I figured out how to do many others things I wasn't even looking for!  ;D

Anyway, I will appreciate your help, and I'll try not to bother the forum with too many "noob" questions if I can help it.  ;)

P.S. -I'm also very tired, so if if this makes no sense at all, forgive me.

Laukku

#1
AFAIK script commands put after a player.ChangeRoom command won't be run if it is in the same room script.  No room can read other rooms' scripts. You have to put the animation code in the cave-like room. :)

Something like this:

Room A script
//floor breaking animation
player.ChangeRoom (B);

Room B script (probably in "first time player enters room")
//falling and getting up animation
You are standing in an open field west of a white house, with a boarded front door.
>WIN GAME
Congratulations! You just won! You got 0 out of 500 points.

Tadanobu

#2
Quote from: Laukku on Sat 23/08/2008 10:08:02
AFAIK script commands put after a player.ChangeRoom command won't be run if it is in the same room script.  No room can read other rooms' scripts. You have to put the animation code in the cave-like room. :)

Something like this:

Room A script
//floor breaking animation
player.ChangeRoom (B);

Room B script (probably in "first time player enters room")
//falling and getting up animation


Thanks for the reply!  :)

Hmm.. Actually I had put the script in the beginning of the cave-like room..  ???

For my other animation (to fall through the floor) I just created a hotspot on the floor and used that to trigger the animation, by using the "When stand on hotspot" event.
This time, I'm not using a hotspot, I just want it to happen right after the room change.

So I think I'm missing something for the script..

After the room change, rather than just using this code:

player.LockView(4);
cAng.Animate(0, 3, eOnce, eBlock);
player.UnlockView();

(Where view 4 is my "Get Up from the floor" animation, and cAng is my character's name.)

What should I start with?  :-[



Laukku

What is the whole error message? That might help towards the solution.
You are standing in an open field west of a white house, with a boarded front door.
>WIN GAME
Congratulations! You just won! You got 0 out of 500 points.

Tadanobu

#4
Quote from: Laukku on Sun 24/08/2008 08:34:48
What is the whole error message? That might help towards the solution.


This is what I get:

Failed to save room room5.crm; details below
room5.asc(3): Error (line 3): Parse error: unexpected 'cAng'

This was my script for that:

1  // room script file
2
3  cAng.LockView(4);
4  player.Animate(0, 3, eOnce, eBlock);
5  cAng.UnlockView();
6

And when I tried other script for it, it would give the same message, except replace "cAng" with whatever was the first word I put into the script.
(I also tried StartCutscene, but it said "unexpected StartCutscene")

Basically, I think I'm missing something to get the script to perform that code..
Is it possible to just have that code at the beginning of a room?
Or does their need to be some sort of function or other line before it?

I don't know anything about code or scripting, and I'm brand new with AGS, so I don't know what do to..
And again, I don't know what to look for..  :-\




VK Dan

#5
The problem is you're not using it in a function. If you want your animation to run, you need to place the code inside a function.

For example, this should compile:
Code: ags

function DoSomething()
{
   cAng.LockView(4);
   player.Animate(0, 3, eOnce, eBlock);
   cAng.UnlockView();
}


Alternatively, if you want it to happen when you click on an object in a room, you have to put the code in the appropriate function. Take a look at the Introduction part of the help file for how to do that. (I'd link you, but the online tutorial isn't available ATM.)

Tadanobu

Quote from: VK Dan on Wed 27/08/2008 05:32:40
The problem is you're not using it in a function. If you want your animation to run, you need to place the code inside a function.

For example, this should compile:
Code: ags

function DoSomething()
{
   cAng.LockView(4);
   player.Animate(0, 3, eOnce, eBlock);
   cAng.UnlockView();
}


Alternatively, if you want it to happen when you click on an object in a room, you have to put the code in the appropriate function. Take a look at the Introduction part of the help file for how to do that. (I'd link you, but the online tutorial isn't available ATM.)

Thanks for your reply!  :)

Thank you, that is what I was missing.
I knew there probably had to be a function, but I wasn't sure which one.

I tried "DoSomething" and it ran, but it didn't play the animation, it just showed my character in one spot for a quick moment, and then jumped into the starting position.
I also tried a different view to see if it would play but it didn't.
So I tried a different function (DoOnlyOnce) and still it won't play...

I know that's not a lot of info, but do you have any idea what I might be doing wrong now?

VK Dan

You need to make sure you're calling it at the right time. From your original post, it looks like you want it to run as soon as you enter a room. For that to happen you need to put the code inside the room_Enter() function.

To make it work though, you'll need to make room_Enter() occur when your character enters the room. That info should be in the Tutorial (I can't give you anything more exact. I don't have AGS on this computer).  Once that is done, the only thing left to do is make sure that the code is doing what you want it to do. :)

Khris

You need to link the function to the room event ("after fadein" in this case).
This tutorial page explains how to do this for the "Look at" event of a hotspot.
Just select the room from the dropdown box in the first picture, then proceed as shown and it will take you to the room events.

After the function is created, put the code inside.

Tadanobu

Thanks guys!  ;D

I used the "after fadein" event and it works now.

I guess I forgot that the room itself had events..
But it would help if I learned more about scripting.

Anyway, thanks again!
I don't think I'll have another problem after this for a while..   :=

SMF spam blocked by CleanTalk