Recursion
Recursion is a programming method in which a routine
calls itself. Recursion is an extremely powerful concept, but it can strain a
script's memory allocation. While in the recursion area of the script, you cannot specify a certain state to go to.
In this script as long as then number put in for subtractTillTwo is greater than 2, it will keep subtracting 1 until it reaches 2 as its value.
subtractTillTwo(integer value) {
if (value > 2) {
subtractTillTwo(value - 1);
} else if (value == 2) {
llSay(0, "Value is two!");
}
}
default {
state_entry() {
subtractTillTwo(35);
}
}
To determine a script's memory usage:
llGetFreeMemory
script |
memory