how to animate an object? My script doesn't work!

Started by Minimi, Wed 09/07/2003 22:54:25

Previous topic - Next topic

Minimi

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;
     
}
}

Barcik

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.
Currently Working On: Monkey Island 1.5

Minimi

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!

Wolfgang Abenteuer

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

Minimi


SMF spam blocked by CleanTalk