From: Perl Hallstrom
I have an object with a script. Now I want to be able to stop people from wearing this object. It should only be possible to rez it on the ground.
Is it possible to set such limitations.
Yes. Try this or something like it....
key avAttached = NULL_KEY;
default
{
on_rez (integer start_param)
{
llResetScript();
}
attach (key attached)
{
llRequestPermissions(attached, PERMISSION_ATTACH);
avAttached = attached;
}
run_time_permissions (integer perm)
{
if(perm & PERMISSION_ATTACH)
{
if (avAttached != NULL_KEY)
{
llDetachFromAvatar(); // This will detach the object and send it back to the owner's inventory
}
}
}
}
From: someone
Or is it possibe to stop the script from running when someone is wearing it.
Yes again. but I can't do it without putting a second script in the object to start it running again later. Here's the script itself....
default
{
on_rez(integer start_param)
{
llSay(0, "Hello, Avatar!"); // This is just to verify that the script has been restarted if it was stopped before.
}
attach (key attached)
{
if (attached !=NULL_KEY)
{
llOwnerSay("Script deactivated");
llSetScriptState(llGetScriptName(),FALSE);
}
}
touch_start (integer num)
{
llSay(0, "This is a test. The script is running."); // This is your test to see if it is running or not.
}
}
Then you have to add this second "restarter" script to the same object....
default
{
on_rez(integer start_param)
{
llSetScriptState("Main Script",TRUE); // Be sure you type the actual name of the first script here
}
}
From: someone
Or can I maybe detect from the script that someone is wearing the object and that the object is not on the ground.
Nope. Can't do that one. Sorry.
ETA: Ah.... Yes, I can. I took the wrong meaning from your question. As Dora said, all you have to do is ask ...
if (llGetAttached())
{
Say(0,"I'm attached!");
}