Check Animations Permissions Tool

From Second Life Wiki
Jump to navigation Jump to search

Purpose: a tool to check that animations have correct the permissions for the next owner.

Catches errors that tired eyes may miss!

The logic is based on the assumption that full perms you have licenced should never have both copy and transfer enabled, only one or the other.

Copy the text below the line into a script, and follow the directions below.


//Purpose: a tool to check that animations have correct the permissions for the next owner
//The logic is based on the assumption that full perms you have licenced
//should never have both copy and transfer enabled, only one or the other.
//Confirms to you if all is well; lets you know what the problem ones are otherwise.
//Drop into the prim holding your MLPV2 when you have finished set up.
//Correct any errors.
//Then click the prim to check one more time; correct any errors then repeat until you get all is well msg.
//Then delete this script; customers don't need it, and the SL backend server doesn't need
//yet another running script to be monitoring in SIMs. Plus, customers would get a msg from it
//each time they clicked the prim, which would confuse them.
//Chaz Longstaff. June 2008.
checkPerms() {
    string perms_copy;
    integer i;
    string perms_xfer;
    string ObjectName;
    list WarningList = [];
    integer num = llGetInventoryNumber(INVENTORY_ANIMATION);

    for (i = 0; i < num; ++i) {
        ObjectName = llGetInventoryName(INVENTORY_ANIMATION, i);
        if (llGetInventoryPermMask(ObjectName, MASK_NEXT) & PERM_COPY) {
            perms_copy = "Copy";
            }
        if (llGetInventoryPermMask(ObjectName, MASK_NEXT) & PERM_TRANSFER) {
            perms_xfer = "Transfer";
            }
        if ( ( perms_copy == "Copy") && (perms_xfer == "Transfer") ) {
            WarningList += ObjectName + ": " + perms_copy + " " + perms_xfer;
        }
        perms_copy = "";
        perms_xfer = "";
    }
    integer WarningNum = llGetListLength(WarningList);
    if (WarningNum == 0) {
        llSay(0, "All animation permissions are correct!");
        return;
    }
    else {
        for (i = 0; i < WarningNum; ++i) {
            string tmp01 = llList2String(WarningList, i);
            llSay(0,tmp01);
        }
    }
    WarningList = [];
 }


default {
    state_entry() {
        checkPerms();
    }
   
    on_rez(integer params) {
        llResetScript();
    }
   
    touch_start(integer start) {
        checkPerms();
    }
}

Here's an alternative implementation of the same idea.

// Drop this script in any prim that contains animations to check the their permissions.
// Prints a warning for each animation that is copy/xfer for next owner.
// Prints a warning if you've mixed no-copy and no-xfer anims, and lists the exceptions.
// Lists any modifiable animations.
// Deletes itself when done.
//
// Lear Cale, based on code by Chaz Longstaff, June 2008.

checkPerms() {
    integer ix;
    integer perms;
    integer numWarnings;
    string  anim;
    list    copy;
    list    xfer;
    list    mod;
    
    llSay(0, "Checking that anims are not copy/xfer for next owner");

    integer num = llGetInventoryNumber(INVENTORY_ANIMATION);
 
    for (ix = 0; ix < num; ++ix) {
        anim = llGetInventoryName(INVENTORY_ANIMATION, ix);
        perms = llGetInventoryPermMask(anim, MASK_NEXT);
        
        if ((perms & PERM_COPY) && (perms & PERM_TRANSFER)) {
            llSay(0, "'" + anim + "' is copy/xfer");
            ++numWarnings;
        } else {
            if (perms & PERM_COPY) {
                copy += anim;
            }
            if (perms & PERM_TRANSFER) {
                xfer += anim;
            }
            if (perms * PERM_MODIFY) {
                mod += anim;
            }
        }
    }
    
    integer numCopy = llGetListLength(copy);
    integer numXfer = llGetListLength(xfer);
    
    if (numCopy && numXfer) {
        llSay(0, "Warning: you've mixed no-copy and no-xfer anims");
        if (numCopy < numXfer) {
            llSay(0, "Copy/no-xfer anims: " + llList2CSV(copy));
        } else {
            llSay(0, "Xfer/no-copy anims: " + llList2CSV(xfer));
        }
    }
    
    if (llGetListLength(mod)) {
        llSay(0, "Modifiable anims: " + llList2CSV(mod));
    }
}


default {
    state_entry() {
        checkPerms();
        llRemoveInventory(llGetScriptName());
    }
}