<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.frictionalgames.com/page?action=history&amp;feed=atom&amp;title=Hpl2%3ATutorials%3Ascript%3Afuncdef</id>
	<title>Hpl2:Tutorials:script:funcdef - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.frictionalgames.com/page?action=history&amp;feed=atom&amp;title=Hpl2%3ATutorials%3Ascript%3Afuncdef"/>
	<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=Hpl2:Tutorials:script:funcdef&amp;action=history"/>
	<updated>2026-05-04T13:47:47Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=Hpl2:Tutorials:script:funcdef&amp;diff=862&amp;oldid=prev</id>
		<title>Maintenance script: Upload from wiki</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=Hpl2:Tutorials:script:funcdef&amp;diff=862&amp;oldid=prev"/>
		<updated>2020-07-09T13:48:54Z</updated>

		<summary type="html">&lt;p&gt;Upload from wiki&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Funcdef &amp;amp; Function Pointers =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to set up and use funcdefs &amp;amp; function pointers in level scripts. The first two parts of this tutorial cover some very basic examples on use, with the last mixing arrays and function pointers to allow both calling sequences and a function at random.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Introduction to the &amp;quot;funcdef&amp;quot; statement ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The [http://www.angelcode.com/angelscript/sdk/docs/manual/doc_datatypes_funcptr.html Angelscript documentation] states that ''&amp;quot;A function pointer is a data type that can be dynamically set to point to a global function that has a matching function signature as that defined by the variable declaration.&amp;quot; '' In other words, you're making a '''type''' - something like ''int '' or ''string '' - but instead of this type's variables containing ''text'' or ''numbers'', it contains functions - or more specifically,  pointers to functions . &amp;lt;br /&amp;gt; To understand better what a function pointer is: Consider a box, and this box contains a note telling you to look in another box somewhere else - this is your function pointer, it just contains information on where to look. The other box, the one ''referenced, '' contains the actual functional information. We can use these &amp;quot;extra boxes&amp;quot; to create variables that can be called just like functions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first stage in the process, is to make the type which will used to create variables later. This type is dependant on what the signature of your function is (that is, what arguments are taken in by the function, and what is returned by the function) - Below are some example funcdef statements:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
funcdef void fdSimpleFunction(); // Used for pointers to functions which take no arguments and return no vales &lt;br /&gt;
funcdef int  fdReturningFunction(); // Used for pointers to functions which return an int and take no arguments.&lt;br /&gt;
funcdef int  fdComplexFunction(int, int);  // Used for pointers to functions which of return type int and take two ints as arguments&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Taking the top statement, here is a sample function which could later be pointed to:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;void sfHelloWorld() {   &lt;br /&gt;
    AddDebugMessage(&amp;quot;Hello World!&amp;quot;, false);  // Outputs: Hello World!&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With a function pointer type defined, and a function to point to - the next step is to make the function pointer:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
fdSimpleFunction@ functionVar;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is similar to just normal variable creation, except the &amp;quot;@&amp;quot; sign - The &amp;quot;@&amp;quot; symbol in angelscript literally means &amp;quot;Handle of&amp;quot; / &amp;quot;Address of&amp;quot;, and is just stating that our variable is a pointer. However it currently point anywhere - it literally ''&amp;quot;is null&amp;quot;''. To make it point to a function, we use an assignment statement just like a normal variable, except the &amp;quot;@&amp;quot; symbol appears again:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;// We know this line declares our functionVar&lt;br /&gt;
fdSimpleFunction@ functionVar;&lt;br /&gt;
 &lt;br /&gt;
// We now will make this point to sfHelloWorld()!&lt;br /&gt;
@functionVar = @sfHelloWorld;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This new line is making ''functionVar '' point to the address of ''sfHelloWorld'' (in other words, we just put a note in our box saying look into the specific other box for ''sfHelloWorld''). You are actually saying '''&amp;quot;set the handle of function var to the handle of sfHelloWorld&amp;quot;''' - this is why ''functionVar '' can be called just like the function, even though it is actually a variable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;// If all has gone well:&lt;br /&gt;
functionVar();&lt;br /&gt;
 &lt;br /&gt;
// Does exactly the same as:&lt;br /&gt;
sfHelloWorld();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Below is a sample map script file using the code covered in this section, make sure to be in developer mode to see the output.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;// Make the type &amp;quot;fdSimpleFunction&amp;quot;&lt;br /&gt;
funcdef void fdSimpleFunction();  &lt;br /&gt;
 &lt;br /&gt;
// Output hello world&lt;br /&gt;
void sfHelloWorld() {&lt;br /&gt;
    AddDebugMessage(&amp;quot;Hello World!&amp;quot;, false);&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
void OnStart() { &lt;br /&gt;
    // Call the function normally!&lt;br /&gt;
    AddDebugMessage(&amp;quot;Calling the function normally!&amp;quot;, false);&lt;br /&gt;
    sfHelloWorld(); &lt;br /&gt;
 &lt;br /&gt;
    // Call the function using our variable!&lt;br /&gt;
    AddDebugMessage(&amp;quot;Calling the function using the pointer!&amp;quot;, false);&lt;br /&gt;
    fdSimpleFunction@ functionVar;&lt;br /&gt;
    @functionVar = @sfHelloWorld;&lt;br /&gt;
    functionVar();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So far, all we have managed to achieve is something we could have done already! Why go through all this hassle, to just call a function we could have called anyway? The next section shows how the variable aspect of the function can be exploited to solve a basic problem.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Solving a basic problem with function pointers ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This following example can easily be solved without function pointers - however it compactly demonstrates that function pointers can point to any function with a matching signature, and gives a glimpse of what can be achieved using this.  If a function pointer can change where it points to - we can effectively make one function call actually call different things to suit what we want.  Take for example, the following two functions:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;void bigFunction() {&lt;br /&gt;
    subFunction();&lt;br /&gt;
}   &lt;br /&gt;
void subFunction() {&lt;br /&gt;
    //Implementing later...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The specification is as follows: At the end of ''bigFunction'' we want to call a function called ''output1''. However, ''subFunction'' should have a random (1/4) chance of making ''bigFunction'' call ''output2'' instead. Both the output functions are defined below:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;void output1() {&lt;br /&gt;
    AddDebugMessage(&amp;quot;Yo!&amp;quot;, false);&lt;br /&gt;
}   &lt;br /&gt;
void output2() {&lt;br /&gt;
    AddDebugMessage(&amp;quot;Dawg!&amp;quot;, false);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This problem can be solved using a function pointer. First again, the type which matches are output functions is defined:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;// Create a function definition (which is actually the same as fdSimpleFunction)&lt;br /&gt;
// Which will matches the signature of both our output functions&lt;br /&gt;
funcdef void fdOutput();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With the second step creating the variable which shall initially point to ''output1 '' at the start of ''bigFunction. '' Next we call ''subFunction '' as before, which will change the function pointer. Finally, we will call the function pointed to by the pointer:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
fdOutput @outputChoice;&lt;br /&gt;
void bigFunction() {&lt;br /&gt;
    @outputChoice = @output1;&lt;br /&gt;
    subFunction();&lt;br /&gt;
    outputChoice();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The ''subFunction'' implementation is as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;void subFunction() {&lt;br /&gt;
    if(RandInt(0, 3) == 1) &lt;br /&gt;
    {&lt;br /&gt;
        @outputChoice = @output2;  // A 1 in 4 chance of this code being reached&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Problem solved. You can test out the full code as with the previous section below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;// Create a function definition (which is actually the same as fdSimpleFunction)&lt;br /&gt;
// Which will matches the signature of both our output functions&lt;br /&gt;
funcdef void fdOutput();&lt;br /&gt;
 &lt;br /&gt;
// Our output functions &lt;br /&gt;
void output1() {&lt;br /&gt;
    AddDebugMessage(&amp;quot;Yo!&amp;quot;, false);&lt;br /&gt;
}   &lt;br /&gt;
void output2() {&lt;br /&gt;
    AddDebugMessage(&amp;quot;Dawg!&amp;quot;, false);&lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
// The actual stuff that does the descision making&lt;br /&gt;
fdOutput @outputChoice;&lt;br /&gt;
void bigFunction() {&lt;br /&gt;
    @outputChoice = @output1; // Initially point to output 1&lt;br /&gt;
    subFunction();    // Call with 1/4 chance of changing outputChoice &lt;br /&gt;
    outputChoice();   // Call whichever output has been chosen&lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
void subFunction() {&lt;br /&gt;
    if(RandInt(0, 3) == 1) &lt;br /&gt;
    {&lt;br /&gt;
        @outputChoice = @output2;    // A 1 in 4 chance of changing the function pointer&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
void OnStart() {     &lt;br /&gt;
    // Call bigFunction 20 times - notice roughly a 1/4 chance of output2?&lt;br /&gt;
    for(int i=0; i&amp;lt;20; i++) bigFunction();  &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It's time to move onto solving a much bigger problem: Calling a random function.&lt;br /&gt;
&lt;br /&gt;
=== Arrays, function pointers, and you ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We shall extend the above problem to have an arbitrary number of functions, and still manage calling one at random. To make things easier though, we will have each function called with an equal probablility. Obviously we could do a massive set of ifs, or a huge switch-case block (what if there are 100 choices? who would want to write that out that switch-case?). We shall re-use most of the code from the first section to get started, however, this time there are two new signature matching functions, giving us the following script file so far:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;// This creates a signature called &amp;quot;SimpleFunction&amp;quot;&lt;br /&gt;
// Which matches functions which take no arguments, and return nothing...&lt;br /&gt;
funcdef void fdSimpleFunction();    &lt;br /&gt;
// ...such as the following sample functions:&lt;br /&gt;
// This function will output &amp;quot;hello world&amp;quot;&lt;br /&gt;
void sfHelloWorld() {&lt;br /&gt;
    AddDebugMessage(&amp;quot;Hello World!&amp;quot;, false);&lt;br /&gt;
} &lt;br /&gt;
// This function will output how many times it has been called &lt;br /&gt;
void sfDisplayTimesCalled() {&lt;br /&gt;
    AddLocalVarInt(&amp;quot;DTC_TimesCalled&amp;quot;, 1);&lt;br /&gt;
    AddDebugMessage(&amp;quot;DisplayTimesCalled, called: &amp;quot; + GetLocalVarInt(&amp;quot;DTC_TimesCalled&amp;quot;) + &amp;quot; times&amp;quot;, false);&lt;br /&gt;
} &lt;br /&gt;
//This function will play the sound of an angry brute! &lt;br /&gt;
void sfPlayScarySound() {&lt;br /&gt;
    PlayGuiSound(&amp;quot;enemy\\brute\\notice.snt&amp;quot;, 1.0f);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The problem of calling one of the functions at random is going to be solved by making an array. Each index is going to contain one of the above functions, we just then pick a random index, and call the function at that index. This solution scales really nicely when there is are a good number of functions to call.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An array of function pointers is declared in the following code segment - note that the {} part is not required, but merely used for the sake of compact-ness, all this section does is initialise the array with some values in it already. If you are not familiar with arrays, take a scan through the [http://www.angelcode.com/angelscript/sdk/docs/manual/doc_script.html Angelscript documentation].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
fdSimpleFunction@[] simpleFunctions = { @sfHelloWorld, @sfDisplayTimesCalled, @sfPlayScarySound };&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now all is left to do is create a function that picks an index at random, and calls the function at that index:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;void callRandomSimpleFunction() {&lt;br /&gt;
    uint index = RandInt(0, simpleFunctions.length()-1);           // Pick a random index from the array&lt;br /&gt;
    fdSimpleFunction @functionToCall = simpleFunctions[index];    // Select that function&lt;br /&gt;
    functionToCall();                                             // Call that function&lt;br /&gt;
 &lt;br /&gt;
    // Note this can be simplified down to one line:&lt;br /&gt;
    // simpleFunctions[RandInt(0, simpleFunctions.length()-1)]();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We are also in a prime position to solve the problem of sequences here too, the following code will call each function in order in the array:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;void callEachFunction(string &amp;amp;in asTimerName) {&lt;br /&gt;
    uint index = GetLocalVarInt(&amp;quot;simpleFunctionIndex&amp;quot;);    // Get the index&lt;br /&gt;
    if(index&amp;gt;= simpleFunctions.length()) return;           // Don't go any further if we have called all the functions&lt;br /&gt;
 &lt;br /&gt;
    // Access, and call like before:&lt;br /&gt;
    fdSimpleFunction @functionToCall = simpleFunctions[index];&lt;br /&gt;
    functionToCall();  &lt;br /&gt;
 &lt;br /&gt;
    AddLocalVarInt(&amp;quot;simpleFunctionIndex&amp;quot;, 1);        // Increment the index, so the next function is called shortly...&lt;br /&gt;
    AddTimer(asTimerName, 1.0f, &amp;quot;callEachFunction&amp;quot;);  // Call this function again in 1 second, so the next function is called&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
One potential extension for use with sequences is making each function return a float, which can then be used as the delay time before calling the next function. The  sample script file for this section is below, don't forget to visit the OnStart routine and uncomment one of the two lines - or you won't see anything, and additional function is added to loop the ''callRandomSimpleFunction'' with a timer so it's effects can be seen easier:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;// This creates a signature called &amp;quot;SimpleFunction&amp;quot;&lt;br /&gt;
// Which matches functions which take no arguments, and return nothing.&lt;br /&gt;
funcdef void fdSimpleFunction(); &lt;br /&gt;
 // Such as these sample functions:&lt;br /&gt;
void sfHelloWorld() {&lt;br /&gt;
    AddDebugMessage(&amp;quot;Hello World!&amp;quot;, false);    // Output hello world&lt;br /&gt;
}   &lt;br /&gt;
void sfDisplayTimesCalled() {&lt;br /&gt;
    AddLocalVarInt(&amp;quot;DTC_TimesCalled&amp;quot;, 1); //Display how many times function was called:&lt;br /&gt;
    AddDebugMessage(&amp;quot;DisplayTimesCalled, called: &amp;quot; + GetLocalVarInt(&amp;quot;DTC_TimesCalled&amp;quot;) + &amp;quot; times&amp;quot;, false);&lt;br /&gt;
}&lt;br /&gt;
void sfPlayScarySound() {&lt;br /&gt;
    PlayGuiSound(&amp;quot;enemy\\brute\\notice.snt&amp;quot;, 1.0f);    // Play the sound of an angry brute!&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
// We now can create an array of these simple functions for further use.&lt;br /&gt;
fdSimpleFunction@[] simpleFunctions = { @sfHelloWorld, @sfDisplayTimesCalled, @sfPlayScarySound }; &lt;br /&gt;
 &lt;br /&gt;
// Some example uses of this: &lt;br /&gt;
// Calling a random function&lt;br /&gt;
void callRandomSimpleFunction() {&lt;br /&gt;
    uint index = RandInt(0, simpleFunctions.length()-1);           // Pick a random index from the array&lt;br /&gt;
    fdSimpleFunction @functionToCall = simpleFunctions[index];    // Select that function&lt;br /&gt;
    functionToCall();                                             // Call that function&lt;br /&gt;
 &lt;br /&gt;
    // Note this can be simplified down to one line:&lt;br /&gt;
    // simpleFunctions[RandInt(0, simpleFunctions.length()-1)]();&lt;br /&gt;
}&lt;br /&gt;
// Using a timer to call one function per second in sequence.&lt;br /&gt;
void callEachFunction(string &amp;amp;in asTimerName) {&lt;br /&gt;
    uint index = GetLocalVarInt(&amp;quot;simpleFunctionIndex&amp;quot;);    // Get the index&lt;br /&gt;
    if(index&amp;gt;= simpleFunctions.length()) return;           // Don't go any further if we have called all the functions&lt;br /&gt;
 &lt;br /&gt;
    // Access, and call like before:&lt;br /&gt;
    fdSimpleFunction @functionToCall = simpleFunctions[index]; &lt;br /&gt;
    functionToCall();&lt;br /&gt;
 &lt;br /&gt;
    AddLocalVarInt(&amp;quot;simpleFunctionIndex&amp;quot;, 1);        // Increment the index&lt;br /&gt;
    AddTimer(asTimerName, 1.0f, &amp;quot;callEachFunction&amp;quot;);  // Call this function again in 1 second&lt;br /&gt;
}&lt;br /&gt;
// Using a timer to repeatedly call a random function&lt;br /&gt;
void callRandTimer(string &amp;amp;in asTimerName) {&lt;br /&gt;
    callRandomSimpleFunction();&lt;br /&gt;
    AddTimer(asTimerName, 1.0f, &amp;quot;callRandTimer&amp;quot;);&lt;br /&gt;
} &lt;br /&gt;
void OnStart() {&lt;br /&gt;
    // Uncomment one of the following to test it out!&lt;br /&gt;
    //callEachFunction(&amp;quot;testTimer1&amp;quot;);&lt;br /&gt;
    //callRandTimer(&amp;quot;testTimer2&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Closing comments ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A quick note on an earlier point - when the function pointer is defined initially, it points nowhere (as it does if an assignment fails due to mismatching signatures). This can be tested for with the following code:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;if( functionPointer is null )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, that state of a function pointer '''is not saved when the map is - ''' there is no way to save the state of a function pointer - so keep them the same (which is fine in the case of an array - like the last example), or assume they haven't changed within the '''scope''' of the first function (E.g. the second example).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''You should now understand a little about funcdefs. Have a play around, you can use this to make sequences, callbacks, and all sorts of fun stuff. ''' &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://www.angelcode.com/angelscript/sdk/docs/manual/doc_script.html Check out the documentation at: www.angelcode.com/angelscript/sdk/docs/manual/doc_script.html]&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
		
	</entry>
</feed>