Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Library: Item Counter

Apollia Pirandello
Registered User
Join date: 3 Oct 2005
Posts: 15
09-24-2007 14:51
// Item Counter
//
// By Apollia Pirandello
//
// 9/19/2007
//
// Public domain. Free to use and/or modify for any purpose,
// including commercial purposes.
//
// Once you drop this script in any prim, it will immediately
// tell you in an OwnerSay how many items are in that prim,
// minus 1, so the script itself isn't counted.
//
// It will also do that whenever the prim is touched.


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


//****VARIABLE

integer items_contained;

//****END OF VARIABLE SECTION


//****FUNCTIONS****

CountItems()
{ items_contained=llGetInventoryNumber(INVENTORY_ALL);
items_contained--;
}

SayCount()
{ llOwnerSay("This prim contains "+(string)items_contained+" items.";);
}

//****END OF FUNCTIONS****


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

default
{
state_entry()
{ CountItems();
SayCount();
}

touch_start(integer total_number)
{
CountItems();
SayCount();
}

}

//**********END OF SCRIPT**********
Tylerferland Cork
The Push Master
Join date: 28 Apr 2006
Posts: 762
12-12-2007 17:23
So much usless code here
_____________________
The Push Master
Astro Condor
Krypt Hax


From: someone

[13:53] Jontte Gremlin: i like the way tyler works on useless stuff even though he knows its useless
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
12-12-2007 17:31
From: Tylerferland Cork
So much usless code here

It isn't the way I would have coded it up myself but..............
The OP/creator unselfishly took the time to script it and comment it(probably took longer to comment it) and posted it to the library to help other new people. So in my book, that makes them a true hero.

If nothing else, it is a simple enough script for beginning scripters to play with and learn to streamline.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Xhawkx Holden
Registered User
Join date: 1 Nov 2006
Posts: 86
12-12-2007 17:54
I agree Jesse...
If you don't have anything nice to say... Don't say anything
Mitzy Shino
can i haz ur stufz?
Join date: 15 Dec 2006
Posts: 409
12-12-2007 18:12
From: Tylerferland Cork
So much usless code here

Quote:
[13:53] Jontte Gremlin: i like the way tyler works on useless stuff even though he knows its useless


Kettle calling the pot black?

What is useless to you, might not be useless to another.

Take the OP's script, yes it's simple, yes it doesn't do much really, but guess what? As someone just starting out I had no idea how to do it, but now I do.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-12-2007 20:45
I found it useful, I just threw it in the wiki as an example for get inventory number =)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Tormented Twilight
#1 Cheese Lover
Join date: 30 Jan 2004
Posts: 103
03-29-2008 10:42
Actually this is an incredibly useful function with a number of great uses.
_____________________
SteamJunk, HoboJunk, SpaceJunk, FreeJunk n' more!
News, Online Store, Blog n' more: www.tinyurl.com/junkworld
Shop on XSL now: www.tinyurl.com/tormy
Bobbyb30 Zohari
SL Mentor Coach
Join date: 11 Nov 2006
Posts: 466
03-29-2008 15:58
why would use -- the items contained?

Isn't the whole script simply llGetInventoryNumber(INVENTORY_...)?
Antonius Misfit
Certifiable Linux Addict
Join date: 13 Jun 2006
Posts: 97
03-29-2008 21:58
From: Tormented Twilight
Actually this is an incredibly useful function with a number of great uses.

Indeed. In fact, I think it's a nice starting demo of how LSL accesses inventory. I'm currently planning to run classes for learning LSL, and I think I'll include Apollia's script as both an example and a class project(i.e. How can we find out how many notecards are there?)