To add to what others have said - just a quick info on how to read script function "definitions" at the
Engine Scripts page, so that you know how to use them in a script. As you know, some functions take one or more input parameters (which are those things between '(' and ')', right after the name of the function), like the FadeOut function you asked about.
void FadeOut(float afTime);
The meaning of all that is:
returnType FunctionName(parameterType parameterName);
Or, to connect the two:
- returnType = void --> it just means that the function doesn't return any result value (see below)
- FunctionName = FadeOut --> what you type in to use the function in your script
- parameterType = float --> tells you that the parameter accepts decimal numbers (see below)
- parameterName = afTime --> just some descriptive name for the parameter, so that you can know what it is for; in your scripts, you pass in actual values (like "3.14"), or variables.
You never type in the returnType when you call (use) a function. So, as you've already seen, to call FadeOut, you'd do something like this:
Some functions can return a value which you can then use for something else - you'll recognise them on the Engine Scripts page by the fact that there's something other than "void" in front of them. For example:
float RandFloat(float afMin, float afMax);
You can use this function to get a random number between alMin and alMax. Also, note that this function takes
two parameters, both of which are of type float. So, to make the call, you would write:
This would return a random decimal number between 1 and 10, but that number has to go somewhere to be useful. Think of this function call as a place from which its result (the generated random number) flows out - with that in mind you can use it in place of a parameter to, say, FadeOut:
FadeOut(RandFloat(1, 10));
This is the same as before, except that now the result of RandFloat call is passed, so sometimes it might fade out faster, sometimes slower.
Finally, there are only 4 data types you really need to be aware about in order to be able to use the engine functions - these are:
- int - integer (whole) numbers (like 1, 5, -2, 256, 1000000)
- float - decimal numbers (like 2.0, -0.33, 3.14, 1234.567)
- string - text; raw text always in double quotes (like "ScriptArea_1", "Door_ToHall")
- bool - these are truth values; can only be either true or false
So, if there's a hypothetical function that looks like this:
void TypesDemo(float a, int b, bool c, string d);
you'd call it something like this:
TypesDemo(0.5, 256, false, "whatever");
P.S. Note that
callbacks (like Script_VisionTrigger from the code a few posts back) are functions you define yourself that are then called by the game when something of interest happens, that is, they aren't function calls - this is why you see the whole "void FuncName(parameters...) {}" construct with them.
To get a better grasp of how the game and a map script work together, and to have a better idea about where to put what, see
this .