Add an alternative to 'llGetLinkNumber' that allows you to specificy a link name as an argument.
tracked
Kinda Vile
Hard coding link numbers into scripts is usually bad practice. So it's often best to search for something more concrete like the name of a linked prim and assign it to an integer using a loop by using llGetLinkName and comparing it to the link name you want to find. This isn't very friendly to new scripters who want to work with linked prims.
A function that checks all of the prims in a linkset and finds the first instance of a specified link name would make scripts like this much easier.
If I wanted to find the first instance of 'door left' in a linkset this could look like; llFindLinkNumber("door left");
Log In
Maestro Linden
tracked
WolfGang Senizen
About a third of the time I use a pool of prims with name x
So maybe 2 functions, something like
integer llGetFirstLinkNumberByName(string name_regex);
list llGetLinkNumbersByName(string name_regex);
The methods could maybe be made more generic, and take more parameters to allow testing for properties other than name...
SamanthaTekcat Resident
Instead of having it return an integer, why not a list of all matching link numbers?
dantia Gothly
SamanthaTekcat Resident Because Loops are slow, having it return a direct value would be faster.
SL Feedback
Merged in a post from dantia Gothly:
Title: New LSL integer llGetLinkIndex(string Link_Name);
Details: Please add this function into LSL.
Currently, performing tasks that rely on link names in a linkset requires iterating through the entire set. This is less than ideal, as link numbers in a linkset are prone to change during edits, making hard-coded link indices unreliable.
To address this, we propose a function that retrieves the integer index of a child link based on its name with a single call. This would significantly reduce the need for iterative loops, streamlining common operations.
In cases where multiple child links share the same name, the function should handle this scenario gracefully by either returning the index of the first matching instance, raising an error, or implementing a mechanism to support both outcomes.
MythElyrynn Starforge
This would change my life in scripting, and also allow for much smoother running and lighter weight scripts, I believe. This would be among the most handy functions I can think of, at current. Especially if I can use link name to pull back the link that is named such and use that information to apply certain things like particle effects, materials, sounds, etc. using the link NAME instead of the number.
This would solve a big issue, as well, regarding how link numbers change drastically when you add or subtract a link from the set. This would help you not have to reset all the link numbers every time you change the link set.
PLEASE do this, LL!