User Tools

Site Tools


hpl2:amnesia:script_language_reference_and_guide:funcions_-_part_1

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
hpl2:amnesia:script_language_reference_and_guide:funcions_-_part_1 [2012/12/30 01:27]
thegreatcthulhu [Discussion]
hpl2:amnesia:script_language_reference_and_guide:funcions_-_part_1 [2013/01/14 20:16] (current)
thegreatcthulhu Func_ions --> LOL
Line 1: Line 1:
-====== ​Funcions ​- Part 1: The Basics ======+====== ​Functions ​- Part 1: The Basics ======
  
 ---- ----
Line 109: Line 109:
  
 If you visit the [[hpl2:​amnesia:​script_functions|Engine Scripts]] page, you'll see that all the predefined functions over there are listed as function declarations. If you visit the [[hpl2:​amnesia:​script_functions|Engine Scripts]] page, you'll see that all the predefined functions over there are listed as function declarations.
 +
 +<note tip>​Function parameters are also called //function arguments//​.</​note>​
  
 === Calling a Function === === Calling a Function ===
Line 153: Line 155:
 float calculationResult = Calculate(min,​ max, RandFloat(0.0f,​ 1.0f)); float calculationResult = Calculate(min,​ max, RandFloat(0.0f,​ 1.0f));
 </​code>​ </​code>​
 +
 +<note tip>
 +**The Scope of Function Parameters**
 +
 +Function parameters are associated with the function body, as if they were variables declared inside it. Thus, function parameters - the variables in the declaration - are local in scope, that is, they are visible (usable) only from within the function itself.
 +
 +When variables are used in a //function call// as input parameters, these input variables, and their names, are external to the function (and are generally not visible to it); it is //the data// they contain that gets passed in, not their names. The data values, upon entering the function they were passed to, //become assigned// to the corresponding names in the parameter list.
 +</​note>​
  
 === Where to Make the Call From? === === Where to Make the Call From? ===
Line 177: Line 187:
 // are custom, and are omitted from this snippet. // are custom, and are omitted from this snippet.
 </​code>​ </​code>​
 +
 +<note tip>If you haven'​t read Part 2, ignore the strange "&​in"​ qualifiers for now.</​note>​
  
 Just by looking, you can tell, judging by the name OnCollideArea_DramaticEvent(),​ that this function is called when the Player collides with a specific script area, and that this function initiates some in-game dramatic event: first it takes control from the player, then it calls another function that animates the camera, and another to start music, and yet another to make the player loose all of the items. (Maybe the ground gave way, and the Player fell into a river! The exact details are not relevant, the important thing is that you can get a pretty good idea of what is the function supposed to do just by looking at it.) Just by looking, you can tell, judging by the name OnCollideArea_DramaticEvent(),​ that this function is called when the Player collides with a specific script area, and that this function initiates some in-game dramatic event: first it takes control from the player, then it calls another function that animates the camera, and another to start music, and yet another to make the player loose all of the items. (Maybe the ground gave way, and the Player fell into a river! The exact details are not relevant, the important thing is that you can get a pretty good idea of what is the function supposed to do just by looking at it.)
hpl2/amnesia/script_language_reference_and_guide/funcions_-_part_1.1356830852.txt.gz ยท Last modified: 2012/12/30 01:27 by thegreatcthulhu