Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Please Ignore

IBME Swindlehurst
Registered User
Join date: 5 Mar 2007
Posts: 139
01-16-2008 13:43
I am trying to make line breaks in FLOATING TEXT using \n. If I create a string in a script that is:

ft_msg = "Line 1\nLine 2";
llSetText(ft_msg, <0, 0, 0>, 1);

evething works as I would expect. The first line of FLOATING TEXT reads:

Line 1

and the second line of FLOATING TEXT reads:

Line 2

BUT if I create a line in a notecard that is:

FLOATING TEXT = Line1\nLine2

and use:

ft_msg = llGetSubString(data, 16, llStringLength(data));
llSetText(ft_msg, <0, 0, 0>, 1);

the FLOATING TEXT reads:

Line 1\nLine2

all on one line.

I've compared the two ft_msg strings and they are equal.

So here is my question---What am I doing wrong? Can one of you kind folks help me?
--------------------------------------------------------------------------------------------------
Here is the whole script:


string notecard_key;
integer n;
string ft_msg;

default
{
state_entry()
{
notecard_key = llGetNotecardLine("Test Notecard", n);
}

dataserver(key query_id, string data)
{
if(query_id == notecard_key)
{
if (data == EOF)
{
llOwnerSay("No more lines in notecard, read " + (string)n + " lines.";);
n=0;
}

else
{
n++;

if(llSubStringIndex(data, "FLOATING TEXT = ";) == 0)
{
// ft_msg = "Line 1\nLine 2";
ft_msg = llGetSubString(data, 16, llStringLength(data));
llSetText(ft_msg, <0, 0, 0>, 1);
llOwnerSay(ft_msg);
}

if(ft_msg = "Line1\nLine2";)
{
llOwnerSay("They are equal";);
}

notecard_key = llGetNotecardLine("Security Notecard", n); // Get the next line
}
}
}
}


Here is the text in the Test notecard:


FLOATING TEXT = Line 1\nLine 2
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
01-16-2008 13:58
I have to confess I can no longer remember the reason why :o - something to do with how escape characters work - but... try this:

ft_msg = llDumpList2String(llParseStringKeepNulls(ft_msg, ["\\n"], []), "\n";);
IBME Swindlehurst
Registered User
Join date: 5 Mar 2007
Posts: 139
01-16-2008 14:08
Pale - Thank you for your almost IMMEDIATE solution. It works. Now I will go off and find out why. Thank you again!