CasperVend 2/Rez Clean-up script

From CasperTech Wiki
Jump to navigation Jump to search
// Name:        Rez Clean-up
// Author:      Casper Warden
// License:     Attribution 4.0 International (
// Description: This script is for use in rezzed items. It'll automatically clear up the object
//              once the parent (the object that rezzed it) disappears. 

key parentKey;
key myKey;
    on_rez(integer j)
        myKey = llGetKey();
        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
        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