Difference between revisions of "Multi-displays Texture Cycler"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with '==Features== #Display all textures in sequence, distributed to all screens in the set. #Internal delay between each screen, to give some viewer time to load #Single script! ==Us...')
 
m (<lsl> tag to <source>)
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
==Features==
==Features==
#Display all textures in sequence, distributed to all screens in the set.
#Display all textures in sequence, distributed to all screens in the set.
#Internal delay between each screen, to give some viewer time to load
#Internal delay between each screen, to give viewer some time to load
#Single script!
#Single script!


Line 12: Line 12:


==Scripts==
==Scripts==
<lsl>
<source lang="lsl2">
float cycleTimer = 30;
float cycleTimer = 30;
list displays;
list displays;
Line 43: Line 43:
         string textureName = llGetInventoryName(INVENTORY_TEXTURE, currentTexture);
         string textureName = llGetInventoryName(INVENTORY_TEXTURE, currentTexture);
         key textureKey = llGetInventoryKey(textureName);
         key textureKey = llGetInventoryKey(textureName);
         if(textureKey == NULL_KEY) textureKey = textureEmpty;
         if(textureKey == NULL_KEY) textureKey = TEXTURE_BLANK;
              
              
         displayOn(llList2Integer(displays, i), textureName, textureKey);
         displayOn(llList2Integer(displays, i), textureName, textureKey);


         currentTexture = ++currentTexture % count;
         currentTexture = ++currentTexture % count;
         llSleep(0.2);
         llSleep(0.5);
     }
     }
}
}
Line 82: Line 82:
     }
     }
}
}
</lsl>
</source>

Latest revision as of 00:10, 25 January 2015

Features

  1. Display all textures in sequence, distributed to all screens in the set.
  2. Internal delay between each screen, to give viewer some time to load
  3. Single script!

Usage

  1. Link all screens into a linkset, with another root prim separate from the screens.
  2. Name all the screens as DISPLAY#n, where n is a number, starting from 1, 2, 3, ...
  3. Put all textures into the root prim
  4. Put the script in last
  5. Texture will be displayed on Side#1 of the prim. Make sure it is faced right.

Scripts

float cycleTimer = 30;
list displays;
integer totalDisplays;

integer currentTexture = 0;


displayOff(integer link){
    llSetLinkPrimitiveParamsFast(link, [
        PRIM_COLOR, 1, <0,0,0>, 1,
        PRIM_TEXTURE, 1, TEXTURE_BLANK, <1,1,0>, <0,0,0>, 0
    ]);
}

displayOn(integer link, string name, key texture){
    llSetLinkPrimitiveParamsFast(link, [
        PRIM_COLOR, 1, <1,1,1>, 1,
        PRIM_TEXTURE, 1, texture, <1,1,0>, <0,0,0>, 0,
        PRIM_TEXT, name, <1,1,1>, 1
    ]);
}

showTextures(){
    integer count = llGetInventoryNumber(INVENTORY_TEXTURE);
    if(count < 1) return;
        
    integer i;
    for(i=0; i<totalDisplays; ++i){
        string textureName = llGetInventoryName(INVENTORY_TEXTURE, currentTexture);
        key textureKey = llGetInventoryKey(textureName);
        if(textureKey == NULL_KEY) textureKey = TEXTURE_BLANK;
            
        displayOn(llList2Integer(displays, i), textureName, textureKey);

        currentTexture = ++currentTexture % count;
        llSleep(0.5);
    }
}


default{
    state_entry(){
        // Scan for displays
        integer i = llGetNumberOfPrims();
        string name;
        integer num;
        for(; i>0; --i){
            if(llGetSubString((name = llGetLinkName(i)), 0, 7) == "DISPLAY#"){
                num = (integer)llGetSubString(name, 8, -1);

                // Force the ID into link list
                while(llGetListLength(displays) < num) displays += [0];
                displays = llListReplaceList(displays, [i], num - 1, num - 1);
                
                // Prepare display screen
                displayOff(i);
            }                
        }

        totalDisplays = llGetListLength(displays);
        if(totalDisplays < 1)
            llOwnerSay("ERROR: No target display found! Please name target prims as \"DISPLAY#1\", \"DISPLAY#2\", ..., \"DISPLAY#n\"");
        else llSetTimerEvent(cycleTimer);
    }

    timer(){
        showTextures();
    }
}