Thorne Kaiser
Nice Guy
Join date: 29 Nov 2005
Posts: 132
|
06-07-2006 22:55
How can I 1. Check the name of an object and remove special characters in the name like if it's named "Thorne's %!Object" I want to rename it to "Thornes Object" and if it's more than let's say 10 characters, cut off the extra characters, then llSetObjectName to the new name without the special characters, etc? 2. Check my inventory and do the same thing with the object names in there?
|
Bitzer Balderdash
Dazed and Confused
Join date: 21 Dec 2005
Posts: 246
|
06-08-2006 03:07
well, for starters, the only object rename fuction in LSL only allows you to rename the object that the script is running in, so, in order to do what you require you would have to 1) rez every single item one at a time 2) drop the script in each of them 3) pick up the renamed item 4) delete the old item from inventory so you didn't now have a dupe I somehow doubt that is what you are looking for though 
|
Starax Statosky
Unregistered User
Join date: 23 Dec 2003
Posts: 1,099
|
06-08-2006 03:24
This will do the dirty deed when touched for the very first time. Like a viiirgiiiin.
touch_start(integer total_number) { string name=llGetObjectName(); // Filter out the garbage list l=llParseString2List(name,["'","%"],[]); name=llDumpList2String(l,""); // Truncate the name to 10 characters name=llGetSubString(name,0,9); llSetObjectName(name); }
|
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
|
06-08-2006 08:34
Or, perhaps, you can condense and expand all that to llSetObjectName( llDumpList2String( llParseString2List( llDumpList2String( llParseString2List( llDumpList2String( llParseString2List( llDumpList2String( llParseString2List( llGetObjectName(), ["!","\"","#","$","%","&","'","("],[]) , "" ), [")","*","+",",","-",".","/",":" ],[]) , "" ), [";","<","=",">","?","@","[","\\"],[]) , "" ), ["]","^","_","`","{","|","}","~" ],[]) , "" ) );
This will take out all ASCII characters which aren't alphanumeric or a space. Rewrite it... string stripSpecial( string in ) { string noPrint = "!\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"; integer n = -1; string c; while ( ( c = llGetSubString( in, ++n, n ) ) != "" ) if ( llSubStringIndex( noPrint, c ) != -1 ) in = llDeleteSubString( in, n, n-- ); return in; } I haven't tested either of these in-world.
|