Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

float text question

Gareth Qunhua
Registered User
Join date: 11 Apr 2007
Posts: 25
01-10-2008 09:00
hi i was wondering how do you make a float text to cut off and appear in a new line?

eg:
before
what would this text look like in LSL

after
What would
this text look like
in LSL
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
01-10-2008 09:25
Add newline characters to your string with the character sequence "\n" in your script: llSetText("What would\nthis text look like\nin LSL", <1.0, 1.0, 1.0>, 1.0);
Gareth Qunhua
Registered User
Join date: 11 Apr 2007
Posts: 25
01-10-2008 09:57
ahh thanks thats where the problem is, i didn't add n at the back :)
Monica Balut
Beam-Me
Join date: 18 Feb 2007
Posts: 311
01-10-2008 11:03
The \n only seems to work when the text is in the script itself. I recently tried to read the text from a note card and insert it into an llSetText statement and it didn't work the same way. The actual character sequence \n appear rather than an actual newline.
Okiphia Anatine
Okiphia Rayna
Join date: 22 Nov 2007
Posts: 454
01-10-2008 11:05
From: Monica Balut
The \n only seems to work when the text is in the script itself. I recently tried to read the text from a note card and insert it into an llSetText statement and it didn't work the same way. The actual character sequence \n appear rather than an actual newline.

Try seperate values for each line, and in the float text have it

value1 \n value 2

etc
_____________________
In-world, I am Okiphia Rayna. This account is an alt, and is the only account I currently have with payment info on-file due to some account cracking that took place. This is a security measure at present, and I may return to the forums as Okiphia Rayna at a later date.

If you need to reach me, IM Okiphia Rayna, not Okiphia Anatine
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
01-10-2008 11:12
Correct. Inside a script, the "\n" character sequence inside a string literal is interpreted as a newline by the compiler. Strings read as input are not compiled, and may contain newlines (or always be single-line, like when a resident is chatting using the standard client or a notecard line is retrieved) in some cases anyway.
Trevor Langdon
Second Life Resident
Join date: 20 Oct 2004
Posts: 149
01-10-2008 12:20
From: Monica Balut
The \n only seems to work when the text is in the script itself. I recently tried to read the text from a note card and insert it into an llSetText statement and it didn't work the same way. The actual character sequence \n appear rather than an actual newline.


Yes, I discovered something similar; when reading in text from chat for displaying as float text, the '\n' also does not result in newlines being used.

The following code will take the string value in variable 'sTextStr' and rebuild the string, parsing the string and inserting newline characters, so the results will display as intended:

CODE

// Check for embedded "\n" (newline) character-strings
// and re-parse the string to add newlines
if(llSubStringIndex(sTextStr, "\\n") != -1)
{
// Replace any '\n' with newlines
// (note: need a second '\' to allow a literal search for '\')
sTextStr = llDumpList2String(llParseString2List(sTextStr, ["\\n"], []), "\n");
}


Give the above a try.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-10-2008 15:04
also, within a script
"blah\nblah"
is the same as
"blah
blah"

when reading from a notecard you can parse the string to a list, using "\\n" as a seperator and then parse it back to a string adding "\n" as the inserted seperator using dump list 2 string
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -