|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
10-14-2006 18:01
I am playing around with a detector script. I want to be able to get the list of detected objects and put them into a llDialog menu. But if the object name has a space in words it breaks it up into multiple buttons unfortunately. For example "Big blue couch" even though it displays correctly as llSetText "Big blue couch". In LLDialog it becomes 3 buttons "Big", "blue", "couch". I know it is something simple but so far this simple something has eaten up about 2 hours of looking in the wiki and trying different things. sensor(integer n){ vector pos = llGetPos(); string result; string name; string names; targets = []; integer p; for (p=n; p>=0; p--) { vector pos2 = llDetectedPos(p); integer dist = llRound(llVecDist(pos, pos2)); if(dist <= range && llDetectedKey(p) != NULL_KEY){ name = llDetectedName(p); if (llStringLength(name)> 10){ name = llGetSubString(name, 0, 10);} result += (llDetectedName(p)) + " @ " + ((string)dist) + "m"; result += "\n"; names += name + " "; } } llSetText(result, <1,1,1>, 1); targets= llParseString2List(names, [" "], []); targets2 = llList2List(targets, 0, 12); llOwnerSay((string)targets2); }
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Trevor Langdon
Second Life Resident
Join date: 20 Oct 2004
Posts: 149
|
10-14-2006 20:04
Jesse-- It appears your problem comes from using a space as your List delimiter. Try creating a custom 2-character delimiter for use inbetween your collected names. Then when you parse out the names to the list, specify your custom delimiter instead of the space. That should allow you to account for spaces in the names. sensor(integer n){ vector pos = llGetPos(); string result; string name; string names; sting delim = "~~" targets = []; integer p; for (p=n; p>=0; p--) { vector pos2 = llDetectedPos(p); integer dist = llRound(llVecDist(pos, pos2)); if(dist <= range && llDetectedKey(p) != NULL_KEY){ name = llDetectedName(p); if (llStringLength(name)> 10){ name = llGetSubString(name, 0, 10);} result += (llDetectedName(p)) + " @ " + ((string)dist) + "m"; result += "\n"; if(names == "") names += name; else names += delim + name; } } llSetText(result, <1,1,1>, 1); targets = llParseString2List(names, [delim], []); targets2 = llList2List(targets, 0, 12); llOwnerSay((string)targets2); }
Or better yet, build your targets list within the for loop inplace of building your "names" variable. sensor(integer n){ vector pos = llGetPos(); string result; string name; string names; targets = []; integer p; for (p=n; p>=0; p--) { vector pos2 = llDetectedPos(p); integer dist = llRound(llVecDist(pos, pos2)); if(dist <= range && llDetectedKey(p) != NULL_KEY){ name = llDetectedName(p); if (llStringLength(name)> 10){ name = llGetSubString(name, 0, 10);} result += (llDetectedName(p)) + " @ " + ((string)dist) + "m"; result += "\n"; targets = targets + [name]; } llSetText(result, <1,1,1>, 1); targets2 = llList2List(targets, 0, 12); llOwnerSay((string)targets2); }
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
10-14-2006 21:48
oooooo very nice workaround Trevor. I didn't know we could create our own delimiters. But as it is I was able to do it this way. Which is like you had it in the second example: sensor(integer n) { vector pos = llGetPos(); string result; string name; string names; targets = []; integer p; for (p=n; p>=0; p--) { vector pos2 = llDetectedPos(p); integer dist = llRound(llVecDist(pos, pos2)); if(dist <= range && llDetectedKey(p) != NULL_KEY){ name = llDetectedName(p); if (llStringLength(name)> 5){ name = llGetSubString(name, 0, 5);} result += (llDetectedName(p)) + " @ " + ((string)dist) + "m"; result += "\n"; targets += [name]; } } llSetText(result, <1,1,1>, 1); targets = llList2List(targets, 0, 11); llOwnerSay((string)targets); }
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Trevor Langdon
Second Life Resident
Join date: 20 Oct 2004
Posts: 149
|
10-15-2006 00:48
Jesse-- Glad you got it to work. The delimiter can be whatever unique character string you want, but it's best to keep it to 1-3 characters. No need to waste valuable resources by unnecessarily swallowing up the 16k limit 
|