Table of Contents

Start Functions Events Constants Types Language Articles

Function: llAllowInventoryDrop

llAllowInventoryDrop(integer allow)

Enables or disables the possibility for the prim to accept inventory from anyone.

Parameters

allow

Boolean value indicating whether to allow inventory drop (when TRUE) or not (when FALSE).

Notes

Short examples

llAllowInventoryDrop(TRUE); // Allows anyone to drop items.
llAllowInventoryDrop(FALSE); // Stops allowing anyone to drop items.

Complete examples

This implements a very simple drop box, allowing someone to touch the prim to drop an item, and notifying the owner about who did it.

llAllowInventoryDrop-example.lsl
string WhoDropped;
integer in_use;

RevertToDefault()
{
    llSetText("Touch to drop an item", <1, 1, 1>, 1);
    llSetTimerEvent(0);
    in_use = FALSE;
    llAllowInventoryDrop(FALSE);
}

default
{
    state_entry()
    {
        RevertToDefault();
    }

    touch_start(integer n)
    {
        if (in_use)
        {
            llRegionSayTo(llDetectedKey(0), 0, "Sorry, this drop box is in use. Please wait until it's free.");
            return;
        }
        in_use = TRUE;
        llAllowInventoryDrop(TRUE);
        WhoDropped = llDetectedName(0);
        llSetText(WhoDropped + ", please drop your item in the next 30 seconds.", <1, 1, 1>, 1);
        llSetTimerEvent(30);
    }

    changed(integer change)
    {
        if (change & CHANGED_ALLOWED_DROP)
        {
            RevertToDefault();
            llInstantMessage(llGetOwner(), WhoDropped + " dropped an item!");
        }
    }

    timer()
    {
        RevertToDefault();
    }
}

The example is kept as simple as possible, and for that reason it doesn't recognize what was the last item dropped.

The latter can be roughly done with a list that tracks the last known inventory of the prim, and comparing it with the list at the time a CHANGED_ALLOWED_DROP or a CHANGED_INVENTORY event is received.

As an easier alternative, it's possible to give the items to another prim in the linkset (using llGiveInventory and llGetLinkKey) as they are received, deleting them from the current prim if they are copyable (using llGetInventoryPermMask to check the latter). That will help determine what the dropped items are.

See also