Library: Clothes-In-A-Box Sellers Please Read This!
|
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
|
03-26-2004 23:08
I created this script in responce to the confusion first-time clothes buyers face when purchasing clothing that is stored in a box. This is a common tactic employed by many clothing retailers to sell a bunch of inventory items (such as pieces of clothing) all at once. default { on_rez(integer p) { // When the object is rezzed... list inventory = []; list INVENTORY_CONSTANTS = [ INVENTORY_TEXTURE, INVENTORY_SOUND, INVENTORY_OBJECT, INVENTORY_SCRIPT, INVENTORY_LANDMARK, INVENTORY_CLOTHING, INVENTORY_NOTECARD, INVENTORY_BODYPART];
integer i; integer j; integer len = llGetListLength(INVENTORY_CONSTANTS); for (i = 0; i < len; i++) {
integer constant = (integer) llList2String(INVENTORY_CONSTANTS, i); integer num = llGetInventoryNumber(constant);
for (j = 0; j < num; j++) {
string name = llGetInventoryName(constant, j);
if (name != llGetScriptName()) { inventory += name; } } } string folderName = llGetObjectName() + "'s Contents"; // Name of the folder to give user.
llGiveInventoryList(llGetOwner(), folderName, inventory); // Give the user the contents of the object. llInstantMessage(llGetOwner(), "Look in your inventory for a folder called: " + folderName + ". This folder contains your purchased items."); // Alert the user.
llDie(); // Derez the object. } }
As soon as the object is rezzed, the script gives the contents of the object to the owner of the object, notifys the owner that it gave its contents over, and deletes the object. Hope this helps!  ==Chris
|
Bino Arbuckle
Registered User
Join date: 31 Dec 2002
Posts: 369
|
03-29-2004 10:10
Chris, is this automatic, or do people still have to say yes/no to accept the inventory folder? I haven't experimented with llGiveInventoryList(), but if it does it without prompting, this is pretty handy. I'm only worried that someone forgets to say "yes" and loses everything 
|
Bino Arbuckle
Registered User
Join date: 31 Dec 2002
Posts: 369
|
03-29-2004 10:17
Chris, does llGiveInventoryList() prompt yes/no for accepting inventory? If it doesn't, this is great. If not, I am worried someone might hit "no" and then be stuck 
|
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
|
03-30-2004 22:00
Hmm, good question... That would indeed not be good if a user said no.
Perhaps take out the final llDie. That should give out one copy of each inventory item, and if the inventory was no-copy and if the user accepted the dialog, they should get it, otherwise, they could just re-rez and try again.
|
Justice Monde
Boatbuilder
Join date: 13 Jul 2003
Posts: 78
|
03-31-2004 07:43
Howdy!
I wouldn't recommend using this script as is - at the end, the llDie function stops you from being able to add/remove contents from the box should you decide to change it later. Better make sure you have a copy before you put this script in! Just comment out the llDie() and let the user do as he/she please with the empty box. The box will only empty out if its contents are (no copy). In other words, it will give out a copy of each item that has no copy restriction.
It does prompt the user to accept the transfer. It only gives one prompt, for the category, and if the user clicks "no" the contents of the box remain in the box. However, if you leave the llDie() in the script....I don't even want to think about it.
Take out the llDie() when using this script. In fact, the script should probably be updated to include more safeguards. Chris, maybe the script should llListen for the user to say something instead of doing its thing on_rez().
Hrm, maybe I'll work on it real quick. It's a brilliant idea overall and will come in handy for my workshop.
-JMonde
_____________________
JMonde Boatworks - Period ships and bad-ass powerboats - Myrtle 118, 118
|
Tiger Crossing
The Prim Maker
Join date: 18 Aug 2003
Posts: 1,560
|
04-01-2004 12:16
Make it so that it only dies if it's inventory is empty... That will work for all no-copy contents, at least.
_____________________
~ Tiger Crossing ~ (Nonsanity)
|
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
|
05-02-2004 17:10
From: someone Originally posted by Justice Monde Take out the llDie() when using this script. In fact, the script should probably be updated to include more safeguards. Chris, maybe the script should llListen for the user to say something instead of doing its thing on_rez(). Good ideas! Here's version 2.0 of the script, with Justice's suggestions implemented: // The phrase the user says to make the script give the contents. // This phrase can be changed to whatever is desired. string gMagicPhrase = "give contents";
default { on_rez(integer p) { // When the object is rezzed.. // First, prompt the user. llInstantMessage(llGetOwner(), "Say \" + gMagicPhrase + \" (without quotes) to recieve your purchased items."); // Then, reset, to get rid of stale listen handler. llResetScript(); } state_entry() { // Listen for the user's confirmation. llListen(0, "", llGetOwner(), gMagicPhrase); }
listen(integer c, string name, key id, string message) { // When the user says the magic phrase.... // Notify the user that we're processing her request. llInstantMessage(llGetOwner(), "Please wait, gathering information...");
// The contents of the object. list inventory = [];
// A list of all the types of inventory there are. list INVENTORY_CONSTANTS = [ INVENTORY_TEXTURE, INVENTORY_SOUND, INVENTORY_OBJECT, INVENTORY_SCRIPT, INVENTORY_LANDMARK, INVENTORY_CLOTHING, INVENTORY_NOTECARD, INVENTORY_BODYPART];
integer i; integer j; integer len = llGetListLength(INVENTORY_CONSTANTS); for (i = 0; i < len; i++) { // For every type of inventory...
integer constant = (integer) llList2String(INVENTORY_CONSTANTS, i); integer num = llGetInventoryNumber(constant);
for (j = 0; j < num; j++) { // For every inventory item of the type...
string name = llGetInventoryName(constant, j);
if (name != llGetScriptName()) { // Add it to the list of the object's contents. inventory += name; } } } // Now, the script has the names of every inventory item in its list.
string folderName = llGetObjectName() + "'s Contents"; // Name of the folder to give user.
llGiveInventoryList(llGetOwner(), folderName, inventory); // Give the user the contents of the object. llInstantMessage(llGetOwner(), "Look in your inventory for a folder called: " + folderName + ". This folder contains your purchased items."); // Alert the user.
} }
(Code highlighting curtosy Xylor's highlighting webpage  ) Enjoy! 
|
Anor Tabla
Junior Member
Join date: 30 May 2004
Posts: 1
|
06-11-2004 17:08
This is not working for me. I have a box with this script and in the inventory of the box i have a few objects. All the inventory objects are no-copy/no-mod/yes-transfer. When my customer drops the box and says the magic word, it shouts "No items to offer."
Are you able to do this with no-copy/no-mod/yes-transfer objects? or does llGiveInventoryItems() do a copy so this does not work?
|
Asri Falcone
THAT B!TCH
Join date: 30 Apr 2004
Posts: 356
|
08-27-2004 21:31
From: someone Originally posted by Anor Tabla When my customer drops the box and says the magic word, it shouts "No items to offer." Idont mean to be thisssss lazy but i know nothing about scripting and decided to change all my items over to this script...but im getting the same massage. PLZZZZ tell me there is a way for it to auto-detect the contents of the inventory im looking at 200+outfits id have to list inventory for if not....most of them with 8+ items in it. im just not ip to it..its more work then making the custos do it...plz help... 
|
Jay Fairplay
Junior Member
Join date: 10 Jul 2004
Posts: 9
|
09-03-2004 18:40
I tested the script and it worked fine when I had stuff in the box. Only when the box was empty did it shout no items to offer.
If either of you two are still having trouble.. you're welcome to check to see if I'm online and I'll see if I can help you.
Cheers
|
Asri Falcone
THAT B!TCH
Join date: 30 Apr 2004
Posts: 356
|
09-03-2004 20:36
From: someone Originally posted by Jay Fairplay I tested the script and it worked fine when I had stuff in the box. Only when the box was empty did it shout no items to offer.
Cheers only one issue with the script i found out....if you test it on yourself it work if you test on others it doesnt onless the clothing is copiable. which sucks cause now i have to make it no transfer. i have been catching hell for this for the last week. becuse people buy my stuff for others...bet you anything if u test it on someone else it doesnt work if the item isnt copyiable...it give u a copy of the inventory not the original.
|
Anna Valeeva
Registered User
Join date: 20 Nov 2006
Posts: 4
|
Agree with Asri
04-29-2007 03:44
I used this script also (and had several worried customers who received nothing from the boxes!) This script worked beautifully with me but did not work with customers due to the fact that the clothing was transfer only). If this script worked it would be beautiful.
|
Eliphas Mendes
Registered User
Join date: 24 Jan 2007
Posts: 12
|
From the original LSL Wiki
04-30-2007 02:52
From the original LSL Wiki: From: someone llGiveInventoryList can only give items which the object owner has copy permission on. So it doesn't look like you can get this to work with "no copy" items ....
|
Candi Lindman
Registered User
Join date: 8 Mar 2007
Posts: 2
|
How about a BUSY or AWAY avatar?
05-09-2007 07:31
From: Christopher Omega Good ideas! Here's version 2.0 of the script, with Justice's suggestions implemented: // The phrase the user says to make the script give the contents. // This phrase can be changed to whatever is desired. string gMagicPhrase = "give contents";
default { on_rez(integer p) { // When the object is rezzed.. // First, prompt the user. llInstantMessage(llGetOwner(), "Say \" + gMagicPhrase + \" (without quotes) to recieve your purchased items."); // Then, reset, to get rid of stale listen handler. llResetScript(); } state_entry() { // Listen for the user's confirmation. llListen(0, "", llGetOwner(), gMagicPhrase); }
listen(integer c, string name, key id, string message) { // When the user says the magic phrase.... // Notify the user that we're processing her request. llInstantMessage(llGetOwner(), "Please wait, gathering information...");
// The contents of the object. list inventory = [];
// A list of all the types of inventory there are. list INVENTORY_CONSTANTS = [ INVENTORY_TEXTURE, INVENTORY_SOUND, INVENTORY_OBJECT, INVENTORY_SCRIPT, INVENTORY_LANDMARK, INVENTORY_CLOTHING, INVENTORY_NOTECARD, INVENTORY_BODYPART];
integer i; integer j; integer len = llGetListLength(INVENTORY_CONSTANTS); for (i = 0; i < len; i++) { // For every type of inventory...
integer constant = (integer) llList2String(INVENTORY_CONSTANTS, i); integer num = llGetInventoryNumber(constant);
for (j = 0; j < num; j++) { // For every inventory item of the type...
string name = llGetInventoryName(constant, j);
if (name != llGetScriptName()) { // Add it to the list of the object's contents. inventory += name; } } } // Now, the script has the names of every inventory item in its list.
string folderName = llGetObjectName() + "'s Contents"; // Name of the folder to give user.
llGiveInventoryList(llGetOwner(), folderName, inventory); // Give the user the contents of the object. llInstantMessage(llGetOwner(), "Look in your inventory for a folder called: " + folderName + ". This folder contains your purchased items."); // Alert the user.
} }
(Code highlighting curtosy Xylor's highlighting webpage  ) Enjoy!  I often wondered how to tell if the user is BUSY (or AWAY) before sending them an object. What would happen if the object tried to give something to a BUSY avatar (with AWAY, it would at least clear itself up when an avatar moved or did something)?
|
Chaz Longstaff
Registered User
Join date: 11 Oct 2006
Posts: 685
|
giving inventory
05-27-2007 19:02
llGiveInventoryList can only give items which the object owner has copy permission on.
You have to instead use: llGiveInventory(GiveTo,Item2Give)
for multiple items, build up a list, and then give them one at a time. Obviously less than desirable if 200 items in a box.
|
Huney Jewell
Registered User
Join date: 11 Jul 2007
Posts: 7
|
Some improvements and bug correction
07-14-2007 20:47
Even though the script is only usable for inventory items with copy permission, i made some improvements. 1. INVENTORY_CONSTANTS list isn't needed, used INVENTORY_ALL instead. 2. Write to owner in chat rather than IM, as the unexperienced user might not realize to say the 'MagicPhrase' in chat rather than IM. 3. Instruction "Say '" + gMagicPhrase + "' (without quotes) to receive your purchased items. Confirm subsequent prompt with 'Keep'." debugged and confirm hint added. Now shows up like that: // Unpack Script // As soon as the object is rezzed, the script gives the contents of the object to the owner of the object, // notifies the owner that it gave it's contents over, and possibly deletes the object. // The phrase the user says to make the script give the contents. // This phrase can be changed to whatever is desired. string gMagicPhrase = "unpack"; // Derez the object only if all objects have copy permission integer gDeleteObject = FALSE; // TRUE delete object, FALSE don't delete default { on_rez(integer p) { // When the object is rezzed.. // First, prompt the user. llOwnerSay("Say '" + gMagicPhrase + "' (without quotes) to receive your purchased items. Confirm subsequent prompt with 'Keep'."  ; // Then, reset, to get rid of stale listen handler. llResetScript(); } state_entry() { // Listen for the user's confirmation. llListen(0, "", llGetOwner(), gMagicPhrase); } listen(integer c, string name, key id, string message) { // When the user says the magic phrase.... // Notify the user that we're processing her request. llOwnerSay("Please wait, gathering information..."  ; // The contents of the object. integer i; string InvenName; list InvenList = []; integer InvenNumber = llGetInventoryNumber(INVENTORY_ALL); for (i = 0; i < InvenNumber; i++) { // For every inventory item... InvenName = llGetInventoryName(INVENTORY_ALL, i); if (InvenName != llGetScriptName()) { // Add it to the list of the object's contents. InvenList += [InvenName]; } } // Now, the script has the names of every inventory item in its list. string folderName = llGetObjectName() + "'s Contents"; // Name of the folder to give user. llGiveInventoryList(llGetOwner(), folderName, InvenList); // Give the user the contents of the object. llOwnerSay("Look in your inventory for a folder called: '" + folderName + "'. This folder contains your purchased items."  ; // Alert the user. if (gDeleteObject == TRUE) llDie(); // Derez the object on permission } }
|