Over Sleeper
I Dream in LSL
Join date: 12 Jan 2006
Posts: 141
|
05-06-2006 07:16
Does anyone know of a way to remove duplicate objects from a prim? I saw this thread: /54/36/89923/1.html but it's for a list of names, not contents of an object. I need to somehow check to see if there are duplicates and if so SAY SO, then delete them. I'm talking about if I put an object called CUBE_1 into my object and then put 4 more into the object, they are listed in the objects contents as: CUBE_1 CUBE_1 1CUBE_1 2CUBE_1 3CUBE_1 4 I need to remove those extras with a script. Thanks in advance for you help 
|
Metawraith Mistral
Ghost in the Machine
Join date: 26 Sep 2005
Posts: 166
|
05-06-2006 07:57
From: Over Sleeper Does anyone know of a way to remove duplicate objects from a prim? I saw this thread: /54/36/89923/1.html but it's for a list of names, not contents of an object. I need to somehow check to see if there are duplicates and if so SAY SO, then delete them. I'm talking about if I put an object called CUBE_1 into my object and then put 4 more into the object, they are listed in the objects contents as: CUBE_1 CUBE_1 1CUBE_1 2CUBE_1 3CUBE_1 4 I need to remove those extras with a script. Thanks in advance for you help  Try this useful freebie from Adriana Caligari http://www.slexchange.com/modules.php?name=Marketplace&file=item&ItemID=31967
|
Over Sleeper
I Dream in LSL
Join date: 12 Jan 2006
Posts: 141
|
05-06-2006 08:57
Thanks. But I need a solution that I can 'work with'. The script you gave me is copy only so I have no way of making any changes to it. Anyone got any code to get me started? Thanks.
|
Llauren Mandelbrot
Twenty-Four Weeks Old.
Join date: 26 Apr 2006
Posts: 665
|
Try this...
05-06-2006 10:44
From: Over Sleeper Thanks. But I need a solution that I can 'work with'. The script you gave me is copy only so I have no way of making any changes to it. Anyone got any code to get me started? Thanks. No code, Honey, but Ah`ve got an idea: - Create an empty list.
- Loop through the entire inventory; Ah think that y`all will get th` inventory items` names.
- Each repetition, use th` return value from th` previous step ta get the UUID of th` item.
- Check each UUID ta see iffn `tis already in th` list.
- If so, delete item.
- If not, add it to the list.
Ah thinks yoah done heah.
Hope this helps! Iffn it do, send me a copy of the code? Toodle-oo!
|
Over Sleeper
I Dream in LSL
Join date: 12 Jan 2006
Posts: 141
|
05-06-2006 12:14
OK, I see where you are going. Getting started in this asap. But doesn't the object or texture that's in the contents of the object create a new UUID even when duplicated? Or is that just when it rezzes? See I'm thinking: Object UUIDCUBE_1 123-4567 CUBE_1 1 423-8923CUBE_1 2 823-4437CUBE_1 3 103-4039CUBE_1 4 122-3748 Are you saying that if CUBE_1 is duplicated into the contents of the object it will have the same UUID? I thought I should be looking for the space 1 space 2 space 3 on the end of each inventory item name.
|
Yeti Freeloader
Registered User
Join date: 6 Dec 2005
Posts: 13
|
05-06-2006 13:30
I've done something similar but never occured to me that the UUID might be the same. The method of looking for " <num>" is what I used, kinda slow (.1 sec or so) but works.
|
Llauren Mandelbrot
Twenty-Four Weeks Old.
Join date: 26 Apr 2006
Posts: 665
|
05-06-2006 14:14
From: Over Sleeper OK, I see where you are going. Getting started in this asap. But doesn't the object or texture that's in the contents of the object create a new UUID even when duplicated? Or is that just when it rezzes? Ah dunno; Ah`m jes` guessin`, but Ah think it could have th` same UUID From: Over Sleeper See I'm thinking: Object UUID CUBE_1 123-4567 CUBE_1 1 423-8923 CUBE_1 2 823-4437 CUBE_1 3 103-4039 CUBE_1 4 122-3748 Oop, Ah hadn`t thought of that. From: Over Sleeper Are you saying that if CUBE_1 is duplicated into the contents of the object it will have the same UUID? That`s exactly what Ah was thinkin`, but now Ah thinks it`d probably depend on how th` object got inta th` container`s inventory. Ah am shure, howevah, that th` UUID of textures does not change ever. From: Over Sleeper I thought I should be looking for the space 1 space 2 space 3 on the end of each inventory item name. Y`all probably should. Might be a good idea ta check both ways, jes` in case. Me too. Newbie helpin` newbie; makes for plenty o` confusion, no? Ma Birth Day [Note: two words!]isn`t scheduled `till next Tuesday evenin`. Wanna come ta ma Birth Day party?
|
Over Sleeper
I Dream in LSL
Join date: 12 Jan 2006
Posts: 141
|
05-06-2006 18:40
I posted a job offer for this script here: /invalid_link.html If anyone is interested. Thanks for your help 
|
Ardith Mifflin
Mecha Fiend
Join date: 5 Jun 2004
Posts: 1,416
|
05-06-2006 22:30
Here's some code I whipped up while avoiding working on my own project... It only works for up to 9 duplicates, and is not be perfect. In fact, far from it. It's shining example of what happens when you just throw code together without a plan. Use at your own peril! list check_duplicate(list source, integer comparison) { list results = []; integer length = llGetListLength(source); integer j = 0; while (j < length) { if (j != comparison) { list test = llParseString2List(llList2String(source, j), [" "], []); if (llList2String(test, -1) == "1" || llList2String(test, -1) == "2" || llList2String(test, -1) == "3" || llList2String(test, -1) == "4" || llList2String(test, -1) == "5" || llList2String(test, -1) == "6" || llList2String(test, -1) == "7" || llList2String(test, -1) == "8" || llList2String(test, -1) == "9") { results = results + [llList2String(source, j)]; } }
j++; } return results; }
default { touch_start(integer num_detected) { list dupes = []; list inventory = []; //Reset list integer i = 0; //We will use in loop to step through inventory integer number_of_objects = llGetInventoryNumber(10); //10 corresponds to scripts. See Wiki for other types while (i < number_of_objects) { inventory = inventory + (list)llGetInventoryName(10, i); i++; } i = 0; while (i < number_of_objects) { dupes = dupes + check_duplicate(inventory, i);
i++; } llSay(0, llList2CSV(inventory)); llSay(0, llList2CSV(dupes)); integer m = 0; while (m < llGetListLength(dupes)) { string name = llList2String(dupes, m); if (llGetInventoryKey(name) != NULL_KEY) { llRemoveInventory(name); } } } }
|