Private class functions that return a type other than "void."

Started by
2 comments, last by Hardguy 11 years, 11 months ago
I'm working within the Amnesia HPL2 engine, so this may just be a problem with the engine (though I can't really see how as the engine is based on Angelscript, but it's proabablly important to mention), but whenever I try to include private class functions that aren't of the type "void" it gives me a compile error: "ERR : Can't return value when return type is 'void'"

For example, the function:

private int ABS(int i)
{
if(i <= 0) return (-1 * i);
else return i;
}

inside of a class returns the error mentioned above when called (from a public function within the class of course).

Is there any reason why it is doing this, or are private functions of any type other than "void" not supported? The page in the AngelScript manual about private functions ( http://www.angelcode...ss_private.html )doesn't say anything against this, so I don't see why this shouldn't be allowed. I know I can get around it by using refrence peramaters, but that can get a bit obnoxious in a lot of cases.
Advertisement
Hi Satsu,

you're right. This was a bug in AngelScript.

It has already been fixed a long time ago, but Amnesia probably don't use the latest version of AngelScript, thus don't include the bug fix.

I suggest you get in touch with Frictional Games and let them know about this bug in AngelScript, so they can provide a patch for the HPL2 engine and Amnesia. If they need my help to identify what needs to be modified for the version of AngelScript that they are using I'll gladly do so.

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Ah, that makes a lot of sense then. I was pretty confused, as I couldn't really see how a bug like that could have gone by unnoticed. >_<

Thanks a lot!
What kind of sorcery is this! Classes in Amnesia Script!

More seriously, Amnesia use AngelScript very simplistically and we never used classes when creating the game. Now I got kind of curious on what you are using it for, care to share? smile.png

This topic is closed to new replies.

Advertisement