error: Nested functions not supported

Started by AnasAbdin, Tue 06/09/2011 04:40:04

Previous topic - Next topic

AnasAbdin

howdy AGSers.. my game was running smoothly.. until all of a sudden one of the rooms popped this error at me (used to work just fine before):

Error message:
room35.asc(63): Error (line 63): Nested functions not supported (you may have forgotten a closing brace)

line 63 is this:
Code: ags
function room_RepExec()


and here's the whole function and its variables (don't mock my naming):
Code: ags
int inka00 = 0;
int inka01 = 0;
int inka02 = 0;
int inka03 = 0;
int inka04 = 0;
int inka05 = 0;
int dinga = 0;


function room_RepExec()
{
  if ( IsTimerExpired(1) )
  {
    mouse.EnableMode(eModeWalkto);
    dinga = 1;
  }
  if ( inka00 == 0 && dinga == 1 )
  {
    inka00 = 1;
    object[0].Move( 30 + Random(400), -40, 3, eNoBlock, eAnywhere);
  }
  if ( object[0].Y == -40 )
  {
    object[0].StopMoving();
    object[0].SetPosition(376, 240);
    inka00 = 0;
  }
  if ( inka01 == 0 && dinga == 1 )
  {
    inka01 = 1;
    object[1].Move(650, 30 + Random(400), 1, eNoBlock, eAnywhere);
  }
  if ( object[1].X == 650 )
  {
    object[1].StopMoving();
    object[1].SetPosition(262, 256);
    inka01 = 0;
  }
  if ( inka02 == 0 && dinga == 1 )
  {
    inka02 = 1;
    object[2].Move(160 + Random(300), -40, 2, eNoBlock, eAnywhere);
  }
  if ( object[2].Y == -40 )
  {
    object[2].StopMoving();
    object[2].SetPosition(360, 286);
    inka02 = 0;
  }
  if ( inka03 == 0 && dinga == 1 )
  {
    inka03 = 1;
    object[3].Move(650, 100 + Random(200), 2, eNoBlock, eAnywhere);
  }
  if ( object[3].X == 650 )
  {
    object[3].StopMoving();
    object[3].SetPosition(268, 302);
    inka03 = 0;
  }
  if ( inka04 == 0 && dinga == 1 )
  {
    inka04 = 1;
    object[4].Move(160 + Random(200), -40, 2, eNoBlock, eAnywhere);
  }
  if ( object[4].Y == -40 )
  {
    object[4].StopMoving();
    object[4].SetPosition(472, 376);
    inka04 = 0;
  }
  
  if ( inka05 == 0 && dinga == 1 )
  {
    inka05 = 1;
    object[5].Move(650, 200 + Random(150), 3, eNoBlock, eAnywhere);
  }
  if ( object[5].X == 650 )
  {
    object[5].StopMoving();
    object[5].SetPosition(184, 374);
    inka05 = 0;
  }
  if ( player.IsCollidingWithObject(object[0]) || 
       player.IsCollidingWithObject(object[1]) || 
       player.IsCollidingWithObject(object[2]) ||
       player.IsCollidingWithObject(object[3]) ||
       player.IsCollidingWithObject(object[4]) ||
       player.IsCollidingWithObject(object[5]) )
  {
    Display("Ewwh!");
    return;
  }
}


I traced all brackets... I don't think it's a bracket thingy... ...elp!

Gilbert

I just pasted this to an empty room's script (with the repeatedly execute event set accordingly) and it worked without any problems.

So, it's most probably mistakes made in other part of the scripts(such as missing brackets, yeah). You better check again the brackets of the whole room script, or post the whole script here for us to check.

monkey0506

AGS throws a "nested functions not supported" error on the line that the proposed nested function would begin, not the outer function. So if the error is on line 63 which is the beginning of the room_RepExec function, then the problem is nothing to do with the room_RepExec function itself, but the function immediately above room_RepExec.

If you go to the function immediately above and select the last brace you have in the function and then press Ctrl+B, it should highlight the matching brace. Unless the matching brace is the first brace of the function, then you've missed a brace somewhere. You can work your way backwards through the braces this way until you find where the problem is.

If you absolutely can't find it, then post that function here and we can help you out.

AnasAbdin

Thanx all, the missing bracket '}' had to be right above the function  :o

SMF spam blocked by CleanTalk