Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Just LLGiveInventory

Malina Chuwen
Evotive
Join date: 25 Apr 2008
Posts: 502
06-10-2008 23:59
I didn't realize I needed some huge fancy script just to give a single object, and a massive one to give more than one object. Goodness, why on earth would changing an Objects properties to "Open" actually open it..

So, all I'm trying to do is just that - Have Object X give the person what it has. It's so easy on other games, but here's it's a huge process. From the wiki I've managed to somewhat understand:

default
{
on_rez(integer nevermind)
{
llSetText("Touch me to unpack\nyour new "+llGetObjectName()+".",<1,1,1>,1.0);
}
touch_start(integer total_number)
{
// give all items in a prim to the owner, as folder (with the name of the prim)
// Ezhar Fairlight <efairlight@gmail.com>

// user-friendly additions by Mechanique Thirty (egypt@urnash.com)
// Script adjusted to run faster by Strife Onizuka.

list inventory;
string name;
integer num = llGetInventoryNumber(INVENTORY_ALL);
string text = llGetObjectName() + " is unpacking...\n";
integer i;
key user = llGetOwner();//Set to llDetectedKey(0); to allow anyone to use

for (i = 0; i < num; ++i) {
name = llGetInventoryName(INVENTORY_ALL, i);
if(llGetInventoryPermMask(name, MASK_OWNER) & PERM_COPY)
inventory += name;
else
llOwnerSay("Cannot give asset \""+name+"\", owner lacks copy permission";);
llSetText(text + (string)((integer)(((i + 1.0) / num) * 100))+ "%", <1, 1, 1>, 1.0);
}

//chew off the end off the text message.
text = llGetObjectName();

//we don't want to give them this script
i = llListFindList(inventory, [llGetScriptName()]);
if(~i)//if this script isn't found then we shouldn't try and remove it
inventory = llDeleteSubList(inventory, i, i);

if (llGetListLength(inventory) < 1) llSay(0, "No items to offer.";); else
{
llGiveInventoryList(user, text, inventory);
name = "Your new "+ text +" can be found in your inventory, in a folder called '"+ text +"'. Drag it onto your avatar to wear it!";
if(user == llGetOwner())
llOwnerSay(name);
else
llInstantMessage(user, name);
}
}
}

However, I don't need all these bells and whistles! Just give it to them! I don't want it to change text or say 'unpacking', I don't want it to say anything to them. Just give it. However, when I delete all that mumbo jumbo, it gives error after error.

Isn't there a way around this?

I've also tried:

default {
touch_start(integer total_number) {
// to give a different inventory item type,
// replace "INVENTORY_OBJECT" with "INVENTORY_NOTECARD", etc.
llGiveInventory(llDetectedKey(0),llGetInventoryName(INVENTORY_OBJECT, 0));
}
}

Which simply doesn't work unless it's a single object, notecard, etc.. I've tried making my own but there really isn't that many roads to travel down to try..
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
06-11-2008 00:11
The point is that to give more than one object at once, the script has to have to have a list of the objects, and thus must therefore put one together. Also, one rarely wants to give the actual giving script.

Giving everything in inventory to the toucher, except the script itself, into a folder with the same name as the object:

default
{
touch_start(integer n)
{
list items = [];
integer f = llGetInventoryNumber(INVENTORY_ALL);
do {
string name = llGetInventoryName(INVENTORY_ALL, f);
if (name != llGetScriptName()) items = (items = []) + items + [name];
} while (--f >= 0);
llGiveInventoryList(llDetectedKey(0), llGetObjectName(), items);
}
}

Of course there's always "set to buy contents for L$0 + buy on left-click" as well.
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!

http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal

http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
06-11-2008 00:13
From: Malina Chuwen
So, all I'm trying to do is just that - Have Object X give the person what it has.

You can have this one for free, it will give all note cards to the toucher
CODE

// Notecards giver from Studio Dora, Dora Gustafson 2008
// v1.10 Give all notecards in inventory
// keep it simple stupid

// Click on the object, and it will give all notecards

integer nCards;

default
{
state_entry()
{
nCards = llGetInventoryNumber( INVENTORY_NOTECARD );
if ( !nCards ) llOwnerSay("There is no card to give!");
llAllowInventoryDrop( FALSE );
}

touch_start(integer total_number)
{
integer i;
if ( nCards ) for ( i=0; i < nCards; i++ ) llGiveInventory( llDetectedKey(0), llGetInventoryName( INVENTORY_NOTECARD, i ));
else llWhisper( PUBLIC_CHANNEL, "Sorry! no cards to day" );
}

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

It is simple, debugged, tested and it works!
It is easy to change it to work for any content type or for all...
Happy scripting
_____________________
From Studio Dora
Malina Chuwen
Evotive
Join date: 25 Apr 2008
Posts: 502
06-11-2008 09:22
Goodness - Thank you both!

I knew it couldn't have been that difficult! Lol.
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
06-11-2008 09:30
From: Malina Chuwen

So, all I'm trying to do is just that - Have Object X give the person what it has. It's so easy on other games


Just out of interest, which "other games" are you referring to?