Jaydin Normandy
Registered User
Join date: 1 Apr 2006
Posts: 19
|
10-09-2009 11:58
I have a slide show script that I'm making. It has a function that allows the users to hit a delete slides button and the script will go through the inventory of the object and delete all of the slide textures except for the slide named default, which is the logo texture that's displayed on the screen when there are no slides.
Here is the code for deleteSlides():
deleteSlides(){
llSetTexture("default", ALL_SIDES);
integer length = llGetInventoryNumber(INVENTORY_ALL); integer i; string name; for(i = 0; i < length; ++i){ name = llGetInventoryName(INVENTORY_ALL, i); if(name != "default" && llGetInventoryType(name) == 0){ llRemoveInventory(name); llSleep(1); // Thought this would solve it, but made no difference. } } }
My problem is that the script only deletes around 1/4 of the slide textures and then leaves the rest. I thought it might be trying to delete too many textures at once so I added the sleep call in the loop to slow it down a bit. Here's what's even more odd, after running the function once it leaves a lot of textures untouched, and if I run it again it won't delete any of them(I guess the script thinks they've already been deleted).
Anyone have any ideas?
|
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
|
10-09-2009 12:05
/me wonders if you should also not be deleting items that match llGetScriptName().. edit: oops - missed the part where you're checking inventory type. You can use "INVENTORY_TEXTURE " instead of 0 there, if you want, BTW. edit edit: try counting backwards in the loop instead of forwards - if you delete item 0, what used to be item 1 becomes item 0.. 
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!! - Go here: http://jira.secondlife.com/browse/SVC-1224- If you see "if you were logged in.." on the left, click it and log in - Click the "Vote for it" link on the left
|
Jaydin Normandy
Registered User
Join date: 1 Apr 2006
Posts: 19
|
10-09-2009 12:08
From: Meade Paravane /me wonders if you should also not be deleting items that match llGetScriptName().. edit: oops - missed the part where you're checking inventory type. You can use "INVENTORY_TEXTURE " instead of 0 there, if you want, BTW. edit edit: try counting backwards in the loop instead of forwards - if you delete item 0, what used to be item 1 becomes item 0..  Ahhh good thinking, I'll try that out, thanks!
|
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
|
10-09-2009 12:15
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!! - Go here: http://jira.secondlife.com/browse/SVC-1224- If you see "if you were logged in.." on the left, click it and log in - Click the "Vote for it" link on the left
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
10-09-2009 12:22
Actually, if you're only interested in clearing out the extra textures, there's no need to look at everything else in inventory. Just do some thing like ... deleteSlides(){ llSetTexture("default", ALL_SIDES); integer length = llGetInventoryNumber(INVENTORY_TEXTURE); integer i; for(i = length-1; i >=0; --i){ string name = llGetInventoryName(INVENTORY_TEXTURE,i); if (name != "default"){ llRemoveInventory(name); } }
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|