Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

delete objects from root object

Dominique Laville
Registered User
Join date: 24 Apr 2008
Posts: 84
06-07-2008 00:14
is there a way to directly delete a linked object from the root ?
Something like the opposite of llRezObject.

Or should I send a linked message to the prism to delete and then the prism call llDie ?

Which are the commands to delete objects ? only llDie ?

thanks
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
06-07-2008 00:46
The only scripted methods I know of to delete/return objects is llDie() and running them off the edge of the world. llDie() works from any prim in the object (not just the root prim), but won't work from another object. Pushing the object off-world from another object might work if it is physical. That can possibly be done with llPushObject() or collisions, depending on the circumstances and luck.
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
06-07-2008 01:23
One disgusting way:

CODE

default {
touch_start (integer numdetected) {
llRequestPermissions(llGetOwner(), PERMISSION_CHANGE_LINKS);
}

run_time_permissions (integer perm) {
if (perm & PERMISSION_CHANGE_LINKS) {
llSetPrimitiveParams([PRIM_TEMP_ON_REZ, TRUE]);
llBreakLink(2);
}
}

changed(integer change) {
if (change & CHANGED_LINK) {
llSetPrimitiveParams([PRIM_TEMP_ON_REZ, FALSE]);
}
}
}


:p
_____________________
Dominique Laville
Registered User
Join date: 24 Apr 2008
Posts: 84
06-07-2008 01:53
So, the procedure is

- send the messageLinked to kil all the children
- once the children receive the message they unlink themselves from the root
- the die

right ?
is this the correct procedure ? which is the best one ?

thanks
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
06-07-2008 01:58
From: Dominique Laville
So, the procedure is

- send the messageLinked to kil all the children
- once the children receive the message they unlink themselves from the root
- the die

right ?

Yes, but wait for CHANGED_LINK (and make sure the prim is alone) before you do the llDie, unlinking can be delayed.
_____________________
Dominique Laville
Registered User
Join date: 24 Apr 2008
Posts: 84
06-07-2008 02:36
1) In the code you wrote there are 2

llSetPrimitiveParams([PRIM_TEMP_ON_REZ, TRUE]);

what they exactly do ?

2) why do you use a & condition ?

if (perm & PERMISSION_CHANGE_LINKS)

do you mean: "if a permission change and that permission is "Permission_Change_Links" then proceed" ?

thanks
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
06-07-2008 02:40
From: Dominique Laville
1) In the code you wrote there are 2

llSetPrimitiveParams([PRIM_TEMP_ON_REZ, TRUE]);

what they exactly do ?


Oh, that's maybe not what you *really* want to do =) The first one sets the object to temporary. Then when the child is broken off, both objects are temporary and will disappear on their own. The second call saves the parent from doom.

It was just a strange way to kill something remotely, maybe not so useful in your particular case because of the delay and the possible risk to the parent object. Better to put the killing in the child prim for safety sake.

From: someone
2) why do you use a & condition ?

if (perm & PERMISSION_CHANGE_LINKS)

do you mean: "if a permission change and that permission is "Permission_Change_Links" then proceed" ?


Yes, exactly!
_____________________
Dominique Laville
Registered User
Join date: 24 Apr 2008
Posts: 84
06-07-2008 02:44
ok!

two more things

1) you wrote: llRequestPermissions(llGetOwner(), PERMISSION_CHANGE_LINKS);
in the child code.

So when the child is created a request pop-up is generated ? I don't want it!

2) run_time_permissions is a state but i want to include it in the method messageLinked, because i want to send a message to the children to kill them..

mhm, there is something I don't get!
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
06-07-2008 03:04
You will need to request that permission at least once, in the parent. Here is a more realistic way to do it.

The root prim might use something like:

CODE

default
{
state_entry() {
llRequestPermissions (llGetOwner(), PERMISSION_CHANGE_LINKS);
}

run_time_permissions (integer perm) {
if (perm & PERMISSION_CHANGE_LINKS)
state murder; // allow touching
}

}

state murder {
touch_start(integer total_number)
{
llMessageLinked(2, 0, "time to die", "");
llBreakLink(2);
}
}




the child would have something like:

CODE

integer killable = FALSE;

default {
link_message(integer sender_num, integer num, string str, key id) {
// wait for the link message as a precaution, so there
// aren't any mishaps during building
if (str == "time to die") {
llOwnerSay("time to die");
killable = TRUE;
}
}

changed (integer change) {
// wait for a change in link count, then die if this is a solitary prim
if (change & CHANGED_LINK) {
if (killable) {
if (llGetNumberOfPrims() == 1) {
llDie();
}
}
}
}

}



You might also use that temporary thing in the child to help ensure it gets deleted.

(should mention that these are incomplete , just enough to play with).
_____________________