Don't click here unless you want to be banned.

LSL Wiki : LibraryInventoryLoader

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are ia360925.us.archive.org

InventoryLoader


Code to easily get a box full of toys into your inventory.

Just drag this one into the container and watch the counter. Note that it will kill the object text as it gives you the on going status, but for most things this is not a problem.

Sometimes you don't get all the items. That's not the fault of the script; permissions are, by their nature, inconvenient.

string scriptName;
string objName;
list inventory;
 
LoadInventory() {
    string  text = objName + " is unpacking...\n";
    integer fails = 0;

    integer i;
    integer j = llGetInventoryNumber(INVENTORY_ALL);
    integer checkCount = (j/10) + 1;
    for (i = 0; i < j; i++) {
        string name = llGetInventoryName(INVENTORY_ALL, i);
        if (name!=scriptName) {
            if(llGetInventoryPermMask(name, MASK_NEXT) & PERM_COPY) {
               inventory += name;
            } else {
                fails++;
                llOwnerSay("Cannot give asset \""+name+"\", owner lacks copy permission");
            }
        }
        if (i==0 || (i % checkCount)==0) {
            integer pct = (integer)( ((i + 1.0) / j) * 100 );
            llSetText(text + (string)pct + "%", <1, 1, 1>, 1.0);
        }
    }
    if (fails==0) {
        llSetText(objName + " Unpacking Complete\n"
            +"All " + (string)(j - 1) + " sent.", <0, 1, 0>, 1.0);
    } else {
        llSetText(objName + " Unpacking Complete\n"
            + (string)(j - 1 - fails) + " of " + (string)(j - 1) + " sent.", 
            <1, 0, 0>, 1.0);
    }
}


default {
    state_entry() {
        scriptName = llGetScriptName();
        objName = llGetObjectName();
        LoadInventory();
            
        llGiveInventoryList(llGetOwner(), objName, inventory);
        llRemoveInventory(scriptName);
    }
}

ScriptLibrary | Dolyn's Scripts
There is no comment on this page. [Display comments/form]