4-button-prim

 

 

Scripts name 4-button-prim  
Purpose creates 4 touch-zones on a prim surface and gives landmarks, items, notecard or opens website - depending on the touched zone  
script lanugages used lsl  
important settings for region ./.  
test on osgrid - trunk  6.4  
source  osgrid forum  

 

 

 

 

// 1 prim, 4 button notecard, landmark, item, url giver
// drop 1 of each in the prim, paste web url in the description-box of the prim
// ( r-click on prim > Edit > General Tab > Description > your url )
//this script is free for all

// DEFINE THE GRID ON THE PRIM
integer GridColumns = 1;
integer GridRows = 4;
// INDEX FOR BUTTONS
list index;
// DEFINE BUTTONS, BOTTOM LEFT TO TOP RIGHT PLUS VARIOUS VARIABLES
list GridButtons = ["OBJECT4", "OBJECT3", "OBJECT2", "OBJECT1"];
string ButtonLabel;
integer ButtonIndex;
string ButtonWord;
//////////////////////////
default
{
    state_entry()
    {
        // CREATE AN INDEX OF COORDINATES BASED ON THE GRID
        integer y;
        for(y=0; y <= GridRows - 1; y++)
        {
            integer x;
            for(x=0; x <= GridColumns - 1; x++)
            {
                index += (list)((string)<(float)x,(float)y,0.0>);
            }
        }
    }
    touch_start(integer total_number)
    {
        // LOOK UP CLICKED BUTTON IN BUTTON INDEX LIST AND DO SOMETHING
        vector pos = llDetectedTouchST(0);
        integer x = llCeil(GridColumns * pos.x);
        integer y = llCeil(GridRows * pos.y);
        vector gridPos = <(float)x,(float)y,0.0>;
        gridPos = gridPos - <1.0,1.0,0.0>;
        // LOOK UP CLICKED BUTTON IN BUTTON INDEX LIST AND DO SOMETHING
        ButtonIndex = llListFindList(index, (list)((string)gridPos));
        if(ButtonIndex != -1)
        {
            // GET THE DATA FROM THE BUTTON, CHECK IT'S NOT EMPTY
            ButtonLabel = llList2String(GridButtons, ButtonIndex);
            if (ButtonLabel == "OBJECT1")

                //Give notecard
            {
                llGiveInventory(llDetectedKey(0),
                llGetInventoryName (INVENTORY_NOTECARD,0));
            }
            else if (ButtonLabel == "OBJECT2")
            {
                //give landmark
                llGiveInventory(llDetectedKey(0),
                llGetInventoryName (INVENTORY_LANDMARK,0));
            }
            else if (ButtonLabel == "OBJECT3")
            {
                //give item
                llGiveInventory(llDetectedKey(0),
                llGetInventoryName (INVENTORY_OBJECT,0));
            }
        else if (ButtonLabel == "OBJECT4")
        {
                //go to website
                string page = llGetObjectDesc();           
                llLoadURL(llDetectedOwner(0),"",page);
        }
    }
}
}