Difference between revisions of "Template:LSL Function/docs"

From Second Life Wiki
Jump to navigation Jump to search
(AutoHUD constructor)
Line 1: Line 1:
<pre>
==Script==
{{LSL_Function
Automatic assembly of stacked text element HUD. [Typically used to track avatars in your vicinity.]
|func
<br>
|func_id
<b>This script ONLY assembles the HUD prims and then deletes itself.</b>
|func_sleep
<div style="padding: 0.5em;">
|func_energy
<lsl>
|func_desc
//
|func_footnote
// BETLOG Hax
|return_type
// AEST: 20090113 1346 [SLT:  20090112 2046]
|return_text
// Total rewrite of a script called 'Align' by Zwagoth Klaar.
|p1_type|p1_name|p1_desc|p1_hover
// This script features a better layout of prims, specifically so the displayed text is over
|p2_type|p2_name|p2_desc|p2_hover
// the same prim (typically this is not the case, making touch events confusing as they have
|p3_type|p3_name|p3_desc|p3_hover
// to reference the previous linkset prim). This layout avoids that.
|p4_type|p4_name|p4_desc|p4_hover
// Optimized for finer tuned text positioning and sexy texturing.
|p5_type|p5_name|p5_desc|p5_hover
// Intended to facilitite use of an array of llDetectedTouchXX buttons on the main panel.
|p6_type|p6_name|p6_desc|p6_hover
//
|p7_type|p7_name|p7_desc|p7_hover
// WTF?: Arrays prims into a vertical array suitable for avatar-listing HUDs.
|p8_type|p8_name|p8_desc|p8_hover
// HOW?: 1] Rez a bunch of boxes 2] link them together 3] add this script to the root prim.
|p9_type|p9_name|p9_desc|p9_hover
//
|p10_type|p10_name|p10_desc|p10_hover
// LICENCE :
|p11_type|p11_name|p11_desc|p11_hover
//  GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007
|p12_type|p12_name|p12_desc|p12_hover
//  http://www.gnu.org/licenses/gpl-3.0.txt
|constants
// ie: You can modify this script, but you must prominently state that you used this script,
|spec
//  and supply this unaltered script with your modification, and/or make it available to download.
|caveats
//----------------------------------
|examples
// SHARED CONFIGURATION
|helpers
integer    gPIN                    = 652212; //CHANGE ME
|also_header
//----------------------------------
|also_functions
// CONFIGURATION
|also_tests
//
|also_events
vector      gDisplayScale          = <0.22,0.06, 0.01>;//<0.22,0.055, 0.01>;
|also_articles
vector      gDisplayColor          = <0.0, 0.25, 0.25>;
|also_footer
float      gDisplayAlpha          = 0.5;
|notes
//----------------------------------
|mode
// CORE CODE
|deprecated
//
|location
//----------------------------------
|cat1
f_initPrimLayout()
|cat2
{  llSetRemoteScriptAccessPin(gPIN);
|cat3
    llSetObjectName(llGetScriptName());
|cat4
    llOwnerSay("STARTING: processing initial prim layout");
|cat5
    llSetPrimitiveParams([
|cat6
        PRIM_SIZE,<0.055,0.22,0.01>
}}
        ,PRIM_ROTATION, llEuler2Rot(<0.0, 90.0, 180.0>*DEG_TO_RAD)
</pre>
//HALF of the CONTROL PANEL (8 main function button slots)
        ,9, 0, 0, <0.125000, 0.625000, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>
//WHOLE CONTROL PANEL (16 main function button slots)
//        ,9, 0, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>
        ,PRIM_COLOR, ALL_SIDES, <1.0, 1.0, 1.0>, 0.5
        ,PRIM_TEXTURE, ALL_SIDES, TEXTURE_BLANK, <1,1,0>, <0.0,0.0,0>, 0*DEG_TO_RAD
        ,PRIM_TEXTURE, 4,"0c4f66d1-048b-a66e-0c7e-0d40a0b9cd82", <1,1,0>, <0.0,0.0,0>, 270*DEG_TO_RAD
    ]);
    integer p;
    integer link = p = llGetNumberOfPrims();
    while(link>1)
    {  llSetLinkPrimitiveParams(link, [
            PRIM_POSITION, <(gDisplayScale.y*0.5*0.6)*(link-1), 0.0, gDisplayScale.z*(link-1)>
            ,PRIM_SIZE, gDisplayScale
            ,PRIM_ROTATION, llEuler2Rot(<0.0, 90.0, 90.0>*DEG_TO_RAD)
            ,9, 0, 0, <0.375000, 0.875000, 0.0>, 0.0, <0.0, 0.0, 0.0>
                , <1.0, 1.58750000, 0.0>, <0.0, 0.0, 0.0>
            ,PRIM_COLOR, ALL_SIDES, <1.0, 1.0, 1.0>, 0.0
            ,PRIM_COLOR, 2, gDisplayColor, gDisplayAlpha
            ,PRIM_TEXTURE, ALL_SIDES, TEXTURE_BLANK, <1,1,0>, <0.0,0.0,0>, 0*DEG_TO_RAD 
            ,PRIM_TEXTURE, 2, "650f8650-e924-cf51-5603-a1bb03cfab59", <1,1,0>, <0,0,0>, 0*DEG_TO_RAD
        ]);
        --link;
    }
    llOwnerSay("COMPLETED: processing prim layout");
    llRemoveInventory(llGetScriptName());
}
//======================================================================================
default
{  on_rez(integer start_param)
    {  llResetScript();
    }
    state_entry()
    {  f_initPrimLayout();
    }
}
//======================================================================================


The LSL_Function template is a intermediate template for LSL_Generic, which handles the formating for both functions and events (LSL_Event is also an intermediate template). The main job of this template is to change the parameter, names & setup the right-side floater. Also makes permission requirements a part of the template.
//ZWAGOTHS ORIGINAL SCRIPT:
 
// *******************************************************************************
{| {{Prettytable}}
//
|-{{Hl2}}
// I give tech support for advanced+interesting topics only.
!parameter
// Otherwise dont ask me for tech support. I won't give it.
!desc
// But I will accept tips sent to Zwagoth Klaar :-)
!example
//
|-
// Copyright (C) 2008 Zwagoth Klaar
|func
//
|Function name
// This program is free software; you can redistribute it and/or modify
|-
// it under the terms of the GNU General Public License as published by
|func_id
// the Free Software Foundation; either version 2 of the License, or
|{{LSLG|Function ID}}
// (at your option) any later version.
|1.0
//
|-
// This program is distributed in the hope that it will be useful,
|func_sleep
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|{{LSLG|Delay}}
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
|0.0
// GNU General Public License for more details.
|-
//
|func_energy
// You should have received a copy of the GNU General Public License
|{{LSLG|Energy}}
// along with this program; if not, write to the Free Software
|10.0
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  U
|-
//
|func_desc
//default
|Function description text.
//{
|Gives the monkey a banana
//    state_entry()
|-
//    {
|func_footnote
//        vector scale = <0.6,0.032, 0.01>;
|Function footnote (appears after the parameters text).
//        integer link;
|Has the side effect of causing the avatar to run in circles shouting like on fire.
//        for(link = 2;link <= (llGetNumberOfPrims()+1);link++)
|-
//        {
|return_type
//            llSetLinkPrimitiveParams(link, [PRIM_POSITION, ZERO_VECTOR + <0,(scale.y-0.012)*(link-1),0> ,PRIM_SIZE,scale]);
|return type
//        }
|integer
//        llSetLinkPrimitiveParams(1, [PRIM_SIZE,(scale - <0.15,0,0>)]);
|-
//    }
|return_text
//
|"Returns a return_type return_text" in most cases return_text can be used instead of func_desc.
//    touch_start(integer total_number)
|that is a monkey
//    {
|-
//        vector scale = <0.5,0.032, 0.01>;
|p1_type
//        integer link;
|first parameter type
//        for(link = 2;link <= (llGetNumberOfPrims()+1);link++)
|-
//        {
|p1_name
//            llSetLinkPrimitiveParams(link, [PRIM_POSITION, ZERO_VECTOR + <0,(scale.y-0.012)*(link-1),0> ,PRIM_SIZE,scale]);
|first parameter name
//        }
|-
//        llSetLinkPrimitiveParams(1, [PRIM_SIZE,(scale - <0.15,0,0>)]);
|p1_desc
//    }
|first parameter desc
//}
|-
//======================================================================================
|p1_hover
</lsl>
|first parameter hover, if not included it defaults to p1_desc
|-
|p2_type
|second parameter type
|-
|p2_name
|second parameter name
|-
|p2_desc
|second parameter desc
|-
|p2_hover
|second parameter hover, if not included it defaults to p2_desc
|-
|...
|
|
|-
|p12_type
|twelfth parameter type
|
|-
|p12_name
|twelfth parameter name
|-
|p12_desc
|twelfth parameter desc
|-
|p12_hover
|twelfth parameter hover, if not included it defaults to p12_desc
|-
|constants
|constants area, no box, please use a table for this section.
|
|-
|spec
|spec box
|
|-
|caveats
|caveats box
|
|-
|examples
|examples box
|
|-
|helpers
|helper functions box
|
|-
|also_header
|also header
|
|-
|also_functions
|also functions indent
|
|-
|also_events
|also events indent
|
|-
|also_articles
|also articles indent
|
|-
|also_tests
|also tests indent
|
|-
|also_footer
|also footer
|
|-
|notes
|notes box
|
|-
|mode
|If mode equals 'god' then it is tagged as requiring godmode. If set to 'request' marks the page as a feature request. If set to 'user' avoids function being added to LSL Function Index, thus enabling usage of this template for documentation of User Functions.
|
|-
|deprecated
|Marks the function as deprecated. Set the value to the replacement functions name or 'none'. If it is not set to none and it is infact set, it will include a link to the replacement function.
|-
|self
|Special field that you only set if you don't want the function to be included in any categories.
|
|-
|cat1
|An LSL specific category and sets the proper sort. (example would add the function to the "LSL Stub" category)
|Stub
|-
|cat2
|"
|-
|cat3
|"
|-
|cat4
|"
|-
|cat5
|"
|-
|cat6
|"
|-
|sort
|not required but used to specify the sort order, if excluded the wiki will calculate this value for you.
|-
|location
|optional: location box, used to say which source file it is defined in.
|-
|history
|a box for function history
|}
 
<div id="box">
{{LSL_Function
|func=MyFunction
|func_id=-1
|func_sleep=100.5
|func_energy=0.0
|func_desc=A fictitious function{{Footnote|Footnote test}}
|func_footnote=func_footnote
|return_type=void
|return_text=(aka nadda, nothing).
|p1_type=integer|p1_name=i|p1_desc
|p2_type=float|p2_name=f|p2_desc
|p3_type=string|p3_name=s|p3_desc
|p4_type=key|p4_name=k|p4_desc
|p5_type=list|p5_name=l|p5_desc
|p6_type=vector|p6_name=v|p6_desc
|p7_type=rotation|p7_name=r|p7_desc
|constants=constants
|spec=spec
|caveats=caveats
|examples=examples
|helpers=helpers
|also_header=also_header
|also_events=*also_events
|also_functions=*also_functions
|also_articles=*also_articles
|also_tests=*also_tests
|also_footer=also_footer
|notes=notes
|mode
|self=self
|location=location
|history=history
}}
</div>
</div>

Revision as of 18:33, 16 January 2009

Script

Automatic assembly of stacked text element HUD. [Typically used to track avatars in your vicinity.]
This script ONLY assembles the HUD prims and then deletes itself.

<lsl> // // BETLOG Hax // AEST: 20090113 1346 [SLT: 20090112 2046] // Total rewrite of a script called 'Align' by Zwagoth Klaar. // This script features a better layout of prims, specifically so the displayed text is over // the same prim (typically this is not the case, making touch events confusing as they have // to reference the previous linkset prim). This layout avoids that. // Optimized for finer tuned text positioning and sexy texturing. // Intended to facilitite use of an array of llDetectedTouchXX buttons on the main panel. // // WTF?: Arrays prims into a vertical array suitable for avatar-listing HUDs. // HOW?: 1] Rez a bunch of boxes 2] link them together 3] add this script to the root prim. // // LICENCE : // GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 // http://www.gnu.org/licenses/gpl-3.0.txt // ie: You can modify this script, but you must prominently state that you used this script, // and supply this unaltered script with your modification, and/or make it available to download. //---------------------------------- // SHARED CONFIGURATION integer gPIN = 652212; //CHANGE ME //---------------------------------- // CONFIGURATION // vector gDisplayScale = <0.22,0.06, 0.01>;//<0.22,0.055, 0.01>; vector gDisplayColor = <0.0, 0.25, 0.25>; float gDisplayAlpha = 0.5; //---------------------------------- // CORE CODE // //---------------------------------- f_initPrimLayout() { llSetRemoteScriptAccessPin(gPIN);

   llSetObjectName(llGetScriptName());
   llOwnerSay("STARTING: processing initial prim layout");
   llSetPrimitiveParams([
       PRIM_SIZE,<0.055,0.22,0.01>
       ,PRIM_ROTATION, llEuler2Rot(<0.0, 90.0, 180.0>*DEG_TO_RAD)

//HALF of the CONTROL PANEL (8 main function button slots)

       ,9, 0, 0, <0.125000, 0.625000, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>

//WHOLE CONTROL PANEL (16 main function button slots) // ,9, 0, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>

       ,PRIM_COLOR, ALL_SIDES, <1.0, 1.0, 1.0>, 0.5
       ,PRIM_TEXTURE, ALL_SIDES, TEXTURE_BLANK, <1,1,0>, <0.0,0.0,0>, 0*DEG_TO_RAD 
       ,PRIM_TEXTURE, 4,"0c4f66d1-048b-a66e-0c7e-0d40a0b9cd82", <1,1,0>, <0.0,0.0,0>, 270*DEG_TO_RAD 
   ]);
   integer p;
   integer link = p = llGetNumberOfPrims();
   while(link>1)
   {   llSetLinkPrimitiveParams(link, [
           PRIM_POSITION, <(gDisplayScale.y*0.5*0.6)*(link-1), 0.0, gDisplayScale.z*(link-1)> 
           ,PRIM_SIZE, gDisplayScale
           ,PRIM_ROTATION, llEuler2Rot(<0.0, 90.0, 90.0>*DEG_TO_RAD)
           ,9, 0, 0, <0.375000, 0.875000, 0.0>, 0.0, <0.0, 0.0, 0.0>
               , <1.0, 1.58750000, 0.0>, <0.0, 0.0, 0.0>
           ,PRIM_COLOR, ALL_SIDES, <1.0, 1.0, 1.0>, 0.0
           ,PRIM_COLOR, 2, gDisplayColor, gDisplayAlpha
           ,PRIM_TEXTURE, ALL_SIDES, TEXTURE_BLANK, <1,1,0>, <0.0,0.0,0>, 0*DEG_TO_RAD  
           ,PRIM_TEXTURE, 2, "650f8650-e924-cf51-5603-a1bb03cfab59", <1,1,0>, <0,0,0>, 0*DEG_TO_RAD 
       ]);
       --link;
   }
   llOwnerSay("COMPLETED: processing prim layout");
   llRemoveInventory(llGetScriptName());

} //====================================================================================== default { on_rez(integer start_param)

   {   llResetScript();
   }
   state_entry()
   {   f_initPrimLayout();
   }

} //======================================================================================

//ZWAGOTHS ORIGINAL SCRIPT: // ******************************************************************************* // // I give tech support for advanced+interesting topics only. // Otherwise dont ask me for tech support. I won't give it. // But I will accept tips sent to Zwagoth Klaar :-) // // Copyright (C) 2008 Zwagoth Klaar // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 U // //default //{ // state_entry() // { // vector scale = <0.6,0.032, 0.01>; // integer link; // for(link = 2;link <= (llGetNumberOfPrims()+1);link++) // { // llSetLinkPrimitiveParams(link, [PRIM_POSITION, ZERO_VECTOR + <0,(scale.y-0.012)*(link-1),0> ,PRIM_SIZE,scale]); // } // llSetLinkPrimitiveParams(1, [PRIM_SIZE,(scale - <0.15,0,0>)]); // } // // touch_start(integer total_number) // { // vector scale = <0.5,0.032, 0.01>; // integer link; // for(link = 2;link <= (llGetNumberOfPrims()+1);link++) // { // llSetLinkPrimitiveParams(link, [PRIM_POSITION, ZERO_VECTOR + <0,(scale.y-0.012)*(link-1),0> ,PRIM_SIZE,scale]); // } // llSetLinkPrimitiveParams(1, [PRIM_SIZE,(scale - <0.15,0,0>)]); // } //} //====================================================================================== </lsl>