|
Arad Alter
The Wold is Yours !
Join date: 8 Apr 2008
Posts: 8
|
04-10-2008 04:07
Hi
How we can remove child prims after rezzing (Created by llRezObject) ?! I think, I need to add an script in each child prim before rezzing and use Link_message and call llDie() !?!
Is there any better way ?
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
04-10-2008 10:02
Your question is a little unclear. Do you want to destroy an object you rezzed with llRezObject(), or do you want to rip it apart and destroy some of the prims used to construct it? If you want to destroy the whole rezzed object, llDie() should work fine (but I'm not sure what you mean about link messages; if you want the object that rezzed it to tell it to die, you're going to need some kind of chat interface not link messages).
If you want to unlink and delete some of the child prims of the rezzed object, it'll take some more work. You'll need to use llBreakLink() or llBreakAllLinks(), and that requires you obtain the PERMISSION_CHANGE_LINKS permission. I believe that will require that either the owner be present in the sim or that the permission is granted (to that owner I think...) before the object is stuffed into the rezzer. The permission also apparently can't be granted to a script in a child prim, so unless you want to construct the object after permissions have been granted, you'll need to make the call to break the link(s) from the root prim. This might be where your link message comes in; if a script in the child prim is the one that decides the child prim needs to be unlinked, it'll need to communicate to something in the root prim. Once the child prim has been unlinked a script inside that unlinked (former child) prim will have to call llDie(). That could be done as part of a larger script that handles the above logic and link messages, or it could be a pretty dumb script that just responds to a 'changed' event with the CHANGED_LINK flag and a new llGetLinkNumber() of zero (indicating a stand-alone prim).
NOTE: I would suggest instead of the latter mess of an implementation that you consider simply rezzing multiple objects, and having some of them llDie() when appropriate. It may take some logic for placement (in either the rezzer or the rezzed object), and maybe some hacks to get around script delay if timing is an issue, but it gets around the permission problems.
|
|
Arad Alter
The Wold is Yours !
Join date: 8 Apr 2008
Posts: 8
|
04-10-2008 11:08
I want to unlink and delete all of child prims of the rezzed object, because changing child prim position and shape after rezzing is too hard, I prefer to delete all results and start again by calling llRezObject however I would have a bad delay.
I obtained required permission before linking. as you know calling llDie() in main object (root prim) cant remove child prims. it seams, to remove all child prims we need to add script to the object before rezzing but do u know any way that help me delete child prims inside root prim script without any secondary script in child prims?
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
04-10-2008 14:52
No. There is no way that I know of. You could make them invisible, or maybe make them tiny and hide them inside the root prim. Unfortunately, I believe a script has to have permission from the CURRENT owner in order to change links, so you'd have to have a new owner rez the object, accept permissions, then replace it in the rezzing object. If I'm wrong about that, I welcome correction. Ignoring that issue for the moment, you could do this (NOTE: not yet compiled; may require minor syntactic corrections): root prim script: default { state_entry() { llRequestPermissions(llGetOwner(), PERMISSION_CHANGE_LINKS); }
on_rez(integer startParam) // or use another event if appropriate { if (llGetPermissions() & PERMISSION_CHANGE_LINKS) { llBreakAllLinks(); } } }
child prims: default { changed(integer changes) { if (changes & CHANGED_LINK) { if (llGetLinkNumber() == 0) { llDie(); } } } }
|
|
Arad Alter
The Wold is Yours !
Join date: 8 Apr 2008
Posts: 8
|
04-12-2008 08:01
thanks dear friend,
Then is there any way to add script file to an object programatically?
as you said, we must add a script to rez objects, i mean is there anyway to add this script(lldie() when change) when user dragged a new object for rezzing to inventory of Rezzer (Main) object ? (the user is the owner too)
|