Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llGetInventoryName Issue

HatHead Rickenbacker
Registered Loser
Join date: 6 Nov 2006
Posts: 133
10-27-2007 14:07
Hello!

I am trying to debug an issue with llGetInventoryName. Here is my function from my code

deleteOldObjects()
{
integer objectTotal = llGetInventoryNumber(INVENTORY_OBJECT);

integer i;

for (i = 0; i < objectTotal; i++) {
string name = llGetInventoryName(INVENTORY_OBJECT, i);
llRemoveInventory(name);
}
}

For some reason, while the code will provide the names for the other objects in the hosting object's inventory, it will never provide the name for another specific object; no matter what I do. I can make a copy of the same object that reports its name, rename it and then the copy will not report back its new name. I can make a copy of an object that reported its name correctly and rename that but then it stops reporting. (The name is "Hemp Joint" - not a reserved or key word! ;)

Putting llSay statements in the code prove that it can see the correct number of objects in the hosting object's inventory yet, while providing correct names for the other objects, it will always return a blank name for a certain object (thereby preventing it from being deleted).

I am going crazy trying to correct this - thanks for any help!
HatHead Rickenbacker
Registered Loser
Join date: 6 Nov 2006
Posts: 133
10-27-2007 15:08
Got it - an i should be a 0
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
10-27-2007 15:22
Yeah, reason being you've deleted one INVENTORY_OBJECT so incrementing the i value in
string name = llGetInventoryName(INVENTORY_OBJECT, i);
will result in i reaching a value greater than the number of objects in the inventory. Instead of using 0 you could reverse the order in which you delete them, this way you start at objectTotal-1 and work your way towards 0 (only useful if you decided to check names with the intention of not deleting one or more objects with certain names).
_____________________
www.nandnerd.info
http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum