Jump to content

Marquee-Style Texture Display


Rolig Loon
 Share

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

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

Recommended Posts

There are many ways to build texture display systems.  This one is fairly straightforward and easy to modify.

// Marquee-Style Texture display  -- Rolig Loon -- October 2012
//
// A basic display system that might be built into a texture sorter, for example, or a marquee display.
//    Textures display on face #4, which will work well for a HUD, if you want to do that.
//
// To use, you must have a linkset with cube prims --- any number of prims you want.  
//    (1) Name each of the prims you will use for a texture display "display".
//    (2) Name one prim "forward".  That will be your Forward button.
//    (3) Name one other prim "reverse". That will be .... tada! .. your Reverse button
//    (4) Any other prims in the linkset will be ignored.
// Add any number of textures to your object's Contents.

list gTex;
list gPrims;
list gTxOnPrim;
integer gCount;

default
{
    state_entry()
    {
        gCount = 100000000;  //  A nice high integer that's unlikely to ever go negative as you hit the "reverse" button
        integer i;
        for (i=0;i<llGetInventoryNumber(INVENTORY_TEXTURE);++i) // Load the texture names
        {
            gTex += llGetInventoryName(INVENTORY_TEXTURE,i);
        }
        integer Q = (gTex !=[]);
        for (i=1;i<=llGetNumberOfPrims();++i)
        {
            if (llToLower(llGetLinkName(i)) == "display")  // Identify the "display" prims and load a texture on each one to start
            {
                gPrims += [i];
                string temp = llList2String(gTex,(i + gCount)%Q);
                llSetLinkPrimitiveParamsFast(i,[PRIM_TEXTURE,4,temp,<1.0,1.0,1.0>,ZERO_VECTOR,0.0]);
                gTxOnPrim += [temp];
            }
        }
    }
    
    changed (integer change)
    {
        if (change & CHANGED_INVENTORY)
        {
            llResetScript();
        }
    }

    touch_start(integer total_number)
    {
        integer idx = llListFindList(gPrims,[llDetectedLinkNumber(0)]); //Touch any "display" prim to see the name of the displayed texture
        if (~idx)
        {
            llSay(0,llList2String(gTxOnPrim,idx));
        }
        else    // Touch the "forward" or "reverse" prim to advance textures from one "display" prim to the next.
        {
            gTxOnPrim = [];
            integer Q = (gTex !=[]);
            if(llToLower(llGetLinkName(llDetectedLinkNumber(0))) == "reverse")
            {
                --gCount;
            }        
            else if (llToLower(llGetLinkName(llDetectedLinkNumber(0))) == "forward")
            {
                ++gCount;
            }
            integer i;
            while(i < (gPrims !=[]))
            {
                string temp = llList2String(gTex,(i + gCount)%Q);
                llSetLinkPrimitiveParamsFast(llList2Integer(gPrims,i),[PRIM_TEXTURE,4,temp,<1.0,1.0,1.0>,ZERO_VECTOR,0.0]);
                gTxOnPrim += [temp];
                ++i;
            }
        }
    }
}

 

Link to comment
Share on other sites

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