Jump to content

Texture Changer with Two Buttons


KiondraeLoc
 Share

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

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

Recommended Posts

I want to make a script containing a next and previous button(s) to scroll trough a large amount of textures. Should I make a main script that uses llSay(); with a listen script in the listener prim or should I do one script that calls on the names of the prims in the linkset? Also what LSL functions would be required to achieve this?

Edited by KiondraeLoc
Link to comment
Share on other sites

It's fairly straightforward to do it with one script.  As long as the script is in the root of the linkset, you can detect which button was touched with llDetectedLinkNumber and than act on the result.  Unless you really want to reinvent the wheel, you may want to adapt Sendao Goodman's classic slide changer script for your purpose.  At least take a look to see one way to handle the logic.

Link to comment
Share on other sites

11 minutes ago, Rolig Loon said:

It's fairly straightforward to do it with one script.  As long as the script is in the root of the linkset, you can detect which button was touched with llDetectedLinkNumber and than act on the result.  Unless you really want to reinvent the wheel, you may want to adapt Sendao Goodman's classic slide changer script for your purpose.  At least take a look to see one way to handle the logic.

The script works and I can modify it in Second Life, I just wish the buttons worked like that in Opensimulator as well. I wonder what functions I should change to make it work in Opensimulator.

Link to comment
Share on other sites

Probably best to find somebody who still uses OpenSim, but in the meantime could you tell us what happens differently there? The function list at that link suggests that llSetLinkPrimitiveParamsFast() may not be implemented (although the list itself appears very old), and if that happens to be the problem, the script could be fairly easily changed to use the slower llSetLinkPrimitiveParams() without big delay by consing-up the whole list of parameters to be changed on each affected side of each affected link before calling the function. (As long as a script has plenty of memory, that's better practice for either function anyway because it pushes fewer object update messages out the sim into the aether to everybody's viewers.)

Link to comment
Share on other sites

9 hours ago, KiondraeLoc said:

I want to make a script containing a next and previous button(s) to scroll trough a large amount of textures. Should I make a main script that uses llSay(); with a listen script in the listener prim or should I do one script that calls on the names of the prims in the linkset? Also what LSL functions would be required to achieve this?

 

7 hours ago, KiondraeLoc said:

The script works and I can modify it in Second Life, I just wish the buttons worked like that in Opensimulator as well. I wonder what functions I should change to make it work in Opensimulator.

 

You could do something like...

//You would put the uuid key of your textures in here like this
list textures=[
    "00000000-0000-0000-0000-000000000000",
    "00000000-0000-0000-0000-000000000000",
    "00000000-0000-0000-0000-000000000000"
];

integer textureIndex; //How far through the above list of textures we have moved

integer textureLink=1;  //Change to the link number to display the texture
integer rightButton=2;  //Change to the link number of the right button
integer leftButton=3;   //Change to the link number of the left button

default{
    state_entry(){
        //Here so that everytime you save, add a new texture etc it will reset the image being displayed back to the first image in the list
        textureIndex=0;
        llSetLinkTexture(textureLink,llList2String(textures,textureIndex),ALL_SIDES);
    }
    
    //You can use llSetLinkPrimitiveParams as well to change the texture but as you seem to be a learner and because its simpler for a learner to understand iv used llSetLinkTexture

    touch_start(integer x){
        //Change "right button" and "left button" to the link number of the buttons you are pressing
        if(llDetectedLinkNumber(0)==rightButton){
            //Move down through the textures or "to the right"
            ++textureIndex;
            //Display the texture
            llSetLinkTexture(textureLink,llList2String(textures,textureIndex),ALL_SIDES);
            //Check if we have reached the end of the list and if so go back to the start
            if(textureIndex==llGetListLength(textures))textureIndex=0;
        }else if(llDetectedLinkNumber(0)==leftButton){
            //Move up through the textures or "to the left"
            --textureIndex;
            //Display the texture
            llSetLinkTexture(textureLink,llList2String(textures,textureIndex),ALL_SIDES);
            //Check if we have reached the start of the list go back to the end
            if(textureIndex==llGetListLength(textures))textureIndex=llGetListLength(textures)-1;
        }
    }
}

As I said in the script I used llSetLinkTexture but you can use llSetLinkPrimitiveParamsFast if you have gotten that far in your learning. But this script will work for open sim also as all of the above functions, including llSetLinkPrimitiveParamsFast should you choose to use it, are available for use in open sim.

The llSetLinkPrimitiveParamsFast way of changing texture would be...

Instead of : llSetLinkTexture(textureLink,llList2String(textures,textureIndex),ALL_SIDES);

Use : llSetLinkPrimitiveParamsFast(textureLink, [PRIM_TEXTURE, ALL_SIDES, llList2String(textures,textureIndex), <1.0,1.0,1.0>, <0.0,0.0,0.0>, 0.0]);

Edited by chibiusa Ling
Link to comment
Share on other sites

18 hours ago, chibiusa Ling said:

 

 

You could do something like...


//You would put the uuid key of your textures in here like this
list textures=[
    "00000000-0000-0000-0000-000000000000",
    "00000000-0000-0000-0000-000000000000",
    "00000000-0000-0000-0000-000000000000"
];

integer textureIndex; //How far through the above list of textures we have moved

integer textureLink=1;  //Change to the link number to display the texture
integer rightButton=2;  //Change to the link number of the right button
integer leftButton=3;   //Change to the link number of the left button

default{
    state_entry(){
        //Here so that everytime you save, add a new texture etc it will reset the image being displayed back to the first image in the list
        textureIndex=0;
        llSetLinkTexture(textureLink,llList2String(textures,textureIndex),ALL_SIDES);
    }
    
    //You can use llSetLinkPrimitiveParams as well to change the texture but as you seem to be a learner and because its simpler for a learner to understand iv used llSetLinkTexture

    touch_start(integer x){
        //Change "right button" and "left button" to the link number of the buttons you are pressing
        if(llDetectedLinkNumber(0)==rightButton){
            //Move down through the textures or "to the right"
            ++textureIndex;
            //Display the texture
            llSetLinkTexture(textureLink,llList2String(textures,textureIndex),ALL_SIDES);
            //Check if we have reached the end of the list and if so go back to the start
            if(textureIndex==llGetListLength(textures))textureIndex=0;
        }else if(llDetectedLinkNumber(0)==leftButton){
            //Move up through the textures or "to the left"
            --textureIndex;
            //Display the texture
            llSetLinkTexture(textureLink,llList2String(textures,textureIndex),ALL_SIDES);
            //Check if we have reached the start of the list go back to the end
            if(textureIndex==llGetListLength(textures))textureIndex=llGetListLength(textures)-1;
        }
    }
}

As I said in the script I used llSetLinkTexture but you can use llSetLinkPrimitiveParamsFast if you have gotten that far in your learning. But this script will work for open sim also as all of the above functions, including llSetLinkPrimitiveParamsFast should you choose to use it, are available for use in open sim.

The llSetLinkPrimitiveParamsFast way of changing texture would be...

Instead of : llSetLinkTexture(textureLink,llList2String(textures,textureIndex),ALL_SIDES);

Use : llSetLinkPrimitiveParamsFast(textureLink, [PRIM_TEXTURE, ALL_SIDES, llList2String(textures,textureIndex), <1.0,1.0,1.0>, <0.0,0.0,0.0>, 0.0]);

This helps me understand how it works better, thank you. 

Link to comment
Share on other sites

18 hours ago, chibiusa Ling said:

 

 

You could do something like...


//You would put the uuid key of your textures in here like this
list textures=[
    "00000000-0000-0000-0000-000000000000",
    "00000000-0000-0000-0000-000000000000",
    "00000000-0000-0000-0000-000000000000"
];

integer textureIndex; //How far through the above list of textures we have moved

integer textureLink=1;  //Change to the link number to display the texture
integer rightButton=2;  //Change to the link number of the right button
integer leftButton=3;   //Change to the link number of the left button

default{
    state_entry(){
        //Here so that everytime you save, add a new texture etc it will reset the image being displayed back to the first image in the list
        textureIndex=0;
        llSetLinkTexture(textureLink,llList2String(textures,textureIndex),ALL_SIDES);
    }
    
    //You can use llSetLinkPrimitiveParams as well to change the texture but as you seem to be a learner and because its simpler for a learner to understand iv used llSetLinkTexture

    touch_start(integer x){
        //Change "right button" and "left button" to the link number of the buttons you are pressing
        if(llDetectedLinkNumber(0)==rightButton){
            //Move down through the textures or "to the right"
            ++textureIndex;
            //Display the texture
            llSetLinkTexture(textureLink,llList2String(textures,textureIndex),ALL_SIDES);
            //Check if we have reached the end of the list and if so go back to the start
            if(textureIndex==llGetListLength(textures))textureIndex=0;
        }else if(llDetectedLinkNumber(0)==leftButton){
            //Move up through the textures or "to the left"
            --textureIndex;
            //Display the texture
            llSetLinkTexture(textureLink,llList2String(textures,textureIndex),ALL_SIDES);
            //Check if we have reached the start of the list go back to the end
            if(textureIndex==llGetListLength(textures))textureIndex=llGetListLength(textures)-1;
        }
    }
}

As I said in the script I used llSetLinkTexture but you can use llSetLinkPrimitiveParamsFast if you have gotten that far in your learning. But this script will work for open sim also as all of the above functions, including llSetLinkPrimitiveParamsFast should you choose to use it, are available for use in open sim.

The llSetLinkPrimitiveParamsFast way of changing texture would be...

Instead of : llSetLinkTexture(textureLink,llList2String(textures,textureIndex),ALL_SIDES);

Use : llSetLinkPrimitiveParamsFast(textureLink, [PRIM_TEXTURE, ALL_SIDES, llList2String(textures,textureIndex), <1.0,1.0,1.0>, <0.0,0.0,0.0>, 0.0]);

//You would put the uuid key of your textures in here like this
list textures;

integer textureIndex; //How far through the above list of textures we have moved

integer textureLink=1;  //Change to the link number to display the texture
integer rightButton=2;  //Change to the link number of the right button
integer leftButton=3;   //Change to the link number of the left button

default{
    state_entry(){
        //Here so that everytime you save, add a new texture etc it will reset the image being displayed back to the first image in the list
        textureIndex=0;
       llSetLinkTexture(textureLink,llList2String(llGetInventoryNumber(INVENTORY_TEXTURE),textureIndex),ALL_SIDES);
    }
    
    //You can use llSetLinkPrimitiveParams as well to change the texture but as you seem to be a learner and because its simpler for a learner to understand iv used llSetLinkTexture

    touch_start(integer x){
        //Change "right button" and "left button" to the link number of the buttons you are pressing
        if(llDetectedLinkNumber(0)==rightButton){
            //Move down through the textures or "to the right"
            ++textureIndex;
            //Display the texture
            llSetLinkTexture(textureLink,llList2String(llGetInventoryNumber(INVENTORY_TEXTURE),textureIndex),ALL_SIDES);
            //Check if we have reached the end of the list and if so go back to the start
            if(textureIndex==llGetListLength(textures))textureIndex=0;
        }else if(llDetectedLinkNumber(0)==leftButton){
            //Move up through the textures or "to the left"
            --textureIndex;
            //Display the texture
           llSetLinkTexture(textureLink,llList2String(llGetInventoryNumber(INVENTORY_TEXTURE),textureIndex),ALL_SIDES);
            //Check if we have reached the start of the list go back to the end
            if(textureIndex==llGetListLength(textures))textureIndex=llGetListLength(textures)-1;
        }
    }
}

I thought maybe adding llGetInventoryNumber(INVENTORY_TEXTURE) in place of textures would allow me to drop textures in the root prim and it would automatically detect them, but that puts me back at step one, trying to figure out how to make it work. What should I change to get it to detect the textures automatically so I don't have to update the list if I add, say 157 textures?

Link to comment
Share on other sites

Here is a tip if you want your texture to appear quicker. If you target a separate hidden prim .010 x .010 x .010 that you do not see for a second before it loads onto the prim you wish to display the image, it will load instantly because you already have loaded that texture. Basically you are loading the texture without seeing it first.

Think llpreloadsound but for textures. If you are dealing with many textures, it might be something you can use.

I come up with this idea when I came back to second life. It works pretty good for me.

Edited by AngeliqueMinogue
Link to comment
Share on other sites

6 minutes ago, AngeliqueMinogue said:

Here is a tip if you want your texture to appear quicker. If you target a separate hidden prim .010 x .010 x .010 that you do not see for a second before it loads onto the prim you wish to display the image, it will load instantly because you already have loaded that texture. Basically you are loading the texture without seeing it first.

Think llpreloadsound but for textures. If you are dealing with many textures, it might be something you can use.

I come up with this idea when I came back to second life. It works pretty good for me.

You can load six on one prim and roll it face by face.

Link to comment
Share on other sites

2 minutes ago, steph Arnott said:

Yes, use a listen function and event.

//  Says beep to owner the first time owner says something in main chat
//  and then stops listening
 
integer listenHandle;
 
remove_listen_handle()
{
    llListenRemove(listenHandle);
}
 
default
{
    state_entry()
    {
//      Change the channel number to a positive integer 
//      to listen for '/5 hello' style of chat.
 
//      target only the owner's chat on channel 0 (PUBLIC_CHANNEL)
        listenHandle = llListen(0, "", llGetOwner(), "");
    }
 
    listen(integer channel, string name, key id, string message)
    {
//      we filtered to only listen on channel 0
//      to the owner's chat in the llListen call above
 
        llOwnerSay("beep");
 
//      stop listening until script is reset
        remove_listen_handle();
    }
 
    on_rez(integer start_param)
    {
        llResetScript();
    }
 
    changed(integer change)
    {
        if (change & CHANGED_OWNER)
        {
            llResetScript();
        }
    }
}

 

 

I want to change llOwnerSay("beep"); to a touch function and I'm not sure how to do that. What command will allow this?

Link to comment
Share on other sites

2 minutes ago, KiondraeLoc said:

//  Says beep to owner the first time owner says something in main chat
//  and then stops listening
 
 
default
{
    state_entry()
    {
//      Change the channel number to a positive integer 
//      to listen for '/5 hello' style of chat.
 
//      target only the owner's chat on channel 0 (PUBLIC_CHANNEL)
        llListen(0, "", llGetOwner(), "");
    }
 
    listen(integer channel, string name, key id, string message)
    {
//      we filtered to only listen on channel 0
//      to the owner's chat in the llListen call above
 
        llOwnerSay("beep");
 
//      stop listening until script is reset
    }
 
    on_rez(integer start_param)
    {
        llResetScript();
    }
 
    changed(integer change)
    {
        if (change & CHANGED_OWNER)
        {
            llResetScript();
        }
    }
}

 

 

I want to change llOwnerSay("beep"); to a touch function and I'm not sure how to do that. What command will allow this?

 

Link to comment
Share on other sites

3 minutes ago, steph Arnott said:

Can you decide what you want please as it is confusing.

I want to replace llOwnerSay("beep"); with a touch function that will let me change the texture right or left based on commands along side the buttons. I just don't know the right command to look up to use here. 

Link to comment
Share on other sites

21 minutes ago, KiondraeLoc said:

I want to replace llOwnerSay("beep"); with a touch function that will let me change the texture right or left based on commands along side the buttons. I just don't know the right command to look up to use here. 

So you want a touch event plus a channel event. Press the button it works, say something it works. That it?

Link to comment
Share on other sites

1 hour ago, KiondraeLoc said:

I want to replace llOwnerSay("beep"); with a touch function that will let me change the texture right or left based on commands along side the buttons. I just don't know the right command to look up to use here. 

then you simply take what is in the touch_start() event earlier posted and replace the 

if(llDetectedLinkNumber(0)==rightButton)

with

listen(integer channel, string name, key id, string message) {
	message = llToLower(message); 
	if (message == "next") {

	//same code to change your texture as before

	}
	else if (message == "previous") {
    
	//same code to change your texture as before
	
	}
}

(where "previous" and "next" are the commands you choose to switch to the next or previous texture)

Side comments:

I would not remove the listener if you want to use this command more than once (I think you did that already).

If you already reset the script on_rez event, no need to also reset it on changed for owner change as it has already reset before the change event occurred.

I don't see a reset reason on every rez though, so I would keep the changed event reset (but lets not try to confuse you now more than needed but one of these is surely enough).

 

 

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

6 hours ago, AngeliqueMinogue said:

Here is a tip if you want your texture to appear quicker. If you target a separate hidden prim .010 x .010 x .010 that you do not see for a second before it loads onto the prim you wish to display the image, it will load instantly because you already have loaded that texture. Basically you are loading the texture without seeing it first.

Think llpreloadsound but for textures. If you are dealing with many textures, it might be something you can use.

I come up with this idea when I came back to second life. It works pretty good for me.

That's exactly the way Sendao Goodman's script -- the one that the OP is using here, at my recommendation -- works. Goodman proposed the idea back in 2007.  It's been used heavily  in SL ever since.  😎

Edited by Rolig Loon
  • Thanks 1
Link to comment
Share on other sites

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