Jump to content

Float Box Contents


Rolig Loon
 Share

You are about to reply to a thread that has been inactive for 4781 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Here's the scenario: You have a box full of goodies that you want to offer people, and you want to make it easy for them to know what's inside.  Yes, I know they can always right click and use Open or Edit >> Contents, but you want to save them even that much trouble. This simple little script lists everything in your box in an alphabetized hover text display that shows 8 lines at a time, like a vertical marquee. It even shows what type of item (clothing, script, notecard, ....) each one is.

 

// FLOAT BOX CONTENTS  -- Rolig Loon 
// Lists object contents in hover text, labeled by type
//
// Hover text has a 254 character limit, so this script rotates the contents list into hover text eight at a time, marquee style

list gContents = [];

default
{
state_entry()
{
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];
list list_names = ["None", "Texture", "Sound", "Landmark", "Clothing", "Object", "Notecard",
"Script", "Body Part", "Animation", "Gesture"];
integer i;
for (i=0;i<llGetInventoryNumber(INVENTORY_ALL);++i)
{
            string item_name = llGetInventoryName(INVENTORY_ALL,i);
            if((item_name != llGetScriptName())&& (llGetInventoryType(item_name) != 10))
            {
                integer type_index = llListFindList(list_types,[llGetInventoryType(llGetInventoryName(INVENTORY_ALL,i))]);
                string type_name = llList2String(list_names, type_index);
                gContents += type_name + ": " + item_name + "\n ";
            }
        }
        if(llGetListLength(gContents) > 8)
        {
            llSetTimerEvent(5.0);
        }
else
{
llSetText("THIS BOX CONTAINS: \n " + llDumpList2String(gContents,""),<1,1,1>,1.0);
}
}

changed(integer change)
{
if (change & CHANGED_INVENTORY)
{
llResetScript();
}
}

timer()
{
gContents = llList2List(gContents,1,-1) + llList2String(gContents,0); // Move item 0 to the end of the list
list temp = llList2List(gContents,-8,-1); // Display only the last eight items
llSetText("THIS BOX CONTAINS: \n " + llDumpList2String(temp,""),<1,1,1>,1.0);
}

}

ETA:  Modified with the addition of suggestions by Void Singer. :smileywink:

ETA2: And again.  That's what I get for editing too fast.  :=P

 

  • Like 1
Link to comment
Share on other sites

might add a check to see if there are more than 8 items before calling the timer, and if not, just set the text. (might also want to remove the script itself from the list)

I like it though... I did something similar for a leader board scroll.... 5 name at a time, dropping through the top 30

Link to comment
Share on other sites

have to place another set text for the else clause (before you only set it in the timer)

and there's a dirty trick you can pull... instead of testing for the script name on every inventory read, wait till you are out of your look then use find list, and list replace (or list delete) to get rid of it...less proccessing overall (but not something you could get away with if you were giving or deleting the items inside the loop)

Link to comment
Share on other sites

Oh, #$@***!  Fixed again.  :smileysad:

Yeah, I actually considered that doubling back trick for getting rid of the script name but figured that it wasn't worth the extra effort to optimize a bit of code that will execute once on a script reset, especially where saving time is not really important.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4781 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...