Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How do I truncate the name of something in a prim's contents tab?

Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
02-23-2008 04:26
Hi.. I am using Revolution Perenti's open source Menu Based Texture Selection script and have run into a problem, with which I seek people's advice.

The script uses llGetInventoryName to get the names of the textures in the prim's contents and then present them on menu buttons. Unfortunately, some of the textures I want to use -- which are non-modifiable, so I can't change their names -- have long names and this causes the script to fail, giving the error message "Object: llDialog: button labels must be 24 or fewer characters long"

How would I tweak the script to truncate them?

I guess what I'm asking is how do I say, in LSL, something like, "count the number of characters in the texture's name and, if there are more than 24 of them, return only the first 24." Unless there's a better way to do it.
Monica Balut
Beam-Me
Join date: 18 Feb 2007
Posts: 311
02-23-2008 05:08
newStr = llGetSubString(Str,0,23)
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
02-23-2008 07:15
When you apply only the first 24 characters of an item name (which may or may not be more than 24 characters) to a dialog button, and pressing the button simply causes the av to speak what is assigned to the button (but not necessarily what the user sees on the button, see below), the listening script will essentially have to re-search the inventory for items whose first 24 characters match those of the spoken button text, and this presents a problem: What if you have 2 (or more) items whose first 24 characters are identical? How would the script tell which was intended?

A slight variant on this problem: While button text is limited to 24 characters, rarely will the displayed button text actually be 24 char long. It's usually limited to fewer than that, depending on the physical width of the text itself. So if you have 2 (or more) items whose first, say, 10 or 15 characters are identical, the user will be presented with a button list which contains 2 (or more) identical options. Unless they are familiar with the options already, and know that, say, the first actually ends in a "1" and the second in a "2," how will *they* tell the options apart?

For this reason, I much prefer numbering the buttons (1-12, or even better, 1-10 with prev/next page buttons) and displaying a list of what those numeric options correlate to in the dialog text, which isn't as limited. (Assuming 10 options, each consisting of a number, a separator character, a space, and a newline on the first 9 options, that still leaves slightly over 46 characters per option, out of the total 512 char message limit)

It's harder to code, but much more flexible.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
02-23-2008 17:10
presuming you use monica's method to limit characters, you can store any overlimit items in a list, usually as a truncated/raw pair of values, then when searching, add one to the index to get your actual item name. if it's not in your mini list, you can use the button text as is.

deanna also raises a good point in that visible space of buttons may only be 8-10 characters in worst casescenarios, and numbering may help... I also suggest tagging the name after the number so there's at least a vague clue what the item is, then in the code only use the number portion.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -