Jump to content

You know you love formatting code


Twisted Pharaoh
 Share

You are about to reply to a thread that has been inactive for 4821 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

 

default {
    state_entry() {
        list l;
        integer i = 0;
        while (TRUE) {
            l = l + [i];  // or add the (l=[]), see below
            if (i % 100 == 0) llOwnerSay((string)i);
            ++i;
        }
    }
}
default {
    state_entry() {
        list l;
        integer i = 0;
        while (TRUE) {
            l = l + [i];  // or add the (l=[]), see below            if (i % 100 == 0) llOwnerSay((string)i);
            ++i;
        }
    }
}

 First, is pasted from a SL script window using the code button, second is pasted from the lslwiki.net web page.


From:http://lslwiki.net/lslwiki/wakka.php?wakka=list

SetLinkText( integer linknumber, string text, vector color, float alpha )
{
    llSetLinkPrimitiveParamsFast(linknumber,[PRIM_TEXT,text,color,alpha]);
}
/*
Above here is the function that allows it to work
 
This example makes the prim you click in the Link Set display the word Hello above it in Red text
*/
default
{
    touch_start(integer total_number)
    {
        SetLinkText(llDetectedLinkNumber(0),"Hello",<1,0,0>,1);
    }
}

The last one is from wiki.secondlife.com: http://wiki.secondlife.com/wiki/SetLinkText

 

(¨Pasted from Firefox).

Method to format code using LSL WIki:

This works with Firefox but not with Opera, untested on other browsers.

1) Log into WIki and edit your user pagewiki1.png:

 

  2) Type the tags <lsl> and </lsl> as shown above

 

3) Paste your LSL code between the tags

 

4) Hit the button "Show Preview wiki2.jpg"

 

 

 3) Select the code (make sure you are using Firefox) and Copy it. You don't need to save the page; Preview is enough.

 

4) Paste it in your forum post. under the "Rich Text" tab.

 

default
{
    state_entry()
    {
        llSay(0, "Hello, Avatar!");
    }
 
    touch_start(integer total_number)
    {
        llSay(0, "Touched.");
    }
}

 

5) Then you can go to the HTML tab and make the editions recommended by Void Singer (don't forget to close the <span> you added)

wiki3.jpg

6)  Hit Preview (do it a few times if it complains but all shall go well).

 

7) Post your code and enjoy the highlighting

You can do the same thing from lslwiki.net

 

See Also:

Void Singer's post about creating Macros:

http://community.secondlife.com/t5/LSL-Scripting/You-know-you-love-formatting-code/td-p/704495/page/2#M84

 

Link to comment
Share on other sites

There might be some solutions with the alternate editors (Eclipse maybe?) but I think the second best way would be to add a page in the wiki where we could paste the code and obtain the html. The additional benefit would be the link to the function documentation like if you hover the mouse on llOwnerSay or llDetectedLinkNumber() you can see the link.

The first best way would be to have it directly from the forum of course.

Link to comment
Share on other sites

I didn't realize it at first, but the pre tags have been broken by css (to make them compatible with quoting I guess). they will preserve spaces, but instead of extending the scroll bar, they wrap....

BUT, I found a fix.... just after the opening pre tag add <span style="white-space: pre;">, and before the close pre tag add </span>

so that you end up with:

<pre><span style="white-space: pre;">my carefully formated code that should not be wrapped goes here</span></pre>

 

ps
delete the class attribute from pre tags that are posted code from the LSL Portal to get the to preview, and to post without complaining first.

Link to comment
Share on other sites

adding an update....

you can make your life easier by going to My Settings --> Macros and entering the following....

Macro 1 title:

Script Paste

Macro 1:

<pre><span style="white-space: pre;">Replace</span></pre>

then when you are in a post there will be a Macros combo box on the right of the editor tool bar, and when you select "Script Paste" it will paste a textbox with the word replace into the window, and if you double click the word and paste over top of it, the span style will remain

 

... unfortunately does NOT work for pastes from the LSL_Portal, as those replace both the pre tag and the the span tag, but works great from plaintext sources like the inworld editor.

Link to comment
Share on other sites

  • 1 month later...

Let's see what this button does.

 

    object_rez(key id)    {        llCreateLink(id, LINK_ROOT);        llSetLinkPrimitiveParamsFast(2, [            PRIM_POSITION,                <0., 0., gCubeSize * (gNewChild + 1)>,            PRIM_ROTATION,                ZERO_ROTATION,            PRIM_SIZE,                <gCubeSize, gCubeSize, gCubeSize>,            PRIM_TEXTURE,                ALL_SIDES,                TEXTURE_BLANK,                <1., 1., 0.>,                ZERO_VECTOR,                0.,            PRIM_COLOR,                ALL_SIDES,                ZERO_VECTOR,                0.,            PRIM_DESC,                (string)gNewChild        ]);         gNewChild++;        if (gNewChild < 16)        {            llRezObject(gWorkPrim, llGetPos() + <.5, 0., 0.>, ZERO_VECTOR, ZERO_ROTATION, 0);        }        else        {            llRemoveInventory(gWorkPrim);            llSetText("Object created, you can drag in the radar script now.", <0., 1., 0.>, 1.);            llRemoveInventory(llGetScriptName());        }    }}

 

 

default{    touch_end(integer a)    {        state print;    }} state event{    state_entry()    {        llOwnerSay("Hello");        jump upandown;        float custard = PI;        custard += print;        string event;        @ // wheeeeeeeeeeee!                   upanddown        ;        jump inalake;        @inalake; llShout(           "*splash*");        jump print; @event;        state default;        state ofconfusion;    }    state_exit()    {        llOwnerSay("Goodbye");    }}

 

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4821 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...