Jump to content

HUD Textur change on wearing clothes


Kwezalcoatl
 Share

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

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

Recommended Posts

Hello ist's me again ...

 

I found a script where i can change textures on a prim. I do insert the script in a prim, together with some textures. So far so good- it works - on click ta menu appears and i can change the texture. But if i wear the prim it do not work no more. i can click on it but nothing happen.

But my idea is to change the texture in my clothes with a hud. I m little confused where i have to put the textures and how the textures can change ...

This is the line in my script wo set teh texture :

                "llSetTexture(message, side);"

I checked so much scripts but i did not found the right, now i m confused.
Thanks for any help.
With kind regards

Link to comment
Share on other sites

1 hour ago, Wulfie Reanimator said:

Post the whole script.

//Drop this script into an object with up to 36 textures inside.

//When anyone Touches they will get a menu with all the textures available. Button names in menu will be first 10 characters from that item's name. 

//NOTE: Texture Names may not exceed 24 characters or script error and menu fails.


integer side = ALL_SIDES; //ALL_SIDES or any face number 0 through 5

list texture_list;
list texture_list2;
key user = NULL_KEY;

composelist()
{
    integer currenttexture = 0;
    integer totaltextures = llGetInventoryNumber(INVENTORY_TEXTURE);
    
    if(totaltextures > 0 & totaltextures <= 12)
    {
        texture_list = [];
        do
        {
            texture_list = texture_list + llGetInventoryName(INVENTORY_TEXTURE, currenttexture);
            currenttexture++;
        }
        while (currenttexture > 0 & currenttexture < totaltextures);
    }
    
    if(totaltextures > 12 & totaltextures <= 36)
    {
        texture_list = ["Next Page"];
        do
        {
            texture_list = texture_list + llGetInventoryName(INVENTORY_TEXTURE, currenttexture);
            currenttexture++;
        }
        while (currenttexture > 0 & currenttexture < 11);
        
        texture_list2 = ["Last Page"];
        do
        {
            texture_list2 = texture_list2 + llGetInventoryName(INVENTORY_TEXTURE, currenttexture);
            currenttexture++;
        }
        while (currenttexture >= 11 & currenttexture < totaltextures);
    }
    
    if(totaltextures > 36)
    {
        llWhisper(0, "You may only have a maximimum of 36 Textures. Please remove any extra ones.");
    }
    if(totaltextures == 0)
    {
        llWhisper(0, "Please add up to 36 Textures inside this object.");
    }
}


//The Menu
integer menu_handler;
integer menu_channel;
menu(key user,string title,list texture_list)
{
    menu_channel = (integer)(llFrand(99999.0) * -1); //random channel
    menu_handler = llListen(menu_channel,"","","");
    llDialog(user,title,texture_list,menu_channel);
    llSetTimerEvent(30.0); //menu channel open for 30 seconds
}

default
{
    state_entry()
    {
        composelist(); //make list from inventory textures
    }

    touch_start(integer total_number)
    {
        user = llDetectedKey(0);
        menu(user,"nnPlease select one below.",texture_list);
    }
    
    listen(integer channel,string name,key id,string message)
    {
        if (channel == menu_channel)
        {
            llSetTimerEvent(0.0);
            llListenRemove(menu_handler);
            if(message == "Next Page")
            {
                menu(user,"nnPlease select one below.",texture_list2);
            }
            else if(message == "Last Page")
            {
                menu(user,"nnPlease select one below.",texture_list);
            }
            else
            {
                llSetTexture(message, side);
            }
        }
    }
    
    timer() //Close the Menu Listen or we'll get laggy
    {
        llSetTimerEvent(0.0); 
        llListenRemove(menu_handler);
    }
    
    changed(integer change) 
    {
        if (change & CHANGED_INVENTORY) //inventory has changed
        {
            llSleep(0.5);
            composelist(); //rebuild the list
        }
    }
}

Hello - this works good if rezzed on land. But i want to do from a HUD but on some clothes i did to change the textures. Actually i have a complete blockade to find the begin of the filament... get permission request permission . im lost.

 

Greetings

Kwezalcoatl

Link to comment
Share on other sites

8 hours ago, Kwezalcoatl said:

Hello - this works good if rezzed on land. But i want to do from a HUD but on some clothes i did to change the textures. Actually i have a complete blockade to find the begin of the filament... get permission request permission . im lost.

 

Greetings

Kwezalcoatl

First of all the clothing need to be mod - the most easy thing is to place the script in the inventory of the clothing item along with the textures.

Examine what faces of the mesh need to be textured - ALL_SIDES will texture everything.

A more simple approach, where we just use 3 textures to keep it simple and understandable:

integer side = ALL_SIDES; //ALL_SIDES or any face number 0 through 5
list listTextures;
integer nMenuHandle;
integer nMenuChannel;

default
{
    state_entry()
    {
        // get list of textures in inventory
        integer nCount = llGetInventoryNumber(INVENTORY_TEXTURE);
        string  strName;
        while (nCount--)
        {
            strName = llGetInventoryName(INVENTORY_TEXTURE, count);
            if (strName != llGetScriptName())  
                listTextures += strName;
        }    
        
        nMenuChannel = (integer)(llFrand(99999.0) * -1); //random channel
        nMenuHandle = llListen( nMenuChannel,"","","");
    }

    touch_start(integer total_number)
    {
        llSetTimerEvent(180.0); //menu channel open for 180 seconds
        key id = llDetectedKey(0);
        llDialog( id, "\nSelect",  ["1", "2", "3"], nMenuChannel);        
    }
    
    listen(integer channel,string name,key id,string message)
    {
        if (channel == nMenuChannel)
        {
            integer n= ((integer)message)-1;
            llSetTexture( llList2String( listTextures, n), side);
        }
    }
    
    timer() //Close the Menu Listen or we'll get laggy
    {
        llSetTimerEvent(0.0); 
        llListenRemove(nMenuHandle);
    }
    
    changed(integer change) 
    {
        if (change & CHANGED_INVENTORY) //inventory has changed
        {
            llResetScript();
        }
    }
}

Now original you used name of texture, here we use numbers and select relevant texture accordingly. With the original approach you would need to handle max button size of 12 chars of texture names may longer and maybe even in Unicode... Keep it simple!

A more professional approach would be a HUD and a listener script in the clothing listening to the HUD and where the textures are UUID from relevant textures in your inventory or from someone else. But get a grip of the basic first and learn to program in LSL before doing it with HUD and listener script.

Happy coding and have fun 😁

 

Link to comment
Share on other sites

16 hours ago, Rachel1206 said:

A more professional approach would be a HUD and a listener script in the clothing listening to the HUD and where the textures are UUID from relevant textures in your inventory or from someone else. But get a grip of the basic first and learn to program in LSL before doing it with HUD and listener script.

Rachel thank you for your kind comment, is about 22 textures ...

THIS S EXACTLY WHAT I FINALLY WANT a hud .. but sighs wher the texture put in? in the hud or the clothes? What is the listener script -

Link to comment
Share on other sites

12 hours ago, Wulfie Reanimator said:

The script works fine while wearing it.

I am sorry wulfie - if i wear it (all on mod, texture and cloth and the creator wear it itself) i become a strange pose - like going toilett, turn around - and no menu appear, so i can't change the texture. Any Idea? Is good if i only receive a key word do i can research on that.

EDIT - lol - it works if i rightklick, click more and then 'touch' ... i m sorry but a HUD willl be great

Thank you :)

Greetings

Kwezalcoatl

Edited by Kwezalcoatl
Link to comment
Share on other sites

44 minutes ago, Kwezalcoatl said:

i m sorry but a HUD willl be great

Maybe so, but you don't have a HUD script there. Maybe somebody can help you find one in a script library -- it's a common enough usage -- or you might be able to get one on Marketplace.

To clarify, a script in one object cannot change textures directly on any other object, so a HUD never directly changes textures of clothing - that's why a "listener" script is needed. The listener script resides in the clothing and listens for the HUD script to tell it what to do.

Once you've got those two scripts communicating, you can put the textures in the clothing and have the HUD tell the listener by name which texture to use, or if you have full permissions on the textures you can have the HUD simply tell the clothing the UUID (or "key") of the desired texture, and just keep the actual textures in your own Inventory.

This all assumes you're doing this for yourself only. If this is for a commercial product that others will use, you'll need to decide how much you care about others potentially using your textures, and go to some trouble (and possibly expense) for a script that protects that intellectual property.

Link to comment
Share on other sites

3 hours ago, Qie Niangao said:

To clarify, a script in one object cannot change textures directly on any other object, so a HUD never directly changes textures of clothing - that's why a "listener" script is needed. The listener script resides in the clothing and listens for the HUD script to tell it what to do.

Thank you very much QIE - i got good help here in that topic and i can say i reached my aim for this project, it works even with 26 textures ;) - but i will come back soon :)

 

Thank you all

Kwezalcoatl - the feathered snake

Edited by Kwezalcoatl
  • Like 1
Link to comment
Share on other sites

10 hours ago, Kwezalcoatl said:

Rachel thank you for your kind comment, is about 22 textures ...

THIS S EXACTLY WHAT I FINALLY WANT a hud .. but sighs wher the texture put in? in the hud or the clothes? What is the listener script -

Do you read what I wrote? ... the most easy thing is to place the script in the inventory of the clothing item along with the textures.

Use my example, extend it to 22 textures, when you got the basics - hint, you need to handle multi pages in the dialog.

  • Like 1
Link to comment
Share on other sites

On 11/19/2020 at 5:17 AM, Rachel1206 said:

Do you read what I wrote? ... the most easy thing is to place the script in the inventory of the clothing item along with the textures.

Yes i got this ... i finish it and as next i try the HUD thing :) i will come back ...

Thank you very much

Edited by Kwezalcoatl
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1395 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...