Recursion in IPP

The purpose I've been trying to use IPP for is to add some random talents to a generated character
I have a table which has the names and another table that has the descriptions of talents and they are linked by a lookup
id value. I can run [#{$talentId} TalentName] and [#{$talentId} TalentDescription] happily but I want to collect a bunch of ids to form the list of talents an npc has.

I use a string to hold the list of ids and pass it that list through the ForEach table (below) but I find that it conks out randomly after recursing short of the desired number of times. Anyone else tried anything similar or succeeded in such endevours?

//Expects String in the Format of "|1|7|"
// example use : [@ForEach with MethodName, |1|2|3|]
Table: ForEach
Set: Method={$1}
Set: List={$2}
[when][{$List} >> Length]>2[do][@{$Method} with [@ListHead with {$List}]][@ForEach with {$Method}, [@ListTail with {$List}]][end]

Table: ListHead
Set: seperatorIndex=[{$1} >> Substr 2 0 >> At |]
[{$1} >> Substr 2 {!{$seperatorIndex}-1}]

Table: ListTail
Set: seperatorIndex=[{$1} >> Substr 2 0 >> At |]
[{$1} >> Substr {!{$seperatorIndex}+1} 0]

Leave a Comment