NewLine
Jump to navigation
Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Specification
string NewLine(string message)
{
integer newlinepos = llSubStringIndex(message, "\\n");
while(newlinepos >= 0)
{
message = llDeleteSubString(message, newlinepos, newlinepos + 1);
message = llInsertString(message, newlinepos, "\n");
newlinepos = llSubStringIndex(message, "\\n");
}
return message;
}
A shorter alternative:
string NewLine(string message)
{
list lWords = llParseStringKeepNulls(message, ["\\n"], []);
return llDumpList2String(lWords, "\n");
}
Example
Example used in a prim to generate floating text.
string NewLine(string message)
{
integer newlinepos = llSubStringIndex(message, "\\n");
while(newlinepos >= 0)
{
message = llDeleteSubString(message, newlinepos, newlinepos + 1);
message = llInsertString(message, newlinepos, "\n");
newlinepos = llSubStringIndex(message, "\\n");
}
return message;
}
default
{
on_rez(integer rez_param)
{
llResetScript();
}
state_entry()
{
llSetText("", <1,1,1>, 0.0);
llListen(1, "", llGetOwner(), "");
}
listen(integer channel, string name, key id, string str)
{
str = NewLine(str);
llSetText(str, <1,1,1>, 1.0);
}
}
In chat,
"/1 test test test" causes the prim to display:
test test test
"/1 test\ntest\ntest" causes the prim to display:
test
test
test