Public feed #890968

thumb texture setting

public text v1 · immutable
Raw Edit
·published 2008-02-04 06:28 UTC
rendered paste body
integer gListPos = 0;    //an integer to track current list position.
integer gListLength = 0;  //number of snapshots found.
string gCurrentSnap = "Snap01";    //a string, to be converted to from gListPos, relating to the name of each snapshot.
string gLastSnap = "Snap01"; //string for previous snap thumbnail.
string gNextSnap = "Snap01";  //string for next snap thumbnail.
string FORWARD = "forward_button";  // 2 constants based on button names, to determine which button was pressed.
string BACK = "back_button";

default
{
    state_entry()
    {
        gListLength = llGetInventoryNumber(INVENTORY_TEXTURE);  //finding number of textures stored, and setting an integer for it.
    }
    link_message(integer sender_num, integer num, string str, key id)
    {
        string lLinkName = llGetLinkName(sender_num);  //determining which button was pressed by getting button name from id.

        if (lLinkName == FORWARD)  //comparing button name with constants.
        {
            if (gListPos == gListLength -1)    //Branch to reset gListPos to 0 when it hits the end of the list.
            {
                gListPos = 0;
            }
            else 
            {
                ++gListPos;    //increment on touch, to move through the snapshots.
            }
        }
        else if (lLinkName == BACK)
        {
           if (gListPos == 0)    //Branch to reset ListPos to max when it hits the bottom of the list.
            {
                gListPos = (gListLength - 1);
            }
            else 
            {
                --gListPos;    //decrement on touch, to move through the snapshots.
            }
        }
        gCurrentSnap = llGetInventoryName(INVENTORY_TEXTURE, gListPos);    //Pulling the string name of current snapshot from the list for use in llSetTexture.
        if (gListPos == gListLength -1)    //Branch to reset gNextSnap to 0 when it hits the end of the list.
        {
            gNextSnap = llGetInventoryName(INVENTORY_TEXTURE, 0);
        }
        else
        {
            gNextSnap = llGetInventoryName(INVENTORY_TEXTURE, (gListPos + 1));  //setting to next snap.
        }
        if (gListPos == gListLength 0)    //Branch to reset gNextSnap to max when it hits the end of the list.
        {
            gNextSnap = llGetInventoryName(INVENTORY_TEXTURE, (gListLength - 1));
        }
        else
        {
            gNextSnap = llGetInventoryName(INVENTORY_TEXTURE, (gListPos - 1);  //setting to next snap.
        }
        llSetTexture(gCurrentSnap, ALL_SIDES);  //Setting snapshot!
        llSay(PUBLIC_CHANNEL, "Displaying picture " + (string)(gListPos +1) + "/" + (string)gListLength);
    }
}