Jump to content
MSTRPLN

Need help with hud feature

Recommended Posts

Hello, i'm almost done with my hud i have one more feature to add before i can make it communicate between the actual meshes.

I'm not sure how i would explain this so it's understandable so here's a little gif to explain: - Click

The way it's constructed for me is the following:
HUD.thumb.png.54cd83421a387bd02e852635f0070746.png

the HUD would send that output to the mesh and tell on which face to change which texture to (more specific the texture + offset). This could be 1, 3, all etc.
On the left example of the mesh the 2 parts would be on top of each other instead of next to eachother.

A full_perm copy of the hud working in-game could be given for a live representation of what it does already, just send me a IM

some more images to understand:
Screenshot_2.png.c55f8b0cbedc5f3df24edb523f1dfedb.pngScreenshot_3.png.b8c120b72be93eca5ae22eeca8b9a646.pngScreenshot_4.thumb.png.ff3415592b1d63c89f5b230479998421.pngScreenshot_5.thumb.png.fe3bf6b6d42205d6928718af033a0a15.png

The code:
 

// Name: HUD Script
// Category: Modular Road kit
// Author: Chris Parker
// Created: 18-08-2017

// Setup for the texture changer 
integer numberOfColumns = 3;
integer numberOfRows = 5; 

// Channel Setup
integer channel = -50502;

// Toggle
integer gOn;

// Rotating unused elements
vector rotated = <0, -90, 0>;
rotation rOn = ZERO_ROTATION;
rotation rOff;

// Textures
key kTitleTex = "a1805d46-f48e-c4fd-648e-c00d608d1604";
key kWetRoadBtn = "a83fcd2c-4df2-8e8a-3edd-03ba8b0b7a7b";
key kRoadMarkingsBtn = "3a7c7475-21f0-31f4-4da7-d094c819c6c3";
key kRoadTexturesBtn = "b97dc6ac-e2be-403b-f6ed-558eb4c11932";
key kRoadLinesBtn = "2677b56d-ecc5-67c0-1a57-9f69c69bf158";
vector vTabRepeats = <0.5, 1.0, 0.0>;
vector vTabOn = <-0.25, 0, 0>;
vector vTabOff = <0.25, 0, 0>;

// Linknumbers
integer giTitle;
integer giTabs;
integer giDryRoad;
integer giDisplay_1;
integer giMarksDisplay;
integer giLinesDisplay;
integer giNext;
integer giPrev;
integer giClear;

// Current Tab
list glTabs = [0,0,"Wet Road", "Road Markings", "Road Textures", "Road Lines"];
integer giCurrTab = 2;
integer giSelectedTextureNum;

// Sorting
list glSortNum = ["13","14","15","10","11","12","7","8","9","4","5","6","1","2","3"];
list glSortNum2 = ["28","29","30","25","26","27","22","23","24","19","20","21","16","17","18"];
list glSortNum3 = ["43","44","45","40","41","42","37","38","39","34","35","36","31","32","33"];


// Texture List
list glWetRoad = ["Wet 1", "Wet 2", "Wet 3"];
list glRoadMarkings = ["Decal 1", "Decal 2", "Decal 3", "Decal 4", "Decal 5", "Decal 6", "Decal 7", "Decal 8", "Decal 9", "Decal 10", "Decal 11", "Decal 12", "Decal 13", "Decal 14", "Decal 15", "Decal 16", "Decal 17", "Decal 18", "Decal 19", "Decal 20", "Decal 21", "Decal 22", "Decal 23", "Decal 24", "Decal 25", "Decal 26", "Decal 27", "Decal 28", "Decal 29", "Decal 30", "Decal 31", "Decal 32"];
list glRoadTextures = ["Road 1", "Road 2", "Road 3", "Road 4", "Road 5", "Road 6", "Road 7", "Road 8", "Curb 1", "Curb 2", "Curb 3", "Curb 4"];
list glRoadLines = ["Line 1", "Line 2", "Line 3", "Line 4", "Line 5", "Line 6", "Line 7", "Line 8"];

// Pages
list glPages = ["Page 1", "Page 2", "Page 3"];
integer giCurrPage = 1;

// Preview selector 8 texture faces max
list lPosition = [0,1,2,3,4,5,6,7];


GetLinkNum()
{
    integer iP = llGetNumberOfPrims();
    while(iP)
    {
        string sName = llGetLinkName(iP);
        if (sName == "Title")
        {
            giTitle = iP;
        }
        else if (llGetSubString(sName, 0,7) == "Mesh_HUD")
        {
            giTabs = iP;
        }
        else if (sName == "Dry Road")
        {
            giDryRoad= iP;
        }
        else if (sName == "Display 1")
        {
            giDisplay_1 = iP;
        }
        else if (sName == "Marks Display")
        {
            giMarksDisplay= iP;
        }
        else if (sName == "Lines Display")
        {
            giLinesDisplay = iP;
        }
        else if (sName == "Next")
        {
            giNext = iP;
        }
        else if (sName == "Prev")
        {
            giPrev = iP;
        }
        else if (sName == "Clear")
        {
            giClear= iP;
        }
        --iP;
    }
}

integer TextureSelection(vector _st)
{
    // ZERO_VECTOR (<0.0, 0.0, 0.0> ... the origin) is in the bottom left corner of the face
    // touchST.x goes across the face from the left to the right
    // touchST.y goes up the face from the bottom to the top
    
    integer columnIndex = (integer) (_st.x * numberOfColumns);
    integer rowIndex    = (integer) (_st.y * numberOfRows);
    integer cellIndex   = (rowIndex * numberOfColumns) + columnIndex;
    if (giCurrPage == 2)
    {
        return llList2Integer(glSortNum2, cellIndex);
    }
    else if (giCurrPage == 3)
    {
        return llList2Integer(glSortNum3, cellIndex);
    }
    else
    {
        return llList2Integer(glSortNum, cellIndex);
    }
}


default
{
    state_entry()
    {
        GetLinkNum();
        llSetText(llGetObjectName(), <1.0, 1.0, 1.0>, 1.0 );
        
        rotated *= DEG_TO_RAD;
        rOff = llEuler2Rot(rotated);
    }

    touch_start(integer num_detected)
    {
        gOn = !gOn;
        
        integer iLinkNum = llDetectedLinkNumber(0);
        string sLinkName = llGetLinkName(iLinkNum);
        integer iTouchFace = llDetectedTouchFace(0);
        vector vTouchST = llDetectedTouchST(0);
        
        if (sLinkName == "Display 1")
        {
            string sCurrentTab = llList2String(glTabs, giCurrTab);
            giSelectedTextureNum = TextureSelection(vTouchST);
            //llOwnerSay("Texture # " + (string)giSelectedTextureNum + " has been clicked in tab " + llList2String(glTabs, giCurrTab));
            
            if (sCurrentTab == "Wet Road")
            {
                llOwnerSay("This Texture has been seleted: " + llList2String(glWetRoad, giSelectedTextureNum -1));
            }
            else if (sCurrentTab == "Road Markings")
            {
                 llOwnerSay("This Texture has been seleted: " + llList2String(glRoadMarkings, giSelectedTextureNum -1));
            }
            else if (sCurrentTab == "Road Textures")
            {
                 llOwnerSay("This Texture has been seleted: " + llList2String(glRoadTextures, giSelectedTextureNum -1));
            }
            else if (sCurrentTab == "Road Lines")
            {
                 llOwnerSay("This Texture has been seleted: " + llList2String(glRoadLines, giSelectedTextureNum -1));
            }
        }
        
        // If "Prev" button is pressed
        if (sLinkName == "Prev")
        {
            if (giCurrPage > 1)
            {
                giCurrPage--;
                llOwnerSay("Current page: " +(string)giCurrPage);
            }
        }
        // If "Next" button is pressed
        if (sLinkName == "Next")
        {
            if (giCurrPage < 3)
            {
                giCurrPage++;
                llOwnerSay("Current page: " +(string)giCurrPage);
            }
        }
        // If "Clear" button is pressed
        if (sLinkName == "Clear")
        {
            if (giCurrTab == 3)
            {
            llOwnerSay("Clear Decals");
            }
            else if (giCurrTab == 4)
            {
            llOwnerSay("Clear Road");
            }
            else if (giCurrTab == 5)
            {
            llOwnerSay("Clear Lines");
            }
        }
        
        // Reset road back to dry
        if(sLinkName == "Dry Road")
        {
            if (giCurrTab == 2)
            {
                llOwnerSay("Dry Road");
            }
        }
        
        // Toggle rain Animation
        if(sLinkName == "Animated")
        {
            if (giCurrTab == 2)
            {
                if (gOn)
                {
                    llOwnerSay("Animate");
                    llSetLinkPrimitiveParamsFast(10, [ PRIM_TEXTURE, ALL_SIDES, "cecbcc14-cc70-9f60-3486-fec8f9de3e4e", <1.0, 0.5, 0.0>, <0.0, -0.25, 0.0>, 0.0 ]);
                }
                else if (!gOn)
                {
                    llOwnerSay("!Animate");
                    llSetLinkPrimitiveParamsFast(10, [ PRIM_TEXTURE, ALL_SIDES, "cecbcc14-cc70-9f60-3486-fec8f9de3e4e", <1.0, 0.5, 0.0>, <0.0, 0.25, 0.0>, 0.0 ]);
                }
            }
        }
        
        if (giCurrTab == 3)
        {
            //Page texture switching
            if (iLinkNum == 6 | iLinkNum == 4)
            {
                if (giCurrPage == 1)
                {
                    llSetLinkTexture(3, "452e4d7a-405c-d530-f2e9-39af7584bc2a", ALL_SIDES);
                    llOwnerSay("Page 1 texture applied");
                }
                else if (giCurrPage == 2)
                {
                    llSetLinkTexture(3, "d851c87b-ee5d-5f2f-7929-95714f20a367", ALL_SIDES);
                    llOwnerSay("Page 2 texture applied");
                }
                else if (giCurrPage == 3)
                {
                    llSetLinkTexture(3, "5533a062-2b74-1086-0e9d-d95a196c1442", ALL_SIDES);
                    llOwnerSay("Page 3 texture applied");
                }
            }
        }
                 
        // If tab menu is clicked
        if(iLinkNum == 1)
        {        
            // Delete Button
            if(iTouchFace == 0)
            { 
                llOwnerSay("DeleteHUD");
            }
            // Minimize Button
            if(iTouchFace == 1)
            { 
                llOwnerSay("DetachHUD");
            }
            // Wet Road Button
            if(iTouchFace == 2)
            {  
                giCurrTab = 2;
                giCurrPage = 1;
                // Title offset
                llSetLinkPrimitiveParamsFast(2, [ PRIM_TEXTURE, 1, kTitleTex, <1.0, 0.25, 0.0>, <0.0, 0.375, 0.0>, 0.0 ]);
                // wet road offset
                llSetLinkPrimitiveParamsFast(1, [ PRIM_TEXTURE, 2, kWetRoadBtn, vTabRepeats, vTabOn, 0.0 ]);
                // all others offset back
                llSetLinkPrimitiveParamsFast(1, [ PRIM_TEXTURE, 3, kRoadMarkingsBtn, vTabRepeats, vTabOff, 0.0 ]);
                llSetLinkPrimitiveParamsFast(1, [ PRIM_TEXTURE, 4, kRoadTexturesBtn, vTabRepeats, vTabOff, 0.0 ]);
                llSetLinkPrimitiveParamsFast(1, [ PRIM_TEXTURE, 5, kRoadLinesBtn, vTabRepeats, vTabOff, 0.0 ]);
                
                // Rotate Road lines Previewer = OFF
                llSetLinkPrimitiveParamsFast(9, [PRIM_ROT_LOCAL, rOff]);
                // Rotate Road markings Previewer = OFF
                llSetLinkPrimitiveParamsFast(8, [PRIM_ROT_LOCAL, rOff]);
                // Rotate Dry road button = ON
                llSetLinkPrimitiveParamsFast(7, [PRIM_ROT_LOCAL, rOn]);
                llSetLinkPrimitiveParamsFast(10, [PRIM_ROT_LOCAL, rOn]);
                // Rotate page buttons = OFF
                llSetLinkPrimitiveParamsFast(6, [PRIM_ROT_LOCAL, rOff]);
                llSetLinkPrimitiveParamsFast(5, [PRIM_ROT_LOCAL, rOff]);
                llSetLinkPrimitiveParamsFast(4, [PRIM_ROT_LOCAL, rOff]);
                
                //Set Display 01 background texture
                llSetLinkPrimitiveParamsFast(3, [ PRIM_TEXTURE, ALL_SIDES, "b9437edd-c3e0-afe7-1b63-ea56893f723a", <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0 ]);
            }

            // Road Markings Button
            if(iTouchFace == 3)
            {  
                giCurrTab = 3;
                giCurrPage = 1;
                // Title offset
                llSetLinkPrimitiveParamsFast(2, [ PRIM_TEXTURE, 1, kTitleTex, <1.0, 0.25, 0.0>, <0.0, 0.125, 0.0>, 0.0 ]);
                // road markings offset
                llSetLinkPrimitiveParamsFast(1, [ PRIM_TEXTURE, 3, kRoadMarkingsBtn, vTabRepeats, vTabOn, 0.0 ]);
                // all others offset back
                llSetLinkPrimitiveParamsFast(1, [ PRIM_TEXTURE, 2, kWetRoadBtn, vTabRepeats, vTabOff, 0.0 ]);
                llSetLinkPrimitiveParamsFast(1, [ PRIM_TEXTURE, 4, kRoadTexturesBtn, vTabRepeats, vTabOff, 0.0 ]);
                llSetLinkPrimitiveParamsFast(1, [ PRIM_TEXTURE, 5, kRoadLinesBtn, vTabRepeats, vTabOff, 0.0 ]);
                
                // Rotate Road lines Previewer = OFF
                llSetLinkPrimitiveParamsFast(9, [PRIM_ROT_LOCAL, rOff]);
                // Rotate Road markings Previewer = ON
                llSetLinkPrimitiveParamsFast(8, [PRIM_ROT_LOCAL, rOn]);
                // Rotate Dry road button = OFF
                llSetLinkPrimitiveParamsFast(7, [PRIM_ROT_LOCAL, rOff]);
                llSetLinkPrimitiveParamsFast(10, [PRIM_ROT_LOCAL, rOff]);
                // Rotate page buttons = ON
                llSetLinkPrimitiveParamsFast(6, [PRIM_ROT_LOCAL, rOn]);
                llSetLinkPrimitiveParamsFast(5, [PRIM_ROT_LOCAL, rOn]);
                llSetLinkPrimitiveParamsFast(4, [PRIM_ROT_LOCAL, rOn]);
                
                llSetLinkTexture(3, "452e4d7a-405c-d530-f2e9-39af7584bc2a", ALL_SIDES);
                llOwnerSay("Default page texture applied");
            }
            // Road Textures Button
            if(iTouchFace == 4)
            { 
                giCurrTab = 4;
                giCurrPage = 1;
                // Title offset
                llSetLinkPrimitiveParamsFast(2, [ PRIM_TEXTURE, 1, kTitleTex, <1.0, 0.25, 0.0>, <0.0, -0.125, 0.0>, 0.0 ]);
                // road textures offset
                llSetLinkPrimitiveParamsFast(1, [ PRIM_TEXTURE, 4, kRoadTexturesBtn, vTabRepeats, vTabOn, 0.0 ]);
                // all others offset back
                llSetLinkPrimitiveParamsFast(1, [ PRIM_TEXTURE, 3, kRoadMarkingsBtn, vTabRepeats, vTabOff, 0.0 ]);
                llSetLinkPrimitiveParamsFast(1, [ PRIM_TEXTURE, 2, kWetRoadBtn, vTabRepeats, vTabOff, 0.0 ]);
                llSetLinkPrimitiveParamsFast(1, [ PRIM_TEXTURE, 5, kRoadLinesBtn, vTabRepeats, vTabOff, 0.0 ]);
                
                // Rotate  Road lines Previewer = OFF
                llSetLinkPrimitiveParamsFast(9, [PRIM_ROT_LOCAL, rOff]);
                // Rotate Road markings Previewer = OFF
                llSetLinkPrimitiveParamsFast(8, [PRIM_ROT_LOCAL, rOff]);
                // Rotate Dry road button = OFF
                llSetLinkPrimitiveParamsFast(7, [PRIM_ROT_LOCAL, rOff]);
                llSetLinkPrimitiveParamsFast(10, [PRIM_ROT_LOCAL, rOff]);
                // Rotate page buttons = OFF
                llSetLinkPrimitiveParamsFast(6, [PRIM_ROT_LOCAL, rOff]);
                llSetLinkPrimitiveParamsFast(5, [PRIM_ROT_LOCAL, rOn]);
                llSetLinkPrimitiveParamsFast(4, [PRIM_ROT_LOCAL, rOff]);
                
                //Set Display 01 background texture
                llSetLinkPrimitiveParamsFast(3, [ PRIM_TEXTURE, ALL_SIDES, "ed943688-013d-c48b-4546-9822e8afd18f", <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0 ]);
            }
            // Road Lines Button
            if(iTouchFace == 5)
            {
                giCurrTab = 5;
                giCurrPage = 1;
                // Title offset
                llSetLinkPrimitiveParamsFast(2, [ PRIM_TEXTURE, 1, kTitleTex, <1.0, 0.25, 0.0>, <0.0, -0.375, 0.0>, 0.0 ]);
                // road lines offset
                llSetLinkPrimitiveParamsFast(1, [ PRIM_TEXTURE, 5, kRoadLinesBtn, vTabRepeats, vTabOn, 0.0 ]);
                // all others offset back
                llSetLinkPrimitiveParamsFast(1, [ PRIM_TEXTURE, 3, kRoadMarkingsBtn, vTabRepeats, vTabOff, 0.0 ]);
                llSetLinkPrimitiveParamsFast(1, [ PRIM_TEXTURE, 4, kRoadTexturesBtn, vTabRepeats, vTabOff, 0.0 ]);
                llSetLinkPrimitiveParamsFast(1, [ PRIM_TEXTURE, 2, kWetRoadBtn, vTabRepeats, vTabOff, 0.0 ]);
                
                // Rotate Road lines Previewer = ON
                llSetLinkPrimitiveParamsFast(9, [PRIM_ROT_LOCAL, rOn]);
                // Rotate Road markings Previewer = OFF
                llSetLinkPrimitiveParamsFast(8, [PRIM_ROT_LOCAL, rOff]); 
                // Rotate Dry road button = OFF
                llSetLinkPrimitiveParamsFast(7, [PRIM_ROT_LOCAL, rOff]);
                llSetLinkPrimitiveParamsFast(10, [PRIM_ROT_LOCAL, rOff]);
                // Rotate page buttons = OFF
                llSetLinkPrimitiveParamsFast(6, [PRIM_ROT_LOCAL, rOff]);
                llSetLinkPrimitiveParamsFast(5, [PRIM_ROT_LOCAL, rOn]);
                llSetLinkPrimitiveParamsFast(4, [PRIM_ROT_LOCAL, rOff]);
                
                //Set Display 01 background texture
                llSetLinkPrimitiveParamsFast(3, [ PRIM_TEXTURE, ALL_SIDES, "20c83606-4207-3382-ef44-819077616fe0", <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0 ]);
            }
        }   
    }
}

Ofcourse the "return llList2Integer(glSortNum2, cellIndex);" would be changed to llRegionSayTo once i start doing the communiction between the HUD & the Mesh

Edited by MSTRPLN

Share this post


Link to post
Share on other sites
On 15-9-2017 at 10:11 PM, Xiija said:

not sure what the question is?

is some part not working, or do you need help with something?

I need to add this feature, the rest is already working i just need this one feature to finish the script

Share this post


Link to post
Share on other sites

Your current work in progress is already beyond my current abilities, so I'm not going to be any help whatsoever, but I wanted to chime in and say that I really like how you've formatted your post, with all of the images and info.

I've never done anything involving setting scale or offset or anything on textures myself, at least not with scripting, so all of that is over my head, but you've got some impressive work going there so far.

Share this post


Link to post
Share on other sites

Pretty much llRegionSay() or llRegionSayTo() setting up a listener handler on the prim(s) parse the "message". There are lots of ways once you get there. A good idea is to think about isolating the message to into blocks of logic you plan on working with.

http://wiki.secondlife.com/wiki/LlListen

Setting up a listener, channel (use negative values RE: viewers cannot comm over negative channels) you wish to communicate on and parsing the message into the appropiate blocks of commands is where you are at I suppose.

 

Share this post


Link to post
Share on other sites

Sorry i;'ve been away for long time. I think i should've exlained it simpeler. Im not codign the communication just yet.

For example let's take the road decals, clckking of the first one willl output: "This Texture has been seleted: Decal 1" the second one will do the same but output 2.
So far it doesnt have any faces to change the texture on. thats what the selector is for (which isnt coded yet).

Selecting none will result in no changes, selectign one, multiple or all faces on the selector will make the hud change textures on the corresponding faces (as of right now just output text)
for example: "Faces selected 3 & 5 - Texture selected 1" when having faces 3 and 5 selected and licking on texture 1 (image preview)

This is what i need help with to make this work

Share this post


Link to post
Share on other sites

At this point, your script is complex enough that it will take anyone else a long time time to figure out what it does, before we'd be able offer constructive advice. I'll be surprised if anyone wants to invest that much time.

This is the heart of scripting and the hardest part-- determining the logic of what you want to do and translating it into unambiguous code. ( It's also where the fun is, if you can live with a certain amount of frustration. B| )  I suggest loading your script with llOwnerSay statements to keep track of key variables as it runs, and then slowly and deliberately working through each module of code to verify that it follows whatever logical pathway you think you have designed. You're in a much better position to do that than anyone else, because you have the layout in your head. It may make sense to rip out subsections of the script and test them separately.  Debugging simplified versions of a script can often give you insights that would be lost in debugging the more complex version.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...