FollowCharacterEx face forwards when stopped

Started by Candle, Mon 29/11/2004 07:24:37

Previous topic - Next topic

Candle

How would I make it so when he stops he will face forward ?
I have him following with FollowCharacterEx  with FollowCharacterEx(SIDE_KICK, EGO, 25, 80); but I would like him to face forward when ever he stops .

Ashen

Try this in rep_ex:
Code: ags

if ((character[SIDE_KICK].walking == 0) && (character[SIDE_KICK].loop != 0)) {
  // if SIDE_KICK isn't moveing, and isn't already facing down
  FaceLocation (SIDE_KICK, character[SIDE_KICK].x, character[SIDE_KICK].y + 20);
}
I know what you're thinking ... Don't think that.

Candle


Radiant

Create it in your global script. Like this:

Code: ags

function repeatedly_execute () {
}


Candle

Whe I added it in there it gave me a if error ?

Alynn

Check your braces... thats all I can say without seeing some code.

Ashen

Yeah, sorry, rep_ex is repeatedly_execute (specificly, the global repeatedly_excute, unless you only want this to happen in one room), I was just too lazy to type the whole thing.

What is the error exactly? As Alynn said as I was typing this, chances are it's just a problem with the braces ({ and }).
I know what you're thinking ... Don't think that.

Candle

This is the error .
---------------------------
Compile Error
---------------------------
There was an error compiling your script. The problem was in 'Global script':



Error (line 23): Nested functions not supported (you may have forgotten a closing brace)


where would that closing brace be ?

Ashen

Hard to tell without seeing the script.
Could you post the script at line 23, and a few before, so we can see what's what?
I know what you're thinking ... Don't think that.

Candle

I did a // so I could run the script for now .

Code: ags
#sectionstart repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
  // put anything you want to happen every game cycle here
//if ((character[SIDE_KICK].walking == 0) && (character[SIDE_KICK].loop != 0)) {
  // if SIDE_KICK isn't moveing, and isn't already facing down
 //FaceLocation (SIDE_KICK, character[SIDE_KICK].x, character[SIDE_KICK].y + 20);
}



#sectionend repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE


function show_inventory_window () {
  // This demonstrates both types of inventory window - the first part is how to
  // show the built-in inventory window, the second part uses the custom one.
  // Un-comment one section or the other below.
  
  // ** DEFAULT INVENTORY WINDOW
  InventoryScreen();
/*  
  // ** CUSTOM INVENTORY WINDOW
  GUIOn (INVENTORY);  
  // switch to the Use cursor (to select items with)
  SetCursorMode (MODE_USE);
  // But, override the appearance to look like the arrow
  SetMouseCursor (6);
*/
}

Ashen

#10
OK, I see it. It needs to go before the #sectionend repeatedly_executeÃ,  // DO NOT EDIT OR REMOVE THIS LINE line, like so:
Code: ags

#sectionstart repeatedly_executeÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
Ã,  // put anything you want to happen every game cycle here
Ã,  //if ((character[SIDE_KICK].walking == 0) && (character[SIDE_KICK].loop != 0)) {
Ã,  Ã,  // if SIDE_KICK isn't moveing, and isn't already facing down
Ã,  Ã,  //FaceLocation (SIDE_KICK, character[SIDE_KICK].x, character[SIDE_KICK].y + 20);
Ã,  }
} // This one right here.

#sectionend repeatedly_executeÃ,  // DO NOT EDIT OR REMOVE THIS LINE


And don't forget to un-comment the code (remove the //).
For future reference, you could use the 'Match Brace' function in the script editor ('Edit -> Match brace' or 'Ctrl-B') to check for you. I always forget about it though, which is why I didn't mention it earlier.
I know what you're thinking ... Don't think that.

Candle

I was doing some testing and need it to run and it won't with the code wrong so I did the // so it would run .
Now I get the if stuff ?

---------------------------
Compile Error
---------------------------
There was an error compiling your script. The problem was in 'Global script':



Error (line 8): Parse error: unexpected 'if'



Code: ags
// main global script file

#sectionstart game_start  // DO NOT EDIT OR REMOVE THIS LINE
function game_start() {
  // called when the game starts, before the first room is loaded
}
#sectionend game_start  // DO NOT EDIT OR REMOVE THIS LINE
if ((character[SIDE_KICK].walking == 0) && (character[SIDE_KICK].loop != 0)) {
  // if SIDE_KICK isn't moveing, and isn't already facing down
  FaceLocation (SIDE_KICK, character[SIDE_KICK].x, character[SIDE_KICK].y + 20);
}

#sectionstart repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
  // put anything you want to happen every game cycle here




#sectionend repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE



Ashen

Now the code is outside of the repeatedly_execute function, so the engine doesn't know how to deal with it - hence the 'unexpected if' error. Move it back in, so that section of code looks like this:
Code: ags

// main global script file

#sectionstart game_startÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function game_start() {
Ã,  // called when the game starts, before the first room is loaded
}
#sectionend game_startÃ,  // DO NOT EDIT OR REMOVE THIS LINE
// Code was here, for some reason.

#sectionstart repeatedly_executeÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
Ã,  // put anything you want to happen every game cycle here
Ã,  if ((character[SIDE_KICK].walking == 0) && (character[SIDE_KICK].loop != 0)) {
Ã,  Ã,  // if SIDE_KICK isn't moveing, and isn't already facing down
Ã,  Ã,  FaceLocation (SIDE_KICK, character[SIDE_KICK].x, character[SIDE_KICK].y + 20);
Ã,  }
}
#sectionend repeatedly_executeÃ,  // DO NOT EDIT OR REMOVE THIS LINE
I know what you're thinking ... Don't think that.

Candle

Thank you for taking the time to help me . sorry I was being a dumb A@@ .
It works now . I was never good at this stuff..
Thank you again .

Ashen

No problem, that's what I'm here for. Glad you got it sorted.
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk