Page 1 of 1

Link Number from linked Object Name

Posted: Wed Jan 29, 2014 8:30 am
by Brayla Sana
Why isn't there a way to get a linked object's number when you know the name? did they forget?

Re: Link Number from linked Object Name

Posted: Wed Jan 29, 2014 12:03 pm
by Handy Low
Really, a function that took a prim name and returned a link number should return a list, because multiple prims can have the same name.

But if you can be sure that there's only one prim with the given name, you could have something like this:

Code: Select all

integer PrimName2LinkNumber(string Name) {
	integer PrimCount = llGetNumberOfPrims();
	integer L;
	for (L = 1; L <= PrimCount; L++) {
		if (llGetLinkName(L) == Name) return L;
	}
	return -1;	// there's no prim with that name
}

Re: Link Number from linked Object Name

Posted: Wed Jan 29, 2014 5:30 pm
by Brayla Sana
Thank you. I want to create switches that provide feedback. I'm still learning things.

Re: Link Number from linked Object Name

Posted: Wed Jan 29, 2014 6:32 pm
by Handy Low
If someone is clicking on the switch, you can get the link number of the clicked prim from llDetectedLinkNumber() within the touch event, and then the prim name (using that link number) from llGetLinkName(). I'm not sure if that helps you.

Re: Link Number from linked Object Name

Posted: Wed Jan 29, 2014 10:55 pm
by Brayla Sana
Both things were helpful. Thanks a lot!