AutoHUD constructor

From Second Life Wiki
Jump to: navigation, search

AutoHUD constructor v1.0.0

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.
DESIGNED TO DISPLAY 1 TEXT ELEMENT PER PRIM

//https://wiki.secondlife.com/wiki/AutoHUD_constructor
//
// BETLOG Hax
// AEST: 20090113 1346 [SLT:  20090112 2046]
// Total rewrite of a script called 'Align' by Zwagoth Klaar.
// This script features a different 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 facilitate 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 START---
// http://creativecommons.org/licenses/by-sa/3.0/
// ie: Attribution licence:
//   Give me credit by leaving it in the script I created.
//   Supply my original script with your modified version.
//   Refer to the wiki URL from which you copied this script.
//      https://wiki.secondlife.com/wiki/AutoHUD_constructor
// ---LICENCE END---
//=========================================================================
 
//----------------------------------
// 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.015>
        ,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();
    }
}
//======================================================================================
// ORIGINAL LICENCE :
//  GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007
//  http://www.gnu.org/licenses/gpl-3.0.txt
//
//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>)]);
//    }
//}
//======================================================================================


AutoHUD constructor v2.0.0

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.
DESIGNED TO DISPLAY 6 TEXT ELEMENTS PER PRIM, TO SPEED UP LINKMESSAGING..

//https://wiki.secondlife.com/wiki/AutoHUD_constructor
//
// BETLOG Hax
// AEST: 20090124 1605 [SLT:  20090123 2305]
// 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.
//
//  v2.0.0 - DISPLAYS 6 TEXT ELEMENTS PER BLOCK, TO SPEED UP LINKMESSAGING.
//
// 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 START---
// http://creativecommons.org/licenses/by-sa/3.0/
// ie: Attribution licence:
//   Give me credit by leaving it in the script I created.
//   Supply my original script with your modified version.
//   Refer to the wiki URL from which you copied this script.
//      https://wiki.secondlife.com/wiki/AutoHUD_constructor
// ---LICENCE END---
//=========================================================================
 
//----------------------------------
// SHARED CONFIGURATION
integer     gPIN                    = 652212; //CHANGE ME
//----------------------------------
// CONFIGURATION
//
vector      gTextScale              = <0.25, 0.21, 0.01>;
vector      gTextColor              = <0.0, 0.25, 0.25>;
float       gTextAlpha              = 0.5;
//----------------------------------
// CORE CODE
//----------------------------------
f_initPrimLayout()
{   llSetRemoteScriptAccessPin(gPIN);
    llSetObjectName(llGetScriptName());
    llOwnerSay("STARTING: processing initial prim layout");
    llSetPrimitiveParams([
        PRIM_SIZE,<0.055,0.25,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();
    float o;
    vector s = llGetScale();
    float height = gTextScale.y*0.5;
    while(link>1)
    {   o = (s.x*0.5)-(height*0.125);
        if (link > 2)
            o += (height*0.875)*(link-2); 
        llSetLinkPrimitiveParams(link, [
            PRIM_POSITION, <o, 0.0, gTextScale.z*(link-1)> 
            ,PRIM_SIZE, gTextScale
            ,PRIM_ROTATION, llEuler2Rot(<0.0, 90.0, 90.0>*DEG_TO_RAD)
            ,9, 0, 0, <0.375, 0.875, 0.0>, 0.0, <0.0, 0.0, 0.0>
                , <1.0, 1.875, 0.0>, <0.0, 0.0, 0.0>
            ,PRIM_COLOR, ALL_SIDES, <1.0, 1.0, 1.0>, 0.0
            ,PRIM_COLOR, 2, gTextColor, gTextAlpha
            ,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,6,0>, <0,0.5,0>, 0*DEG_TO_RAD 
        ]);
        --link;
    }
    llOwnerSay("COMPLETED: processing prim layout");
    llRemoveInventory(llGetScriptName());
}
//======================================================================================
default
{   on_rez(integer start_param)
    {   llResetScript();
    }
    state_entry()
    {   f_initPrimLayout();
    }
}
//======================================================================================
// ORIGINAL LICENCE :
//  GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007
//  http://www.gnu.org/licenses/gpl-3.0.txt
//
//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>)]);
//    }
//}
//======================================================================================
Tracking 60 avatars on 10 display prims, HUD consists of 13 prims and 14 scripts in total, or 12 if weapon and auxillary function scripts were removed.