lsl second life Give Contents - General unboxing script

Summer Haas

Scripted Agent
Joined
Sep 23, 2018
Messages
44
SL Rez
2007
Code:
// This script is free to redistribute and modify, as long as
// any copies of it can be redistributed and modified.
//
// If modifications are made please notate them in the header.
//
// Version 1.1, August 2019 - © Summer Haas



integer cleanup = TRUE;
float pause = 2.0;

give(key agent)
{
    list inventory = [];
    integer i = 0;
    integer contents = INVENTORY_ALL;

    for(i=0; i < llGetInventoryNumber(contents); i++)
    {
        //skip any scripts in the inventory
        if (llGetInventoryType(llGetInventoryName(contents,i)) != INVENTORY_SCRIPT)
            inventory += [llGetInventoryName(contents,i)];
    }

    llGiveInventoryList(agent, llGetObjectName(), inventory);
}


default
{
    state_entry()
    {
        llSetMemoryLimit(16384);
    }

    on_rez(integer start_param)
    {
        give(llGetOwner());

        if (llGetAttached() == 0 && cleanup)
        {
            llSleep(pause);
            llDie();
        }
    }

    attach(key attached)
    {
        llRequestPermissions(llGetOwner(), PERMISSION_ATTACH);
    }
        
    run_time_permissions(integer perm)
    {
        if(perm & PERMISSION_ATTACH && cleanup)
        {
            llSleep(pause);
            llDetachFromAvatar();
        }
    }

    touch_start(integer total_number)
    {
        if (llDetectedKey(0) == llGetOwner())
        {
            give(llDetectedKey(0));

            if (cleanup)
            {
                llSleep(pause);
                llDie();
            }
        }
    }

}
 
Last edited: