Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Funky unpack script

MadamG Zagato
means business
Join date: 17 Sep 2005
Posts: 1,402
04-01-2006 08:17
Heya!

I would like for this unpack script to unpack and then delete the shopping bag or box. However when I do this the way I have below, it only unpacks 1 thing and then dies. Where do I put the llDie() so it doesn't die right after it unpacks the first item?

Note: It works fine without the llDie() and just unpacks into a folder LOL

CODE

default
{
on_rez(integer nevermind)
{
llSetText("Touch me to unpack\nyour new "+llGetObjectName()+".",<1,1,1>,1.0);
}
touch_start(integer total_number)
{
if(llDetectedKey(0) == llGetOwner()) {

list inventory;
string name;
integer num = llGetInventoryNumber(INVENTORY_ALL);
string text = llGetObjectName() + " is unpacking...\n";
integer i;

for (i = 0; i < num; ++i) {
name = llGetInventoryName(INVENTORY_ALL, i);
if(llGetInventoryPermMask(name, MASK_OWNER) & PERM_TRANSFER)
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);
}

text = llGetObjectName();

//we don't want to give them this script
i = llListFindList(inventory, [llGetScriptName()]);
inventory = llDeleteSubList(inventory, i, i);

if (llGetListLength(inventory) < 1)

{
llSay(0, "No items to offer.");
}
else
{
llGiveInventoryList(llGetOwner(), text, inventory);
llOwnerSay("Your new "+ text +" can be found in your inventory, in a folder called '"+ text +"'. Drag it onto the ground to rez it!");
llDie(); //Doesn't unpack all the items, just kills it here. Where should it go?
}

//llDie(); //It did not work here either
}
else
llWhisper(0, "Only the owner can unpack this bag.");
}

}
MadamG Zagato
means business
Join date: 17 Sep 2005
Posts: 1,402
04-01-2006 08:21
No I was mistaken, it does NOT unpack all the items without the llDie. Just any notecards in the object. All the items are set to transfer only.
Exile Loudon
Aspiring Scripter
Join date: 10 Dec 2005
Posts: 122
04-01-2006 09:27
yeah, I was reading it and I didn't understand how it gave you anything; there is no "give inventory" function in it; just "llGetInventory" etc... After it gives it's inventory, kill itself. Make sure that the llGetInventory is under an if event so it doesn't effect all the events that happen after that; if you don't it makes it null.
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
04-01-2006 12:59
You can no longer give no copy items by llGiveInventoryList() either.
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
04-01-2006 13:27
That is based off the old version of the script (found at llGiveInventoryList) please use this version.

CODE

default
{
on_rez(integer nevermind)
{
llSetText("Touch me to unpack\nyour new "+llGetObjectName()+".",<1,1,1>,1.0);
}
touch_start(integer total_number)
{
if(llDetectedKey(0) == llGetOwner()) {

list inventory;
string name;
integer num = llGetInventoryNumber(INVENTORY_ALL);
string text = llGetObjectName() + " is unpacking...\n";
integer i;
integer die = TRUE;

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

text = llGetObjectName();

//we don't want to give them this script
i = llListFindList(inventory, [llGetScriptName()]);
inventory = llDeleteSubList(inventory, i, i);

if (inventory != [])
{
llGiveInventoryList(llGetOwner(), text, inventory);
llOwnerSay("Your new "+ text +" can be found in your inventory, in a folder called '"+ text +"'. Drag it onto the ground to rez it!");
}
if(die)
llDie();
else
llOwnerSay("You will have to finish unpacking the this object manualy. To do so, right click on the object and select \"Open\" then just drag the contents to your inventory.");
}
else
llWhisper(0, "Only the owner can unpack this bag.");
}
}
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
04-01-2006 13:45
MASK_NEXT, or MASK_OWNER?
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
04-02-2006 12:45
From: Ziggy Puff
MASK_NEXT, or MASK_OWNER?


MASK_NEXT so the owner can test out the package and see what the user sees. MASK_NEXT will match MASK_OWNER for the next owner when they unpack the object (asuming they haven't modified the next owner permissions first).

Basicly it makes testing easy.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey