CasperVend 2/Rez Clean-up script

From CasperTech Wiki
Revision as of 15:23, 2 December 2016 by D1cd5b71-6209-4595-9bf0-771bf689ce00 (talk | contribs) (Created page with "<lsl> // // Name: Rez Clean-up // Author: Casper Warden // License: Attribution 4.0 International (https://creativecommons.org/licenses/by/4.0/) // Description...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

<lsl> // // Name: Rez Clean-up // Author: Casper Warden // License: Attribution 4.0 International (https://creativecommons.org/licenses/by/4.0/) // Description: This script is for use in rezzed items. It'll automatically clear up the object // once the object that rezzed them disappears.

key parentKey; key myKey; default {

   on_rez(integer j)
   {
       myKey = llGetKey();
       llSetTimerEvent(0.0);
       list tmp = llGetObjectDetails(llGetKey(),[OBJECT_REZZER_KEY]);
       if (llGetListLength(tmp)==0) return;
       parentKey = llList2Key(tmp,0);
       if (llGetOwnerKey(parentKey)==parentKey) return; //It's an avatar
       llSetTimerEvent(1.0);
   }
   timer()
   {
       list tmp = llGetObjectDetails(parentKey,[OBJECT_POS]);
       if (llGetListLength(tmp)==0)
       {
           //Parent is gone
           if (myKey == llGetKey()) llDie(); //Protects against script being stopped half way through an event 
       }
   }

} </lsl>