Jump to content

Detecting detach?


Madi Madrigal
 Share

You are about to reply to a thread that has been inactive for 253 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

13 minutes ago, Madi Madrigal said:

I may be just missing this (I hope.)  Is there a way to detect detach of an attachment?  Not sure if it's an event you can detect or not in LSL as I cannot find anything on it.  I would like to do something in a script if someone detaches.

Thanks in advance!

Actually, yes, but if the script is in the detached object, it may or may not have enough time to do whatever useful thing you want it to do.

from inside the attachment:

default
{  attach(key ID)
   {  if(ID)
      {  llSay(0,"This object was just attached.");
      }else
      {  llSay(0,"This object was just detached.");
         // anything more placed here may or may not happen the next time this object is attached, before any other events.
      }
   }
}

for anything more complicated than saying a message, you should expect that some of the code may run during the next attach. see https://wiki.secondlife.com/wiki/Attach

From another object, you'd need to iterate through llGetAttachedList() on a timer.

Edited by Quistess Alpha
  • Thanks 1
Link to comment
Share on other sites

The attach event will be called when you detach the object - though in that scenario, the id parameter will be NULL_KEY. And like Quistess says, you will have a very limited amount of time to do anything before it's derzzed back to inventory, so don't try to do anything complicated.

Additionally, if the object was temp attached, it won't trigger the attach event on detach and will just delete itself immediately.

  • Thanks 1
Link to comment
Share on other sites

Ahhh!  I didn't think to look into the attach functionality.  I only want to change the texture on all faces on detach, so nothing crazy.  If that would fail due to timing, I have a line to set it correctly on the next attach so either way would be fine.

Thank you both so much for taking the time to reply.  😁

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 253 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...