Jump to content
Sign in to follow this  
Rolig Loon

Marquee-Style Texture Display

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;
            }
        }
    }
}

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...