Mysterious "Nested functions not supported" -error

Started by Sakkeus, Fri 22/09/2023 11:58:04

Previous topic - Next topic

Sakkeus

Hello!

I really wouldn't bother anyone with this, except I'm at a complete loss with this problem.
 I've looked through the topics handling this issue, but they were of no help.

I get this very typical and often seen error when trying to compile my game:

Dialog 7(1): Error (line 1): Nested functions not supported (you may have forgotten a closing brace).

From what I've gathered, the problem is not with the dialogue script itself, for it has compiled succesfully before.
And in the forums someone wrote, that the error being on line 1 refers to the problem being on the part being compiled BEFORE the dialogue.

 I've done the following:
-Deleted the latest code from the dialogue script, didn't help.

-Deleted ALL the dialogue script and left only the starts and "ends":
@S
return

@1
return

@2
stop

and so forth. But this didn't help either.
The error still persisted, even though there is no actual code left!

-After this didn't work I deleted the whole dialogue causing the problem. This moved the same exact error message pointing to an other dialogue, this time number 11 (skipping dialogues 8-10), line 1. The dialogue number 11 interestingly involved the same characters as the original one causing the error, where as dialogues 8-10 didn't.

-I've searched my global script and other scripts for missing braces, " ; " -signs and brackets but since I have no idea where to start looking, it's been a wild goose chase.
Compiler often points to the right place in code, where they are missing, so I'm pretty sure this is not the case.

My code is pretty basic but there's lots of it. I'm pretty sure that I have made no code that constitutes as a nested function (as I understand it). Besides, wouldn't the compiler point to a more exact point, if this was the case?

I have always found the missing braces and brackets based on the info the error messages have given me.
This time I have no clue on where to start looking for the problem.


Does anyone have any idea of where to start looking for the problem AND what kind of a problem it could be?

Thanks in advance.



Khris

Here's what specifically causes this error:

Code: ags
function a()
{

}

function b()
{

// } is missing here

function c() {  // <--- error will point to this line

}

As you can see, the problem isn't function c but function b. The error occurs because the compiler encounters the function keyword while still being inside the unclosed function b.

I'm not sure about the order of scripts but my guess is the dialog scripts are wrapped in functions and appended to the global script.
Did you check the very last function in the global script?

Sakkeus

Quote from: Khris on Fri 22/09/2023 12:08:54As you can see, the problem isn't function c but function b. The error occurs because the compiler encounters the function keyword while still being inside the unclosed function b.

I'm not sure about the order of scripts but my guess is the dialog scripts are wrapped in functions and appended to the global script.
Did you check the very last function in the global script?

Thanks for the pointer.

My global script ends with a simple

Code: ags
function cMestari_Look()
{
cEgo.FaceCharacter(cMestari, eBlock);
Wait(20);
cEgo.Say("The foreman.");
}

That function is closed. But if the error is definitely caused by an open function in some other script, I'm going to find it. Just takes time.

Thanks.

Sakkeus

Found the problem, it was a missing closing brace in a script at the end of the dialogue number 8. Phew!
Now it works.

SMF spam blocked by CleanTalk