Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Touch and llDie!!!

HulkHogan Hendrassen
Registered User
Join date: 19 Feb 2009
Posts: 10
08-01-2009 08:41
I was looking for a script that when i touch the object it dies instantly. I know it isn't that hard to do but i couldn't find it on the forums! Any help would be appreciated thanks!
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
08-01-2009 08:51
Just put a llDie() inside the touch event.

touch_start(integer total_number)
{
llDie();
}
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
08-01-2009 19:03
caveat.. this won't work for attachments.

For attachments you'll need to use llDetachFromAvatar (and you'll need permissions for that too, see llRequestPermissions for more on that).
_____________________

● Inworld Store: http://slurl.eclectic-randomness.com
● Website: http://www.eclectic-randomness.com
● Twitter: @WinterVentura
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-01-2009 21:04
Here's one that should work for attachments too (hasn't been compiled; may need minor fix-ups):

CODE

detach()
{
if (llGetPermissions() & PERMISSION_ATTACH)
{
llDetachFromAvatar();
} else
{
llRequestPermissions(llGetOwner(), PERMISSION_ATTACH);
}
}

default
{
touch_start(integer nDetected)
{
state dead;
}
}

state dead
{
state_entry()
{
if (llGetAttached())
{
detach();
} else
{
llDie();
}
}

on_rez(integer startParam)
{
llDie();
}

attach(key id)
{
if (id == NULL_KEY)
{
// In case of drop in-world from viewer
llDie();
} else
{
detach();
}
}

run_time_permissions(integer perms)
{
if (perms & PERMISSION_ATTACH)
{
llDetachFromAvatar();
}
}
}