Difference between revisions of "NewLine"
Jump to navigation
Jump to search
Ryu Darragh (talk | contribs) (New page: {{LSL Header}} __NOTOC__ <div id="box">{{#if: {{#vardefine:p_source_desc|source string}} }} == Function: string NewLine(string {{LSL Param|source}}); == <div style="padding: 0.5em;...) |
Ryu Darragh (talk | contribs) |
||
Line 74: | Line 74: | ||
"/1 test\ntest\ntest" causes the prim to display: | "/1 test\ntest\ntest" causes the prim to display: | ||
test | test</br> | ||
test | test</br> | ||
test | test</br> | ||
</div></div> | </div></div> | ||
{{LSLC|Examples|NewLine}} | {{LSLC|Examples|NewLine}} |
Revision as of 07:47, 17 February 2008
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Specification
<lsl> 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;
} </lsl>
Example
Example used in a prim to generate floating text. <lsl> 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); }
} </lsl> 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