Reply
Recognized Resident
Kendall Edman
Posts: 9
0 Kudos

Help Needed making a Multi-Line titler

[ Edited ]

i am not good at building scripts from scratch, but understand scripting enough to mod them to work for me.

i have however ran into a snag, what i am trying to do is turn a titler into a multi-line titler.

heres the snippet:

 

listen(integer chan, string name, key id, string msg)
    {
        string mesg;
        mesg = llToLower(msg);
        if(chan == 1)
        {
            if(llGetOwnerKey(id) == llGetOwner())
            {
                if(llGetSubString(mesg, 0, 5) == "title ")
                {
                    title = llGetSubString(msg, 6, -1);
                    if(llToLower(title) == "titleoff")
                    {
                        title = "";
                    }

 

i know that \n starts a new line but saying it in open chat wont work, what i need help with is making an un-used character make a new line on a titler.

i have seen some others that use a pipe character "|" to start new lines. if i can get help with making my script do that it will be great.

Randall Ahren
Posts: 1,923
Topics: 28
Kudos: 48
Blog Posts: 0
Registered: ‎04-18-2010
0 Kudos

Re: Help Needed making a Multi-Line titler

[ Edited ]

Reply to Kendall Edman - view message

Why don't you use string replace from the library:

string strReplace(string str, string search, string replace) {
    return llDumpList2String(llParseStringKeepNulls((str = "") + str, [search], []), replace);
}

 

In your situation, choose some substitute for /n such as nl and then use this line in your code:

strReplace(title,"nl", "/n");

Void Singer
Posts: 7,475
Registered: ‎05-28-2009

Re: Help Needed making a Multi-Line titler

Reply to Randall Ahren - view message

the reason "\n" doesn't work from the string is that string sources are parsed differently if they're sourced from within the script or externally....

when you "\n" in the script you get the line break, but passed in from an outside source, what you actually get is "\\n" because internally "\" is treated as a control character, but it's interpreted as a literal character when it comes from an oustside source... the internal literal is "\\"

so in string replace you would just do this...

message = llDumpList2String( llParseStringKeepNulls( message, ["\\n"], [] ), "\n" );

letting you type the same thing you would expect to use internally for the external source.

PS
only chimed in because of keeping the same format and the slashes above were backwards :smileywink:

- Farewell to your ports and good luck to you all
Recognized Resident
Kendall Edman
Posts: 9
0 Kudos

Re: Help Needed making a Multi-Line titler

[ Edited ]

Reply to Kendall Edman - view message

ok I kinda got it to work, I messed around and got it to recognize multiple lines but the word title shows up in front of my custom title, it looks somthing like this(title MyCustomTitle) this only shows up on line one.

this is what i did.

listen(integer chan, string name, key id, string msg)
    {
        string mesg;
        mesg = llToLower(msg);
        if(chan == 1)
        {
            if(llGetOwnerKey(id) == llGetOwner())
            {                if(llGetSubString(mesg, 0, 5) == "title ")
                {
                    title = llGetSubString(msg, 6, -1);
                    title = llDumpList2String( llParseStringKeepNulls( msg, ["|"], [] ), "\n" );
                    if(llToLower(title) == "titleoff")
                    {
                        title = "";
                    }

 

I know I did something right but I also messed up something because title is showing up, however I am getting more than one line now, so my question is what did i do wrong?

Void Singer
Posts: 7,475
Registered: ‎05-28-2009
0 Kudos

Re: Help Needed making a Multi-Line titler

Reply to Kendall Edman - view message

nothing really... you just didn't remove the word "title" from the message so it's still in there

you can remove it with message = llGetSubString( message, 6, -1 );

- Farewell to your ports and good luck to you all
Recognized Resident
Kendall Edman
Posts: 9
0 Kudos

Re: Help Needed making a Multi-Line titler

Reply to Kendall Edman - view message

Thanks alot Void, i now have it working properly and no errors, the funny thing was i just changed the title call to msg and that did the trick. but it was your last post that showed me what i needed to change.

and thank you randall for your input as well.