Jump to content

Why might this purge function not be working?


Life Camino
 Share

You are about to reply to a thread that has been inactive for 3466 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I've written a function to purge certain inventory items from an object and it isn't working and I can't see anything wrong with the function and it acts like it's working - it says the inventory has been purged, but it isn't.  It doesn't remove even a single piece of inventory.  What am I missing here or what have I done wrong?

 

purge()
{ list purge_list = []; integer n = llGetInventoryNumber(INVENTORY_OBJECT); integer i = 0; i = i - n; for (; i< 0; i++) { string object = llGetInventoryName(INVENTORY_OBJECT, i); purge_list += object; } n = llGetInventoryNumber(INVENTORY_TEXTURE); i = 0; i = i - n; for (; i< 0; i++) { string texture = llGetInventoryName(INVENTORY_TEXTURE, i); purge_list += texture; } n = llGetInventoryNumber(INVENTORY_NOTECARD); i = 0; i = i - n; for (; i< 0; i++) { string notecard = llGetInventoryName(INVENTORY_NOTECARD, i); purge_list += notecard; } n = llGetInventoryNumber(INVENTORY_ANIMATION); i = 0; i = i - n; for (; i< 0; i++) { string animation = llGetInventoryName(INVENTORY_ANIMATION, i); purge_list += animation; } n = llGetListLength(purge_list); i = 0; i = i - n; for (; i < 0;i++) { string purge_item = llList2String(purge_list, i); if (purge_item != "")llRemoveInventory(purge_item); llSleep(0.1); } llOwnerSay("Inventory items purged..."); }

 

 

Link to comment
Share on other sites

Yes, but you do have the right idea.  When you clean a list, always work backwards from the end of the list toward the beginning.  Otherwise, when you delete elements close to the start of the list you will change the indices of all of the higher-numbered list elements and risk missing them in your cleanup operation.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3466 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...