Difference between revisions of "Float Box Contents"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with '{{LSL Header}} === Features === * Lists all object contents in hover text * Includes inventory type in the hovertext label * Shows 8 contents at a time in a vertical marqee-style...')
 
m (<lsl> tag to <source>)
 
(One intermediate revision by one other user not shown)
Line 6: Line 6:


=== Script  ===
=== Script  ===
<lsl>// FLOAT BOX CONTENTS  -- Rolig Loon -- November 2009
<source lang="lsl2">// FLOAT BOX CONTENTS  -- Rolig Loon -- November 2009
// Lists object contents in dynamic hover text, labelled by type
// Lists object contents in dynamic hover text, labelled by type
//
//
Line 42: Line 42:
     changed(integer change)
     changed(integer change)
     {
     {
         if (change && CHANGED_INVENTORY)  // If something is added to or removed from box inventory
         if (change & CHANGED_INVENTORY)  // If something is added to or removed from box inventory
         {
         {
             llResetScript();
             llResetScript();
Line 56: Line 56:
          
          
}
}
</lsl>
</source>
{{LSLC|Library}}
{{LSLC|Library}}

Latest revision as of 19:23, 24 January 2015

Features

  • Lists all object contents in hover text
  • Includes inventory type in the hovertext label
  • Shows 8 contents at a time in a vertical marqee-style display that updates every 5 seconds

Script

// FLOAT BOX CONTENTS  -- Rolig Loon -- November 2009
// Lists object contents in dynamic hover text, labelled by type
//
// Free to copy, modify, or distribute.  Please leave these header lines intact
// Please do not sell this script.  Be nice.
//
// Hover text has a 254 character limit, so this script rotates the contents list into hover text eight at a time, marquee style

list contents = [];
default
{
    state_entry()
    {
        // this is a list of all the possible inventory types, as constants.
        list list_types = [INVENTORY_NONE, INVENTORY_TEXTURE, INVENTORY_SOUND, INVENTORY_LANDMARK,
        INVENTORY_CLOTHING, INVENTORY_OBJECT, INVENTORY_NOTECARD, INVENTORY_SCRIPT,
        INVENTORY_BODYPART, INVENTORY_ANIMATION, INVENTORY_GESTURE];
        
        // this list is of the string names corresponding to the one above.
        list list_names = ["None", "Texture", "Sound", "Landmark", "Clothing", "Object", "Notecard",
        "Script", "Body Part", "Animation", "Gesture"];
        
        integer all = llGetInventoryNumber(INVENTORY_ALL);
        integer i;
        for (i=0;i<=all-1;++i)
        {
        integer detected_type = llGetInventoryType(llGetInventoryName(INVENTORY_ALL,i)); // look up which type this object is.
        integer type_index = llListFindList(list_types,[detected_type]); // where in list_types is this type?
        string type_name = llList2String(list_names, type_index); // get the corresponding entry in the names list.
        contents += type_name + ": " + llGetInventoryName(INVENTORY_ALL,i) + "\n "; //Display type of content item and its name
        }
        llSetTimerEvent(5);  // Rotate text every 5 seconds
    }
    
    changed(integer change)
    {
        if (change & CHANGED_INVENTORY)  // If something is added to or removed from box inventory
        {
            llResetScript();
        }
    }
    
    timer()
    {
        contents = llList2List(contents,1,-1) + llList2String(contents,0); // Move item 0 to the end of the list
        list temp = llList2List(contents,-8,-1); // Display only the last eight items 
        llSetText("THIS BOX CONTAINS: \n " + llDumpList2String(temp,""),<1,1,1>,1.0);
    }
        
}