Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

iiRemoveInventory Help

Sagan Carlberg
Registered User
Join date: 14 Jun 2007
Posts: 2
07-14-2008 06:20
Hello there :D

I'm trying to get iiRemoveInventory to remove all of the textures in my objects inventory in one shot on a iiListen. As of right now when I run the command it only removes one texture at a time.

if (llToLower (message) == "erase" )
{
llOwnerSay("/me has been manually erased.";);
llRemoveInventory(llGetInventoryName(INVENTORY_TEXTURE, 0));
llResetScript();
}


Any help will be greatly appreciated. Thanks.
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
07-14-2008 06:31
You need to loop through all the textures and remove them one by one...


if (llToLower (message) == "erase" )
{
llOwnerSay("/me has been manually erased.";);
integer picNum = llGetInventoryNumber(INVENTORY_TEXTURE);
integer i;
for(i=0;i<picNum;++i){
llRemoveInventory(llGetInventoryName(INVENTORY_TEXTURE, i));
}
llResetScript();
}
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
07-14-2008 07:17
while(llGetInventoryNumber(INVENTORY_TEXTURE) > 0)
{
llRemoveInventory(llGetInventoryName(INVENTORY_TEXTURE,0));
}

should do the trick as well
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
07-14-2008 08:26
is this the difference of 110 postings or just me being lazy thinking of more elegant solutions? ;)
Sagan Carlberg
Registered User
Join date: 14 Jun 2007
Posts: 2
07-14-2008 15:13
Thank you for such speedy replys :D It worked awesome!

From: Haruki Watanabe
You need to loop through all the textures and remove them one by one...


if (llToLower (message) == "erase" )
{
llOwnerSay("/me has been manually erased.";);
integer picNum = llGetInventoryNumber(INVENTORY_TEXTURE);
integer i;
for(i=0;i<picNum;++i){
llRemoveInventory(llGetInventoryName(INVENTORY_TEXTURE, i));
}
llResetScript();
}


I tried this but I kept getting errors on my next command?

changed(integer mask)
{
if(mask & (CHANGED_ALLOWED_DROP | CHANGED_INVENTORY))
// llOwnerSay("/me inventory has changed";);
llResetScript();

(im still not used to the lingo. sorry)

From: Squirrel Wood
while(llGetInventoryNumber(INVENTORY_TEXTURE) > 0)
{
llRemoveInventory(llGetInventoryName(INVENTORY_TEX TURE,0));
}


This worked like a charm.

I'm new to this stuff and I'm just learning the ropes. You've both been a great help.
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
07-15-2008 13:50
The one implementation generated errors because it was removing an earlier texture and assuming the count of textures was remaining the same (as if the request to remove the textures wasn't fulfilled until the event handler returned or something). So if there were 3 textures, it would remove the first, then ask for the name of the second (and there were only two at that point) and remove it, then ask for the name of the third (but at that point there would be only one!) to remove it. This could be fixed up by asking for all the texture names before removing any of them or counting backwards from last to first, but...

The other implementation works because it accounts for the fact that the enumerated textures in inventory change with each call. There is always a first item (until there are zero items), and we can always remove it.
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
07-15-2008 21:05
Thanks Hewee... nice that you cleared that one up...

... and just as a sidenote - I love this forum. It's by far the most friendliest one I've ever been to... You guys rock... all of you :)
Keira Wells
Blender Sculptor
Join date: 16 Mar 2008
Posts: 2,371
07-15-2008 21:16
OK..I don't see it mentioned so far, so I have to... the title is iiRemoveInventory Help.


But the function is LLRemoveInventory (With lowercase L's). Sorry, I know you know this really, but I just HAD to comment on it!
_____________________
Tutorials for Sculpties using Blender!
Http://www.youtube.com/user/BlenderSL
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
07-15-2008 22:08
From: Keira Wells
OK..I don't see it mentioned so far, so I have to...I just HAD to comment on it!

LOL. I was initially going to comment on it too, but then I got distracted by what I was going to say next. :-)