It's first time I try to animate an object. But I need to operate from the Global Script since it's inside a character interaction.
It gives me Undefined token oEffetto1
Here part of the code I have:
cGabbiano.UnlockView();
Wait(40);
oEffetto1.Visible = true;
oEffetto1.SetView(38);
oEffetto1.Animate(0, 4, eRepeat, eBlock, eForwards);
Wait(60);
oEffetto1.Visible = false;
aGabbiano.Play();
cGabbiano.Walk(220, 45, eBlock, eAnywhere);
I've tried using the object[0] ID but cannot find how to call from global script. I've used once to call from inside a dialog and it works but here it's the first time I face this error.
Globally, the objects are referenced with their IDs, not by their names.
cGabbiano.UnlockView();
Wait(40);
object[0].Visible = true;
object[0].SetView(38);
object[0].Animate(0, 4, eRepeat, eBlock, eForwards);
Wait(60);
oEffetto1.Visible = false;
aGabbiano.Play();
cGabbiano.Walk(220, 45, eBlock, eAnywhere);
Have you tried using the above code? Also, are you sure that the id of object oEffetto1 is ZERO (0)?
I have to check. I've tried using object[0] since I've already used for another script but maybe I've missed something.
If you use object[ID] inside a function it always search for the object inside the relative room?
Thanks for reply.
Quote from: Gabarts on Sun 15/06/2014 17:27:17
I have to check. I've tried using object[0] since I've already used for another script but maybe I've missed something.
Each created object has its own unique ID. Hence using object[0] for the object whose ID is 1 will, obviously, won't help. My example will work
only, if the ID of
oEffeto1 is ZERO (0).
Quote from: Gabarts on Sun 15/06/2014 17:27:17
If you use object[ID] inside a function it always search for the object inside the relative room?
Yes, you understood correct!
Quote from: Gabarts on Sun 15/06/2014 17:27:17
Thanks for reply.
My pleasure. :)
Thanks again for the clarification.
I simply typed Object[0] instead of object[0]. etc etc
AGS has also the auto-coding function, I could make some tries before asking for help... :-X
Anyway, I learned it.
Yeah, convention says that capital names are Class names, while variables are lowercase.
Quote from: Gabarts on Sun 15/06/2014 20:27:08
I simply typed Object[0] instead of object[0]. etc etc
It happens, Gabarts... It happens to the best of us. You're not alone. :)