Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Minimi on Wed 09/07/2003 22:54:25

Title: how to animate an object? My script doesn't work!
Post by: Minimi on Wed 09/07/2003 22:54:25
Hey, as you may know I just started with AGS... and I'm now trying to animate an object. It's a window and it is object #0. I want to make it that when I'm interacting with the window... the window much open and close. Here is my script.. what did I do wrong?

// room script file

int openclose_window = 0;

function object0_b() {
 // script for object0: Interact object

   if (openclose_window == 0) {
       SetObjectGraphic(0,36);
       openclose_window = 1;
}

   if (openclose_window == 1) {
     SetObjectGraphic(0,35);
     openclose_window = 0;
     
}
}
Title: Re:how to animate an object? My script doesn't work!
Post by: Barcik on Wed 09/07/2003 22:59:56
It should look like that.

// room script file

int openclose_window = 0;

function object0_b() {
// script for object0: Interact object

  if (openclose_window == 0) {
   SetObjectGraphic(0,36);
   openclose_window = 1;} else
  {
   SetObjectGraphic(0,35);
   openclose_window = 0;
   
}
}

You see, when the window is opened, it moves on to the next if. Since the variable is now 1 it immediately closes it, making it seem as if nothing happens.
Title: Re:how to animate an object? My script doesn't work!
Post by: Minimi on Wed 09/07/2003 23:21:21
I understand you, and I even copy pasted it, and when I click the interaction on the window the game crashes with the following error message!

Error: prepare_script: error -2 (no such function in script) trying to run 'object0_a' (room2)

Please help me... I need to make this for alot of objects.. so I need to understand it!
Title: Re:how to animate an object? My script doesn't work!
Post by: Wolfgang Abenteuer on Thu 10/07/2003 01:03:35
The game is trying to run function object0_a, and you have it set up as function object0_b so it can't find it.  Go into your room script and change the "b" to an "a" and see if that fixes it.  Otherwise, just copy all the code you have listed under the interaction (what Barcik posted as well as whatever else you had) into a .txt file, then go into the AGS editor and delete the interaction for that object entirely.  Once it's deleted, re-create the interaction, select Run Script, and then paste that code under the new function it created.  At least that way the code created by AGS will match what the game is looking for.

That's my guess, anyway.  Hopefully it helps!

~Wolfgang
Title: Re:how to animate an object? My script doesn't work!
Post by: Minimi on Thu 10/07/2003 01:18:51
tnx alot! It's working now!