Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Konador on Tue 27/07/2004 16:44:41

Title: What is wrong with this code?
Post by: Konador on Tue 27/07/2004 16:44:41
#sectionstart object4_aÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function object4_a() {
Ã,  // script for object4: Ext.modes object
if (UsedMode(PULL))
{
Display("I'll just move this over a little bit");
Wait(30);
SetCharacterView(AZ, 16);
AnimateCharacter(AZ, 2, 7, 0);
MoveObject(4, 374, 128, 3);
ReleaseCharacterView(AZ);
ObjectOn (8);Ã, 
}
else Unhandled();
}
#sectionend object4_aÃ,  // DO NOT EDIT OR REMOVE THIS LINE


No errors come up when compiling, but the character doesn't perform the animations I've put in, and the object doesn't move. What could be the reason for this?
Title: Re: What is wrong with this code?
Post by: Moox on Tue 27/07/2004 17:40:38
Use AnimateCharacterEX
Title: Re: What is wrong with this code?
Post by: Konador on Tue 27/07/2004 17:45:19
Thanks for the suggestion. I just tried it and got the same problem. The text displays, and the ObjectOn works, but the MoveObject and character actions seem to be getting skipped?
Title: Re: What is wrong with this code?
Post by: on Tue 27/07/2004 18:05:23
I haven't used ags in a while but I think you must add Wait after AnimateCharacter and MoveToObject.

AnimateCharacter(AZ, 2, 7, 0);
Wait(30); //Not exactly 30,you must calculate this.It's frames / speed or... frames x speed...I don't really remember  :-\
Title: Re: What is wrong with this code?
Post by: Moox on Tue 27/07/2004 18:08:21
AnimateCharacterEX is blocking, it should display... Try a
Wait(10);
Title: Re: What is wrong with this code?
Post by: Konador on Tue 27/07/2004 18:40:20
Thanks, the character animation works now, but the object is still not moving.
Title: Re: What is wrong with this code?
Post by: Gilbert on Wed 28/07/2004 07:40:40
if you want the character to animate first, then move the object:
AnimateCharacter(AZ, 2, 7, 0);
while (character[AZ].animating) Wait(1);
MoveObject(4, 374, 128, 3);
while (IsObjectMoving(4)) Wait(1);

OR, if you want the character to be animating and the object to be moving at the same time:
AnimateCharacter(AZ, 2, 7, 0);
MoveObject(4, 374, 128, 3);
while (character[AZ].animating||IsObjectMoving(4)) Wait(1);

That's because AnimateCharacter() and MoveObject() are both non-blocking. (unless you use AnimateCharacterEX().)

Edit: yeah radiant, hehe.
Title: Re: What is wrong with this code?
Post by: Radiant on Wed 28/07/2004 15:27:23
Yes, except that it should be while rather than if :)