At present, it is not guarantee that your code will execute fully when running instructions in the attach event during detachment.
This can be particularly annoying — for instance, when trying to revert avatar deformations upon detachment.
Additionally, there are cases where this code may unexpectedly run during the attachment process, as it remains in the object's execution queue.
For example put this script in an object and wear it then unwear it several times:
default
{
attach(key id)
{
if (id==NULL_KEY) // DETACH
{
llOwnerSay("DETACH 1");
llSleep(0.5);
llOwnerSay("DETACH 2");
llSleep(0.5);
llOwnerSay("DETACH 3");
}
else
{
llOwnerSay("ATTACH");
}
}
}
On first ATTACH you will have these logs :
> ATTACH
On first DETACH you will have these logs :
> DETACH 1
On second ATTACH you will have these logs :
> DETACH 2
> DETACH 3
> ATTACH
The end of the "detach" code is completed on the attachment !
It would be highly beneficial if the object could delay detachment until the attach event has fully completed.