Difference between revisions of "LlRemoveInventory"

From Second Life Wiki
Jump to navigation Jump to search
(inventory category)
(Added Caveat re changed event)
 
(15 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{LSLFunctionAll|func_id=151|func_sleep=0.0|func_energy=10.0|func=llRemoveInventory|p1_type=string|p1_name=inventory|func_footnote=Remove the named inventory item|return_text|spec|caveats|examples|helpers|related|also|notes}}[[Category:LSL_Functions]][[Category:LSL_Stub]][[Category:LSL_Inventory]]
{{LSL_Function
|inject-2={{Issues/SVC-304}}{{LSL_Function/inventory|item|uuid=false|type}}
|func_id=151|func_sleep=0.0|func_energy=10.0
|func=llRemoveInventory|p1_type=string|p1_name=item
|func_footnote
|func_desc=Remove the named inventory {{LSLP|item}}
|return_text
|spec
|caveats=*If the current script is removed it will continue to run for a short period of time after this call.
*With multiple executions an llSleep(0.1) after llRemoveInventory will allow edit window contents to refresh correctly and avoid errors on phantom contents.
*llRemoveInventory will not trigger a changed event.
|constants
|examples=
<source lang="lsl2">
// Remove the current script from the object
 
default
{
    state_entry()
    {
        llRemoveInventory(llGetScriptName());
    }
}
</source>
<source lang="lsl2">
// user-function to include in your script
// deletes all other contents of any type except the script itself
delete_all_other_contents()
{
    string thisScript = llGetScriptName();
    string inventoryItemName;
 
    integer index = llGetInventoryNumber(INVENTORY_ALL);
    while (index)
    {
        --index;        // (faster than index--;)
 
        inventoryItemName = llGetInventoryName(INVENTORY_ALL, index);
 
        if (inventoryItemName != thisScript) 
            llRemoveInventory(inventoryItemName);   
    }
}
 
default
{
    state_entry()
    {
        delete_all_other_contents();
    }
}
</source>
|helpers
|also_functions
|also_events
|also_tests
|also_articles
|notes
|permission
|negative_index
|sort=RemoveInventory
|cat1=Inventory
|cat2
|cat3
|cat4
}}

Latest revision as of 14:00, 6 April 2015

Summary

Function: llRemoveInventory( string item );

Remove the named inventory item

• string item an item in the inventory of the prim this script is in

Caveats

  • If item is missing from the prim's inventory then an error is shouted on DEBUG_CHANNEL.
  • If the current script is removed it will continue to run for a short period of time after this call.
  • With multiple executions an llSleep(0.1) after llRemoveInventory will allow edit window contents to refresh correctly and avoid errors on phantom contents.
  • llRemoveInventory will not trigger a changed event.

Important Issues

~ All Issues ~ Search JIRA for related Bugs
   CHANGED_INVENTORY not triggered by llRemoveInventory()

Examples

// Remove the current script from the object

default
{
    state_entry()
    {
        llRemoveInventory(llGetScriptName());
    }
}
// user-function to include in your script
// deletes all other contents of any type except the script itself
delete_all_other_contents()
{
    string thisScript = llGetScriptName();
    string inventoryItemName;

    integer index = llGetInventoryNumber(INVENTORY_ALL);
    while (index)
    {
        --index;        // (faster than index--;)

        inventoryItemName = llGetInventoryName(INVENTORY_ALL, index);

        if (inventoryItemName != thisScript)   
            llRemoveInventory(inventoryItemName);     
    }
}

default
{
    state_entry()
    {
        delete_all_other_contents();
    }
}

Deep Notes

All Issues

~ Search JIRA for related Issues
   CHANGED_INVENTORY not triggered by llRemoveInventory()

Signature

function void llRemoveInventory( string item );