Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help needed debugging llCreateLink()

AnnMarie Otoole
Addicted scripter
Join date: 6 Jan 2007
Posts: 162
03-27-2007 22:26
I want to link the scripted object to a target that has just been rezzed by the object's script from its local "content", (or is just about to be reezzed?). I can actually link them successfully using the link tool but it is no advantage to save the linked pair because the linked object needs to be "copyable" and once I link them, no-copy restrictions in the child migrate to the parent. So I'm trying to link them once they are OUT of inventory just as I'm able to do with the link tool.

First question:- Does the target (future child) have to be rezzed before linking or can I link to its key in inventory prior to rezzing and then rez it and have it linked? (I've tried both ways and neither are working.)

Both the parent and the target are owned by me.
Permission has been set for the object. "The target doesn't require permission."
There are no restrictions on the object.
"No Transfer" restrictions exist on the target but I'm not transferring it.
Neither is attached.

They don't link and I get the error :-Script trying to link but permissions or target are invalid!

Some possible causes, not spelled out in detail in the Forums Wiki:-

Although the only restriction on the target is NoTransfer, the target contains some NC/NM scripts and it has numerous (20 to 30 primitives), many of which also contain NC/NM scripts.

The object is not physical but the target is, however that was not a problem linking with the link tool and it still didn't work when I tried it with the object physical too.

The object and some of its primitives contain scripts that are no copy, no modify but I'm not copying or modifying them by linking and again, that didn't stop linking with the link tool.

I also tried it making the target the primary and the object the child but that didn't work either (llCreateLink(Target,FALSE); )

Here is the object code:-
CODE

vector base;
key Target;
default
{
state_entry() {
llRequestPermissions(llGetOwner(),PERMISSION_CHANGE_LINKS);
llSleep(10); //Just to make sure the permission had time to click and stick
Target = llGetInventoryKey("future child");
base=llGetPos();
llRezObject("future child",base,ZERO_VECTOR,ZERO_ROTATION,0);
llCreateLink(Target,TRUE);
}
}
Anti Antonelli
Deranged Toymaker
Join date: 25 Apr 2006
Posts: 1,091
03-27-2007 22:55
From the old Wiki on llGetInventoryKey:

From: someone
This can't be stressed enough: if the object owner does not have modify, copy and transfer permissions on the inventory item being requested, then the function returns the NULL_KEY. Everything else may have partial permissions, including the object and the script, and the function will work but the inventory item being requested MUST have full permissions.
I bet you anything if you llOwnerSay the result of llGetInventoryKey on this object it's <00000-0000-000-00000 etc>

Also, even if that worked I doubt the object once rezzed would have the same key it did while it was in inventory anyway. What you want is the object_rez(key id) event, which returns the key of the newly-rezzed object to the script in the parent - just what you're looking for.

As far as permissions: I'm not at all sure llSleep is going to do anything here, since sleeping suspends the entire script in every way so when is it supposed to pick up the permissions? The "proper" way is to ask for permission, then put the rest of the code in a run_time_permissions event handler which only fires when the permissions are granted successfully, so there's never any doubt.

Hope that's some food for thought anyway.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-28-2007 01:18
You cannot link until something is rezzed, it doesnt exist so whats to link too?
Secondly the in inventory key will probably NOT be the same as the rezzed item key.
Use the object_rez event to get the key of the rezzed object and then link that.

CODE

vector base;
key Target;
default
{
state_entry()
{
llRequestPermissions(llGetOwner(),PERMISSION_CHANGE_LINKS);
llSleep(10); //Just to make sure the permission had time to click and stick
base=llGetPos();
llRezObject("future child",base,ZERO_VECTOR,ZERO_ROTATION,0);
}

object_rez(key id)
{
Target = id; // If you need it for other things
llCreateLink(Target,TRUE);
}
}


personally I wouldnt use the sleep, I'd handle the permissions request 'properly' since there is no reason to try to rez the object if permissions havent been given.
AnnMarie Otoole
Addicted scripter
Join date: 6 Jan 2007
Posts: 162
03-28-2007 06:52
Ah ha, thanks Newgate - I'm sure that is exactly what I was trying to find. I felt it had to be possible since I could do it with the Link tool.

But I've been unable to log on since upgrading to 1.14 "Unable to complete transfer: 'copy inventory to new database' Please contact [email]support@secondlife.com[/email]".

So I guess its back to RL for a while until someone finds my inventory - UGH!

(The llSleep was just a temporary diagnostic check because I was getting the error message before I could click to approve the permission so it gave me time to do that. I should have removed it from the example after it made no difference.)