Link Number from linked Object Name

Creating scripts
Post Reply
User avatar
Brayla Sana
Posts: 67
Joined: Wed Mar 27, 2013 7:09 pm
Has thanked: 16 times
Been thanked: 113 times

Link Number from linked Object Name

Post by Brayla Sana » Wed Jan 29, 2014 8:30 am

Why isn't there a way to get a linked object's number when you know the name? did they forget?
Dadiella's for Fashion and Brayla Sana Gallery for Building!
User avatar
Handy Low
Posts: 231
Joined: Fri Nov 08, 2013 3:38 pm
Location: Yorkshire, England
Has thanked: 207 times
Been thanked: 140 times
Contact:

Re: Link Number from linked Object Name

Post by Handy Low » Wed Jan 29, 2014 12:03 pm

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
}
These users thanked the author Handy Low for the post:
Brayla Sana
Handy Low
User avatar
Brayla Sana
Posts: 67
Joined: Wed Mar 27, 2013 7:09 pm
Has thanked: 16 times
Been thanked: 113 times

Re: Link Number from linked Object Name

Post by Brayla Sana » Wed Jan 29, 2014 5:30 pm

Thank you. I want to create switches that provide feedback. I'm still learning things.
Dadiella's for Fashion and Brayla Sana Gallery for Building!
User avatar
Handy Low
Posts: 231
Joined: Fri Nov 08, 2013 3:38 pm
Location: Yorkshire, England
Has thanked: 207 times
Been thanked: 140 times
Contact:

Re: Link Number from linked Object Name

Post by Handy Low » Wed Jan 29, 2014 6:32 pm

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.
Handy Low
User avatar
Brayla Sana
Posts: 67
Joined: Wed Mar 27, 2013 7:09 pm
Has thanked: 16 times
Been thanked: 113 times

Re: Link Number from linked Object Name

Post by Brayla Sana » Wed Jan 29, 2014 10:55 pm

Both things were helpful. Thanks a lot!
These users thanked the author Brayla Sana for the post:
Handy Low
Dadiella's for Fashion and Brayla Sana Gallery for Building!
Post Reply