Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

counter for t-shirts (not for profit)

Hajia Engawa
Registered User
Join date: 22 Sep 2006
Posts: 8
12-15-2006 22:01
Hi. I have some t-shirts with various logos from my employer (Sun Microsystems) on them. The Sun branding team has "blessed" the images as ok, so I'm happy to say I'm offering them for free. I'd like to get an idea of how many people are taking advantage of the offer. Is there any easy way to count this? The items are packed in boxes which users can click on to "buy" the shirt for $0L. Is there a counter I can use? Many thanks for any replies.
Ishtara Rothschild
Do not expose to sunlight
Join date: 21 Apr 2006
Posts: 569
12-16-2006 01:08
That can be easily done with an LSL script. A script also offers a more convenient way for the customer to retrieve his item with a single left-click.

You only need to disable the "For Sale" checkbox in the properties of the box prim used as a vendor, click the "New Script" button in the Content tab of the Edit window (click "More >>" if the tabs are not shown), double click the script and paste the following text into it:
CODE
string item_name = "SUN T-shirt"; // change the text within the quotes
string message = "Have fun with your new T-Shirt! You can find it in the Clothes folder of your inventory.";
integer show_message = TRUE; // set to false if the message should not be shown
integer counter=0;

default
{
state_entry()
{
llListen(0,"",llGetOwner(),"");
}
touch_start(integer total_number)
{
llGiveInventory(llDetectedKey(0),item_name);
++counter;
if (show_message==TRUE) llWhisper(0,message);
}
listen(integer chan, string name, key id, string mes)
{
if (mes=="vendor report")
llWhisper(0,"Handed out "+(string)counter+" copies of '"+item_name+"'");
else if (mes=="reset counter")
{
counter=0;
llWhisper(0,"Counter for item '"+item_name+"' has been reset to 0.");
}
}
}
Change the first three lines (item name, message after "Purchase", show message = TRUE or FALSE) and save the script. Say "vendor report" to have the prim whispering the current counter value, and "reset counter" if you want to set it back to zero.

/Edit: you may need to change the texture on the vendor prim if it contains a text like "Purchase for L$0", since the vendor now only needs to be clicked.
Ishtara Rothschild
Do not expose to sunlight
Join date: 21 Apr 2006
Posts: 569
12-16-2006 01:20
PS: You can also add a hovering text above the vendor prim with a slightly changed script, instead of adding text to the vendor texture:
CODE
string item_name = "SUN T-shirt"; // change the text within the quotes 
string message = "Have fun with your new T-Shirt! You can find it in the Clothes folder of your inventory.";
integer show_message = TRUE; // set to false if the message should not be shown
string hovering_text = "Click me for a free T-Shirt!"; // change if needed
integer counter=0;

default
{
state_entry()
{
llSetText(hovering_text,<1,1,1>,1);
llListen(0,"",llGetOwner(),"");
}
touch_start(integer total_number)
{
llGiveInventory(llDetectedKey(0),item_name);
++counter;
if (show_message==TRUE) llWhisper(0,message);
}
listen(integer chan, string name, key id, string mes)
{
if (mes=="vendor report")
llWhisper(0,"Handed out "+(string)counter+" copies of '"+item_name+"'");
else if (mes=="reset counter")
{
counter=0;
llWhisper(0,"Counter for item '"+item_name+"' has been reset to 0.");
}
}
}
Ishtara Rothschild
Do not expose to sunlight
Join date: 21 Apr 2006
Posts: 569
12-16-2006 01:41
PPS: with the following script you can even get a list of the residents who used your vendor, to find out how many unique "purchases" were made or to have a look at some profiles of your target group:
CODE
string item_name = "SUN T-shirt"; // change the text within the quotes 
string message = "Have fun with your new T-Shirt! You can find it in the Clothes folder of your inventory.";
integer show_message = TRUE; // set to false if the message should not be shown
string hovering_text = "Click me for a free T-Shirt!"; // change if needed
list name_list;
integer counter=0;

default
{
state_entry()
{
llSetText(hovering_text,<1,1,1>,1);
llListen(0,"",llGetOwner(),"");
}
touch_start(integer total_number)
{
string name=llDetectedName(0);
name_list+=name;
llGiveInventory(llDetectedKey(0),item_name);
++counter;
if (show_message==TRUE) llWhisper(0,message);
}
listen(integer chan, string name, key id, string mes)
{
if (mes=="counter report")
llWhisper(0,"Handed out "+(string)counter+" copies of '"+item_name+"'.");
else if (mes=="vendor report")
{
llWhisper(0,"Handed out "+(string)counter+" copies of '"+item_name+"' to the following persons:");
integer length = llGetListLength(name_list);
integer i;
for (i=0;i < length;++i)
{
llWhisper(0,llList2String(name_list,i));
}
}
else if (mes=="reset counter")
{
counter=0;
name_list=[""];
llWhisper(0,"Counter for item '"+item_name+"' has been reset to 0.");
}
}
}
The chat command "vendor report" now reads the name list in addition to the counter value, while "counter report" only tells you the current counter.

For more privacy, you could use this script, which reports to you only (chat commands & output aren't shown in the public chat channel; the chat commands are now "/1 vendor report", "/1 counter report" and "/1 counter reset";):
CODE
string item_name = "SUN T-shirt"; // change the text within the quotes 
string message = "Have fun with your new T-Shirt! You can find it in the Clothes folder of your inventory.";
integer show_message = TRUE; // set to false if the message should not be shown
string hovering_text = "Click me for a free T-Shirt!"; // change if needed
list name_list;
integer counter=0;

default
{
state_entry()
{
llSetText(hovering_text,<1,1,1>,1);
llListen(1,"",llGetOwner(),"");
}
touch_start(integer total_number)
{
string name=llDetectedName(0);
name_list+=name;
llGiveInventory(llDetectedKey(0),item_name);
++counter;
if (show_message==TRUE) llWhisper(0,message);
}
listen(integer chan, string name, key id, string mes)
{
if (mes=="counter report")
llOwnerSay("Handed out "+(string)counter+" copies of '"+item_name+"'.");
else if (mes=="vendor report")
{
llOwnerSay("Handed out "+(string)counter+" copies of '"+item_name+"' to the following persons:");
integer length = llGetListLength(name_list);
integer i;
for (i=0;i < length;++i)
{
llOwnerSay(llList2String(name_list,i));
}
}
else if (mes=="reset counter")
{
counter=0;
name_list=[""];
llOwnerSay("Counter for item '"+item_name+"' has been reset to 0.");
}
}
}


/Edit: you only need one of those scripts, of course :) depending on which functions you need.

Ishtara (bored and in scripting mood this morning)
Nyx Divine
never say never!
Join date: 11 Dec 2004
Posts: 1,052
12-16-2006 08:49
If I understand correctly you want to 'track' how many people get your T-shirt(s)?

If you have a box somewhere marked buy for $0L it will record this transaction on your account page of the website under 'transactions'.

I have freebies for sale for $0L and I often look under 'transactions' to see how many folks have been by to pick them up.

No offense to Ishtara who DOES seem to be in a scripting mood :) but a script isn't necessary. Unless I missed something here, it's early and am on my first cup of coffee so I may have :)
_____________________
Yes Virginia there is an FIC!

If someone shows you who they are.....believe them!

Don't be afraid to go out on a limb, because that's where the fruit is!
Hajia Engawa
Registered User
Join date: 22 Sep 2006
Posts: 8
Thanks!
12-16-2006 10:18
Many thanks for all of the suggestions. I'll try them out.
Rhaorth Antonelli
Registered User
Join date: 15 Apr 2006
Posts: 7,425
12-17-2006 08:27
unless you have one of those accounts that are unable to log into the website

seen reports of this happening, and it happened with my alt
hopefully they fix it

so yeah that script can be handy for ppl who can not log into the website for whatever reason and want to see the transaction as it happens hehe