|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
03-23-2008 08:35
I feel such a fool for not being able to work this out, but..
What do I to
llSay(0, "Hello " + llDetectedName(0));
to get it to say, "Hello Innula" rather than "Hello Innula Zenovka" ?
|
|
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
|
03-23-2008 08:51
From: Innula Zenovka I feel such a fool for not being able to work this out, but..
What do I to
llSay(0, "Hello " + llDetectedName(0));
to get it to say, "Hello Innula" rather than "Hello Innula Zenovka" ? string name = llDetectedName(0); llSay(0, "Hello " + llGetSubString(name, 0, llSubStringIndex(name, " ") - 1));
|
|
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
|
...and for the programming novice...
03-23-2008 10:29
an explanation:
llGetSubString takes a string, a start position, and an end position. It cretes a new string that is the substring of the first. See the WIKI for details.
In this case, start at 0 (not 1) and go as far as the first blank minus 1. llStringIndex finds the count of the first " ".
Can first names have " "'s in them? I don't think last names can have blanks, so maybe you should search for " " from the end of the string instead of the beginning.
_____________________
So many monkeys, so little Shakespeare.
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
03-23-2008 11:19
No, you can't have spaces in a firstname.
As a more general tip for finding words in a string, the original poster might wish to take a look at llParseString2List. For instance
list words = llParseString2List(message, [" ", ",", ".", "-", ";", ":"], []);
will give you a list of strings which comprise the words in a particular string message, splitting them out by the series of characters in the second parameter. There is also llParseStringKeepNulls which operates in the same way but, as the name suggests, also allows for null elements, and which is sometimes more useful for parsing command strings as opposed to speech.
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!
http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal
http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
|
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
03-23-2008 14:07
Thanks, both. I thought it must be something to do with llGetSubString but I didn't understand how to extract the first word and was getting completely confused trying to find the space between the first and second names and work back from there.. .You have been a huge help.
|
|
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
|
03-23-2008 17:06
Using Ordinal's method is quite acceptable as well: llSay(0, "Hello " + llList2String(llParseString2List(llDetectedName(0), [" "], []), 0));
|