Jump to content

Deleting ALL an objects inventory


Tomkinson
 Share

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

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

Recommended Posts

I have written a script that I assumed would delete all the textures out of an objects inventory after you release the mouse button following a 2 second click (does that make sense? :-p ) but it doesn't behave the way I hoped it would. Instead of deleting each texture it errors on every other one, ultimatly failing to delete half the textures. Can someone give me a hand? Or know what is going wrong?

 

integer ignore = FALSE;
float touch_hold_delay = 2.0;
integer touch_held = FALSE;
integer    n = 0;
 
default
{
    state_entry()
    {
        llSay(0, "Hello, Avatar!");
        
    }
 
    touch_start(integer total_number)
    {
        llSetTimerEvent(touch_hold_delay);
        n = llGetInventoryNumber(INVENTORY_TEXTURE);
    }
 
    touch_end(integer total_number)
    {
        llSetTimerEvent(0.0);
        ignore = FALSE;
 
        if (touch_held == TRUE)
        {
            integer i = 0;
            
            while(i < n)
        {
            llRemoveInventory(llGetInventoryName(INVENTORY_TEXTURE, i));
            ++i;
            llSleep(1);
        }
        }
    }
 
    timer()
    {
        llSay(0,"Release to delete slides.");
        touch_held = TRUE;
        ignore = TRUE;
        llSetTimerEvent(0.0);
    }
 
}

 

Link to comment
Share on other sites

Don't do the while loop in such cases. It works, but it is awkward programming. Do either

        for(i=0; i<n; i++)          {          llRemoveInventory(llGetInventoryName(INVENTORY_TEXTURE, i));          i--;                                                   // that is what prevents your problem
n-- // llSleep(1); }

Or as darkie said, which is much better:

        for(i=n-1; i>=0; i--)          {          llRemoveInventory(llGetInventoryName(INVENTORY_TEXTURE, i));          llSleep(1);          }
Link to comment
Share on other sites

  • 2 months later...
You are about to reply to a thread that has been inactive for 4176 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...