Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Archive Box Labeler and Item Counter

Apollia Pirandello
Registered User
Join date: 3 Oct 2005
Posts: 15
05-18-2007 23:21
CODE
//                 Archive Box Labeler and Item Counter
//
// By Apollia Pirandello
//
// 5/19/2007
//
//
// Public domain. Free to use and/or modify for any purpose,
// including commercial purposes.
//
//
// WARNING: Do not set out more than one box containing this
// script at a time, at least not before you've set their custom
// text. Any box that you haven't set their custom text yet will be
// listening on the same chat channel, which probably won't be useful
// to you unless you want to give all of them the same custom text
// (but you probably don't).
//
//
// I made this script to make it easier for me to box various
// items, such as textures I don't use often, which are clogging my
// tremendously bloated inventory.
//
// SL seems to be rather flaky about making sure all the items you
// try to transfer to a box actually make it into the box, though, so
// I thought a script to count how many objects end up in the box
// might be helpful.
//
// This script also makes it easier to set the name of the box -
// you won't have to use the edit window to name it, and the number
// of items in the box will be automatically mentioned in the box
// name.
//
// When placed in a box, the box displays the name of the box
// (prefix + customtext) and "Contains x items", where x equals
// items_contained (the number of items the object contains, minus 1,
// so the script item itself isn't counted).
//
// The floating text's color is set equal to the vector "textcolor"
// (which is set to yellow by default).
//
// The script also listens on channel 3 for whatever custom text you
// want added to the object's name. The object's name will be:
//
// prefix + whatever text you say on channel 3 + "-x items"
//
// (where x is again items_contained). It stops listening after
// you've set the custom text, so if you want to rename the box after
// that, reset this script.
//
// If you want the box to listen on some other channel, change the
// Channel variable below.
//
// You have to touch the object to update the floating text and the
// object's name. It doesn't update automatically as you add new
// items, since I thought that might be laggy.
//
//
// A shortcut for adding items to a box is to hold the Ctrl key while
// you drag some items from your inventory onto the box.
//
// You can also just drag items from your inventory directly into the
// Contents folder in the Contents tab of the Edit window while
// you have your box selected.
//
// Be very careful when archiving your items in this fashion, and don't
// delete them from your own inventory until after you're _certain_
// they're actually in the box. Once you're certain, I recommend
// taking your archive box, or a copy of it, into inventory before you
// delete the original unboxed items from your inventory.


//**********SCRIPT BEGINS BELOW**********


//****VARIABLES YOU CAN EDIT****

string prefix="ApArchive-Textures-";

//The above text will be prefixed to your object's name. It can
//save you some typing if you have a whole lot of different boxes
//with items of the same category, like textures.
//
//You can customize this variable with whatever text you want, or
//make it blank by deleting the text between the quotes above.


integer Channel=3;

//You can change this number to whatever you want.
//
//Using channel 3, the chat command for the custom text you want
//added to the box's name would be:
//
// /3 (insert your text here)



vector textcolor=<1,1,0>;
//The floating text color, currently set to yellow.
//You can customize this if you want.


//No need to change anything in this script beyond this point.

//The below four variables are nothing you need to change.

string displayname;
string floatingtext;

string fullobjname;
string customtext;

integer items_contained;
integer Handle;

//The above four variables are nothing you need to change.



//****FUNCTIONS****

ListenForCustomText()
{
key myowner=llGetOwner();
Handle = llListen(Channel, "", myowner, "");
}


UpdateText()
{
items_contained=llGetInventoryNumber(INVENTORY_ALL);
items_contained--;

displayname=prefix+customtext;

fullobjname=displayname+"-"+(string)items_contained+" items";
llSetObjectName(fullobjname);

floatingtext=displayname+"\nContains "+(string)items_contained+" items";
llSetText(floatingtext,textcolor,1);
}



//****DEFAULT STATE****

default
{
state_entry()
{
UpdateText();
ListenForCustomText();
llOwnerSay("Say /"+(string)Channel+" (insert your text here) to add your custom text to this object's name.");
}

touch_start(integer total_number)
{
UpdateText();
}

listen(integer channel, string name, key id, string heard)
{
customtext=heard;
llListenRemove(Handle);
UpdateText();
}
}


//**********END OF SCRIPT**********
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
05-23-2007 22:19
/54/c6/185977/1.html
_____________________
i've got nothing. ;)