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.
Alternatively you can display it inworld as a wall hanging.
TROUBLESHOOTING
The PREVIOUS and NEXT buttons will work only if they are linked as child-prims with the ScreenHUD as the root prim.
Enjoy.