Public feed #891033

console c

public text v1 · immutable
Raw Edit
·published 2008-02-04 08:23 UTC
rendered paste body
integer x = 0;  //a for loop variable.
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";
integer gPrimCount = 0;  //total number of prims in object.
string LAST = "last thumb"; //constant to search for last snap thumbnail.
string NEXT = "next thumb";  //constant to search for next snap thumbnail.


default
{
    state_entry()
    {
        gPrimCount = llGetNumberOfPrims();
        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 == 0)    //Branch to reset gLastSnap to max when it hits the end of the list.
        {
            gLastSnap = llGetInventoryName(INVENTORY_TEXTURE, (gListLength - 1));
        }
        else
        {
            gLastSnap = llGetInventoryName(INVENTORY_TEXTURE, (gListPos - 1));  //setting to next snap.
        }
        llSetTexture(gCurrentSnap, ALL_SIDES);  //Setting snapshot!
        for (x = 1; x <= gPrimCount; x++)  //loop to check names of all links to find thumbs.
        {
            if (llGetLinkName(x) == LAST) llSetLinkTexture(x, gLastSnap, ALL_SIDES);  //if prim is a last thumb, last snap is set.
            else if (llGetLinkName(x) == NEXT) llSetLinkTexture(x, gNextSnap, ALL_SIDES);  //if prim is a next thumb, next snap is set.
        }
        llSay(PUBLIC_CHANNEL, "Displaying picture " + (string)(gListPos +1) + "/" + (string)gListLength);
    }
}