Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Sockmonkey on Tue 21/10/2003 00:44:30

Title: Character Loop/Facing function?
Post by: Sockmonkey on Tue 21/10/2003 00:44:30
I have a question and I was unable to find an answer to it elsewhere...

Is there a command that will return a variable for the loop that the player character is in or the direction they are facing? I am trying to do a few different things, one of which is an idle animation. For example, a character scratching his head  -I would like to run one loop of this animation if the character is facing right, and another for the left. I can't find any functions that will do this, but I'm certain there must be a solution. It could be used for talking loops also...something like this:

if GetCharacterLoop ()==2 {SetCharacterIdle(EGO,12,30);}
if GetCharacterLoop ()==4 {SetCharacterIdle(EGO,13,30);}

Any help?
Title: Re:Character Loop/Facing function?
Post by: Gilbert on Tue 21/10/2003 04:38:55
character[EGO].loop
Title: Re:Character Loop/Facing function?
Post by: Sockmonkey on Tue 21/10/2003 13:58:35
Perfect. Exactly what I was looking for.

However, after the animation runs the character returns to his (0) loop  - down view - instead of the direction he was facing before...how can i fix this?
Title: Re:Character Loop/Facing function?
Post by: Ishmael on Tue 21/10/2003 14:44:54
Save the loop to a variable and restore it afterwards...
Title: Re:Character Loop/Facing function?
Post by: Sockmonkey on Tue 21/10/2003 14:48:27
Thanks TK, but I'm new to scripting ...could you go into more detail?
Title: Re:Character Loop/Facing function?
Post by: Gilbert on Wed 22/10/2003 05:13:46
On top of script:
int temploop;

Before running the animation, save the loop:
temploop=character[EGO].loop;

After the animation, restore it back:
character[EGO].loop=temploop;

(note that it's not recommended to change the character's loop manually from the manual, but using those FaceLocation() functions for this would be such a mess...)