Rez, then Link?
|
|
Adam Ramona
Registered User
Join date: 5 Jan 2005
Posts: 56
|
03-04-2007 02:57
I'm confused. If I want to rez object B from the inventory of object A, then link objects A and B, how do I do that? I tried this: touch_start(integer total_number) { string objectName = llGetInventoryName(INVENTORY_OBJECT,0); key myKey = llGetInventoryKey(objectName); llRezObject(objectName,llGetPos()+<2,2,2>,ZERO_VECTOR, ZERO_ROTATION, 42); llCreateLink(myKey, TRUE); }
But it doesn't work. I thought perhaps I need llRequestPermissions, but I don't understand how that works, or (if indeed a dialog needs to be clicked by an agent) how it could be of any use if it requires mouse clicking by an agent. Any help most appreciated. Adam
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
Not sure about it but ...
03-04-2007 03:14
From: Adam Ramona I'm confused. If I want to rez object B from the inventory of object A, then link objects A and B, how do I do that? I tried this: touch_start(integer total_number) { string objectName = llGetInventoryName(INVENTORY_OBJECT,0); key myKey = llGetInventoryKey(objectName); llRezObject(objectName,llGetPos()+<2,2,2>,ZERO_VECTOR, ZERO_ROTATION, 42); llCreateLink(myKey, TRUE); }
But it doesn't work. I thought perhaps I need llRequestPermissions, but I don't understand how that works, or (if indeed a dialog needs to be clicked by an agent) how it could be of any use if it requires mouse clicking by an agent. Any help most appreciated. Adam I think you need to handle the object_rez event. This gives you the key of the last rezzed object, not the inventory object, they are not the same. touch_start(integer total_number) { string objectName = llGetInventoryName(INVENTORY_OBJECT,0); key myKey = llGetInventoryKey(objectName); llRezObject(objectName,llGetPos()+<2,2,2>,ZERO_VECTOR, ZERO_ROTATION, 42); } object_rez(key id) { llCreateLink(id, TRUE); }
|
|
Adam Ramona
Registered User
Join date: 5 Jan 2005
Posts: 56
|
03-04-2007 03:39
Thanks Newgate, that certainly seems like it should work, but it's giving a permissions error: "Script trying to link but PERMISSION_CHANGE_LINKS permission not set!".
The way I understand requesting permissions, it would require an agent to click on a dialog before a link could take place, is that correct?
|
|
Jopsy Pendragon
Perpetual Outsider
Join date: 15 Jan 2004
Posts: 1,906
|
03-04-2007 04:21
From: Adam Ramona The way I understand requesting permissions, it would require an agent to click on a dialog before a link could take place, is that correct?
Definitely. And, if you use your imagination a bit... you'll see that the dialog confirmation for granting link permission is nearly just as necessary (and being very cautious about granting) as debit permissions. 
|
|
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
|
03-04-2007 06:28
From: Adam Ramona Thanks Newgate, that certainly seems like it should work, but it's giving a permissions error: "Script trying to link but PERMISSION_CHANGE_LINKS permission not set!".
The way I understand requesting permissions, it would require an agent to click on a dialog before a link could take place, is that correct? Luckily it's only required once though (when the script is reset or changes owner).
|
|
Adam Ramona
Registered User
Join date: 5 Jan 2005
Posts: 56
|
03-05-2007 03:17
From: Jopsy Pendragon Definitely. And, if you use your imagination a bit... you'll see that the dialog confirmation for granting link permission is nearly just as necessary (and being very cautious about granting) as debit permissions.  I can't quite see how it could be dangerous for an object that I own to link to another object I own, especially when it's rezzed from the inventory of the first. Perhaps I'm missing something. Here's my logic. I want to rez (lots of) objects from the inventory of object A, then link them so that object A can send link_messages to the rezzed objects. But, I want this to happen without my being there, and I want to do it this way to avoid using lots of llListens. It's like a tree spawning a leaf, then it wants to communicate with the leaf to tell it things like "it's spring, turn green" etc.
|
|
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
|
03-05-2007 09:41
Have your script request PERMISSION_CHANGE_LINKS once, in default state_entry. Then, in run_time_permissions, if permission to change links is not granted, have it go into a "disabled" state, in which it will do nothing but reset when touched (and thus, request link permission again ). Or, conversely, only have it go into an "enabled" state only if link permission is granted, with the reset-on-touch being part of the default state.
In either case, this prevents the needlessly more computationally expensive method of checking for link permission each time a new object is to be rezzed and linked, since it prevents the situation from ever arising if that condition is not met to begin with.
|
|
Jopsy Pendragon
Perpetual Outsider
Join date: 15 Jan 2004
Posts: 1,906
|
03-05-2007 10:22
From: Adam Ramona I can't quite see how it could be dangerous for an object that I own to link to another object I own, especially when it's rezzed from the inventory of the first. Perhaps I'm missing something. Here's my logic. I want to rez (lots of) objects from the inventory of object A, then link them so that object A can send link_messages to the rezzed objects. But, I want this to happen without my being there, and I want to do it this way to avoid using lots of llListens. It's like a tree spawning a leaf, then it wants to communicate with the leaf to tell it things like "it's spring, turn green" etc. If permission to link objects owned by the same owner were enabled by default, someone could sell/give-away objects that attempt to link to the recipient's house, or anything else modable by within range, and tamper or delete it. Rather an undesirable vulernerability, which is why there's the request for permissions.
_____________________
* The Particle Laboratory * - One of SecondLife's Oldest Learning Resources. Free particle, control and targetting scripts. Numerous in-depth visual demonstrations, and multiple sandbox areas. - Stop by and try out Jopsy's new "Porgan 1800" an advanced steampunk styled 'particle organ' and the new particle texture store!
|
|
Hippyjim Starbrook
Greenpeace Activist
Join date: 15 Dec 2006
Posts: 24
|
03-09-2007 15:27
Thanks for the responses so far - they've told me I'm not misunderstanding! I've got the following script: default { state_entry() { llRequestPermissions(id, PERMISSION_CHANGE_LINKS); }
touch_start(integer total_number) { if (llDetectedKey(0) == llGetOwner()) { llDialog(llDetectedKey(0),"Pick an option. Choose 'Add' to add a new prim.",["Add"],channel); llListen(channel,"", llGetOwner(),""); } } listen(integer chan, string name, key id, string mes) { if (mes == "Add") { llRezObject("inventoryItem", llGetPos()+<0,0,0.5>, <0,0,0>, <0,0,0,0>, 0); } } object_rez(key id) { llCreateLink(id, TRUE); llSay(0, "I made an item and its key is " + id); } }
I then put this in "inventoryItem" : default { state_entry() { llSay(0,"My key is" + (string) llGetKey()); } }
The rezzer says one key, the inventoryItem says another! And no, they don't link. Any ideas?
|
|
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
|
03-09-2007 23:44
If you take out the bugs that stop it compiling that code works for me. You should have a timer to remove the listen though. integer listen_id;
default { state_entry() { llRequestPermissions(llGetOwner(), PERMISSION_CHANGE_LINKS); }
touch_start(integer total_number) { if (llDetectedKey(0) == llGetOwner()) { llDialog(llDetectedKey(0),"Pick an option. Choose 'Add' to add a new prim.",["Add"],12); listen_id=llListen(12,"", llGetOwner(),""); llSetTimerEvent(30); } } listen(integer chan, string name, key id, string mes) { if (mes == "Add") { llRezObject("inventoryItem", llGetPos()+<0,0,0.5>, <0,0,0>, <0,0,0,0>, 0); } } object_rez(key id) { llCreateLink(id, TRUE); llSay(0, "I made an item and its key is " + (string)id); } timer() { llListenRemove(listen_id); llSetTimerEvent(0.0); } }
|
|
Hippyjim Starbrook
Greenpeace Activist
Join date: 15 Dec 2006
Posts: 24
|
03-10-2007 09:40
Ok, thanks for the suggest, but this is freaking me out - I copied your script exactly into a new prim, and added a prim called "inventoryItem" into it.
The inventoryItem rezzes, but doesn't link!
Could it be something to do with the sim I'm in?
|
|
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
|
03-10-2007 09:45
It's possible, I guess. Try it in another sim you know is running well.
|
|
Hippyjim Starbrook
Greenpeace Activist
Join date: 15 Dec 2006
Posts: 24
|
03-10-2007 09:56
Yeah, it was the sim - i tried it elsewhere and it was fine. Thanks for the help 
|