Neverworld Grid

You are not logged in. Would you like to login or register?



6/10/2019 6:01 pm  #1


Region Terrain Leveler

Dangerous. This will level your entire region to either zero meters or the level of the prim. Just click on the prim

/*
                Logan's Region Leveler wth menu V 1.2
                Copylefted April/06/2019 - Logan "Smexypants" Stargazer

                DANGER DANGER DANGER DANGER DANGER DANGER DANGER 
                This script can and WILL mess up your land. It is designed for leveling the entire
                region in one shot.
                DANGER DANGER DANGER DANGER DANGER DANGER DANGER 

                There are two options:
                A Level the land to 0 meters
                B Level the land to the level of the prim

                To use just put the script into a prim and click on it for a menu

                To raise the land just move the prim to whatever altitude you want and choose B.
                To lower it first choose A to get the land out of the way, move the prim, then choose B.
                
                DANGER DANGER DANGER DANGER DANGER DANGER DANGER  
                This script can and WILL mess up your land. It is designed for leveling the entire
                region in one shot.
                DANGER DANGER DANGER DANGER DANGER DANGER DANGER 

                Updates:
                No more multiple menu options. There are only two now.
                The level is automagic now.
*/


list gNames = ["A","B"];  // Your list of potential menu choices
integer gMenuPosition;  // Index number of the first button on the current page
integer gLsn;   // Dialog Listen Handle

vector Location;
vector RegionSize;

Menu()
{
    integer Last; 
    list Buttons;
    integer All = llGetListLength(gNames);
    if(gMenuPosition >= 9)   //This is NOT the first menu page
    {
        Buttons += "    <----";
        if((All - gMenuPosition) > 11)  // This is not the last page
        {
            Buttons += "    ---->";
        }
        else    // This IS the last page
        {
            Last = TRUE;
        }            
    }    
    else if (All > gMenuPosition+9) // This IS the first page
    {
        if((All - gMenuPosition) > 11)  // There are more pages to follow
        {
            Buttons += "    ---->";
        }
        else    // This IS the last page
        {
            Last = TRUE;
        }            
    }
    else    // This is the only menu page
    {
        Last = TRUE;
    }
    if (All > 0)
    {
        integer b;
        integer len = llGetListLength(Buttons);
        // This bizarre test does the important work ......        
        for(b = gMenuPosition + len + Last - 1 ; (len < 12)&&(b < All); ++b)
        {
            Buttons = Buttons + [llList2String(gNames,b)];
            len = llGetListLength(Buttons);
        }
    }
    gLsn = llListen(-12345,"","","");    
    llSetTimerEvent(10.0);
    llDialog(llGetOwner(),"Choose wisely:\n \nA = Level region to 0 Meters\nB = Level region to Prim\n",Buttons,-12345);
}

LevelLand(float x, float y, float z)
{
        integer i; integer j;
        
        for (i = 1; i < x; i++)
        {
            for (j = 1; j < y; j++)
            {
                osSetTerrainHeight(i, j, z);
            }
        }
        osTerrainFlush();
    }


default
{
    touch_start(integer num)
    {
         RegionSize = osGetRegionSize();
         Location = llGetPos();

        llListenRemove(gLsn);
        gMenuPosition = 0;
        Menu();
    }
    
    listen(integer channel, string name, key id, string msg)
    {
        llListenRemove(gLsn);
        llSetTimerEvent(0.0);
        if (~llSubStringIndex(msg,"---->"))
        {
            gMenuPosition += 10;
            Menu();
        }
        else if (~llSubStringIndex(msg,"<----"))
        {
            gMenuPosition -= 10;
            Menu();
        }
        else if (msg == "A")
        {
            LevelLand(RegionSize.x,RegionSize.y, 0);
        }
        else if (msg == "B")
        {
            LevelLand(RegionSize.x,RegionSize.y, Location.z);
        }

        else
        {
            //Do whatever the selected button directs..... your choice
        }
    }
    
    timer()
    {
        llSetTimerEvent(0.0);
        llListenRemove(gLsn);
    }
}

 

Board footera

 

Powered by Boardhost. Create a Free Forum