Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

String splitting questions

Lipidro Bloobury
Registered User
Join date: 5 Jan 2009
Posts: 2
04-06-2009 21:35
What's the easiest way to take a string (for names specifically gathered from llDetectedKey(0) ) and cut off the last name from if? Im not too good with the string manipulation functions =(
Rebekka Revnik
Registered User
Join date: 26 Mar 2008
Posts: 18
04-06-2009 23:27
Try this:
CODE
default
{
touch_start(integer total_number)
{
string name = llDetectedName(0);
string firstname = llGetSubString(name, 0, llSubStringIndex(name, " ")-1);
string lastname = llGetSubString(name, llSubStringIndex(name, " ")+1, llStringLength(name));
llSay(0, firstname);
llSay(0, lastname);
}
}
Talon Brown
Slacker Punk
Join date: 17 May 2006
Posts: 352
04-07-2009 00:00
Alternatively, parse it into a list:

CODE
default
{
touch_start(integer total_number)
{
string name = llDetectedName(0);
list l = llParseString2List(name, [" "], []);
string firstName = llList2String(l, 0);
string lastName = llList2String(l, 1);

llOwnerSay(firstName);
llOwnerSay(lastName);
}
}
Lipidro Bloobury
Registered User
Join date: 5 Jan 2009
Posts: 2
04-09-2009 14:24
awesome, thanks a lot :D

Would've never figured that out, hehe :)