Sign in to follow this  
Followers 0
Kendall Edman

Help Needed making a Multi-Line titler

6 posts in this topic

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.

Share this post


Link to post
Share on other sites

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");

Share this post


Link to post
Share on other sites

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 ;)

1 person likes this

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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 );

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  
Followers 0