| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
hpl2:tutorials:script:funcdef [2011/08/14 20:48] apjjm Tweaked position of a few comments |
hpl2:tutorials:script:funcdef [2011/08/15 01:09] (current) apjjm [Solving a basic problem with function pointers] |
||
|---|---|---|---|
| Line 153: | Line 153: | ||
| AddDebugMessage("Dawg!", false); | AddDebugMessage("Dawg!", false); | ||
| } | } | ||
| - | |||
| - | |||
| // The actual stuff that does the descision making | // The actual stuff that does the descision making | ||
| Line 160: | Line 158: | ||
| void bigFunction() { | void bigFunction() { | ||
| @outputChoice = @output1; // Initially point to output 1 | @outputChoice = @output1; // Initially point to output 1 | ||
| - | subFunction(); // Call whith 1/4 chance of changing outputChoice | + | subFunction(); // Call with 1/4 chance of changing outputChoice |
| outputChoice(); // Call whichever output has been chosen | outputChoice(); // Call whichever output has been chosen | ||
| } | } | ||
| Line 171: | Line 169: | ||
| } | } | ||
| - | void OnStart() { // Call bigFunction 20 times - notice roughly a 1/4 chance of output2? | + | void OnStart() { |
| + | // Call bigFunction 20 times - notice roughly a 1/4 chance of output2? | ||
| for(int i=0; i<20; i++) bigFunction(); | for(int i=0; i<20; i++) bigFunction(); | ||
| } | } | ||
| Line 178: | Line 177: | ||
| It's time to move onto solving a much bigger problem: Calling a random function. | It's time to move onto solving a much bigger problem: Calling a random function. | ||
| - | |||
| ==== Arrays, function pointers, and you ==== | ==== Arrays, function pointers, and you ==== | ||