Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help So many errors
CarnivorousJelly Offline
Posting Freak

Posts: 1,196
Threads: 41
Joined: Dec 2012
Reputation: 80
#11
RE: So many errors

Ohhh that's what float is. I was a little bit confused; thanks for clarifying Big Grin

[Image: quote_by_rueppells_fox-d9ciupp.png]
02-13-2013, 12:54 AM
Find
CarnivorousJelly Offline
Posting Freak

Posts: 1,196
Threads: 41
Joined: Dec 2012
Reputation: 80
#12
RE: So many errors

Fixed; sorry for the accidental thread bump.

[Image: quote_by_rueppells_fox-d9ciupp.png]
(This post was last modified: 02-14-2013, 06:00 AM by CarnivorousJelly.)
02-14-2013, 05:23 AM
Find
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#13
RE: So many errors

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.
PHP Code: (Select All)
void FadeOut(float afTime); 

The meaning of all that is:
PHP Code: (Select All)
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:
PHP Code: (Select All)
FadeOut(2.5); 

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:
PHP Code: (Select All)
float RandFloat(float afMinfloat 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:
PHP Code: (Select All)
RandFloat(110); 

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:
PHP Code: (Select All)
FadeOut(RandFloat(110)); 

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:
PHP Code: (Select All)
void TypesDemo(float aint bbool cstring d); 
you'd call it something like this:
PHP Code: (Select All)
TypesDemo(0.5256false"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 .
(This post was last modified: 02-14-2013, 01:39 PM by TheGreatCthulhu.)
02-14-2013, 01:23 PM
Find




Users browsing this thread: 1 Guest(s)