LinksetIndexing
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
By Exact Name
One Name - Multiple Links | ||||||||
---|---|---|---|---|---|---|---|---|
Searches for multiple prims that share a common specific name and returns a list of linkset numbers. Otherwise an empty list if none found. <syntaxhighlight lang="lsl2"> list LinkedList(string Needle) { list Needles; integer Hay = 1; integer Stacks = llGetNumberOfPrims(); for(; Hay <= Stacks; ++Hay ) if(llGetLinkName(Hay) == Needle) Needles += Hay; return Needles; } </syntaxhighlight>
Released into public domain. By Nexii Malthus.
|
One Name - One Link | ||||||||
---|---|---|---|---|---|---|---|---|
Searches for a single prim that has a specific name. Returns 0 if not found. <syntaxhighlight lang="lsl2"> integer Linked(string Needle) { integer Prims = llGetNumberOfPrims()+1; while(--Prims) if(llGetLinkName(Prims) == Needle) return Prims; return FALSE; } </syntaxhighlight>
Released into public domain. By Nexii Malthus.
|
Multiple Names - One Link each | ||||||||
---|---|---|---|---|---|---|---|---|
Searches and replaces all strings in Needles list with integer linkset numbers, where the strings exactly match a prim name. <syntaxhighlight lang="lsl2"> list ListLinked(list Needles) { integer Prims = llGetNumberOfPrims()+1; while(--Prims) { integer Ptr = llListFindList(Needles,[llGetLinkName(Prims)]); if(~Ptr) Needles = llListReplaceList(Needles,[Prims],Ptr,Ptr); } return Needles; } </syntaxhighlight>
Released into public domain. By Nexii Malthus.
|
Multiple Names - Roll Your Own Loop |
---|
This is how I do most of my linkset indexing. A loop with if-else conditions, it is as simple as you can get. Create a global integer for each linkset you want to track and then an if-else condition to assign the linkset number to it. <syntaxhighlight lang="lsl2"> integer Foot; integer Leg; integer Torso; integer Head; LinksetInit() { integer Prims = llGetNumberOfPrims(); do { string Prim = llGetLinkName(Prims); if(Prim == "Foot") Foot = Prims; else if(Prim == "Leg") Leg = Prims; else if(Prim == "Torso") Torso = Prims; else if(Prim == "Head") Head = Prims; } while(--Prims > 1); } </syntaxhighlight>
Released into public domain. By Nexii Malthus.
|