INDEX

FRONT INDEX

[script] 3 Prim Slideshow

 

Get this item in my shop for free


Screen Prim Script


This version dynamically cycles through all textures in the same prim as the script:


// Configuration

integer currentTextureIndex = 0; 

// Tracks the currently displayed texture index

integer screenFace = 1;        

 // The face on the Screen prim to display textures

// Function to update the texture

updateTexture() 

{

    integer textureCount = llGetInventoryNumber(INVENTORY_TEXTURE); 

// Get the total number of textures

    if (textureCount > 0) 

{

        string textureName = llGetInventoryName(INVENTORY_TEXTURE, currentTextureIndex);

        if (textureName != "") 

{

            llSetTexture(textureName, screenFace);

        } else {

            llOwnerSay("Error: Texture not found in inventory.");

        }

    } else {

        llOwnerSay("No textures found in this prim.");

    }

}


// Listen for button presses from linked prims

default {

    state_entry() {

        llOwnerSay("Script initialized. Screen ready.");

        updateTexture();

    }


    link_message(integer sender_link, integer num, string str, key id) {

        integer textureCount = llGetInventoryNumber(INVENTORY_TEXTURE); // Get the current texture count

        if (textureCount > 0) {

            if (str == "Next") {

                currentTextureIndex = (currentTextureIndex + 1) % textureCount;

                updateTexture();

            } else if (str == "Previous") {

                currentTextureIndex = (currentTextureIndex - 1 + textureCount) % textureCount;

                updateTexture();

            }

        }

    }

}



Next Button Script 


//place in child linked prim called NEXT


default {

    touch_start(integer num_detected) {

        llMessageLinked(LINK_ROOT, 0, "Next", NULL_KEY);

    }

}



Previous Button Script


//place in child linked prim called PREVIOUS


default {

    touch_start(integer num_detected) {

        llMessageLinked(LINK_ROOT, 0, "Previous", NULL_KEY);

    }

}




How It Works


1. The Screen prim dynamically retrieves all textures in its inventory when the script is initialized or when a button is pressed.


2. The Next and Previous buttons send a message to the Screen prim to cycle through the textures.


3. The script calculates the texture index dynamically, ensuring smooth cycling without requiring manual input for the number of textures.




INSTRUCTIONS


Make a back-up of the linked set of 3 prims called: 

<> SCREEN HUD 

Rez the object in the environment. 

Right-Click the object to select Edit/Content. 

It contains a Script called:
[screenHUD] main script

You can rename this prim. 
It will make things easier for you to find it in your inventory. 
Renaming it does not affect the scripts. 
Renaming the child prims called NEXT and PREVIOUS does affect the scripts. 
Don't do it. 
If you do it, change the names back ASAP to get the scripts to work. 

Drag your favourite art Textures from your inventory into the root prim, 
which is the one originally called: 
<> SCREEN HUD

There is no maximum to the number of textures you can drag into the root prim. 
The textures are automagically ordered alphabetically by their names. 
You can name and number them to your hearts content. 

When happy with your Screen HUD content, 
right-click and Take A Copy into your inventory. 
Find it in your inventory in Objects and right-click on it for the drop-down menu.
Choose ADD or Attach To HUD / Center.

The interface is simple: 
PREVIOUS and NEXT buttons change the texture displayed in the SCREEN HUD prim.

Alternatively you can display it inworld as a wall hanging. 

TROUBLESHOOTING

If you get stuck with rotating the HUD to see the display face of the Screen prim; 
rez it, look toward sunrise, rotate the object so you can see the display face; the display face faces sunset.
Right-click to Take Copy then Attach to HUD. 
It should display okay. 

The PREVIOUS and NEXT buttons will work only if they are linked as child-prims with the ScreenHUD as the root prim. 

Enjoy.