Khris mentioned that the expression
float side = Cuberoot(volume);
is basically a function that returns something but does not do something.
To be precise, this expression in whole is not a function. It's calling a function Cuberoot, passing "volume" as parameter, and saves returned value in a "float side".
Whether "Cuberoot" is doing something or not is not known from this code only.
Hmm, thinking this further, I believe you misinterpret what Khris said, or maybe he was not clear enough. Function that "is not doing anything" could be an obscure wording. Every function does something, otherwise there's no point to have one. I am in doubts how to explain this better. Guess, functions may be divided in the three kinds:
* ones that tell you about something - these just return some existing value, but don't do
anything else. Random example: GetGameSpeed().
* ones that calculate a value out of provided parameters, but again don't change anything. They work as a value "converter". You pass A, and get B in return. Random example: Maths.Sin().
* ones that actually do some action. They may also return something, like a success/error code, or result of a work, but not necessarily. Random example: Character.Walk().
Tha above is merely a categorization, but not a programming rule.In that case
Can be considered a function that only returns a value and does nothing, and since int defined functions can be replaced with the key word "function", it should be obvious that you can also write
instead.
Well, in proper terms this code creates a variable, not a function. Of course, you may consider a variable a variant of a function, and, perhaps, philosophically that would make sense.
Thing is, function/int substitution is not relevant at all, and should not be minded too much. In the modern AGS script "function" is declared as a "macro" (alias) which is blindly replaced with "int" by a pre-compiler anywhere you wrote it in code. This was done by CJ for ease of transition from old version of scripts into new ones. This way a person who got used to old scripts could keep writing "function" everywhere, or copy old scripts to the new game. That is - "for compatibility reasons".
This is a simple, yet not perfect solution, as declaring a "function a = 0;" makes no sense syntactically, yet works.
Even further, following also works, while making even less sense:
function MyFunc(function a, function b, function c);
you'd think that passes 3 functions into MyFunc... (but it does not)