Terraforming again

I normally use Kayaker Magic’s product on the Kitely Market for terraforming in OpenSim but for some reason I couldn’t get it delivered on Wolf Territories Grid. I intend my presence there to be very light touch so decided I would improvise instead by making a large linkset of thin 1 m diameter cylinders. All that was then needed was a little piece of code placed in the root that iterated across the terraforming linkset (TL) and set terrain height at each cylinder’s location via the appropriate OSSL command. So by orienting the TL as desired I could with a single touch create flat surfaces on the horizontal or at an incline. In theory I could even edit the height of each prim and get more sophisticated effects.

However, one thing I wanted in particular was to be able to create paths that have shallow terraformed depressions to which textured prims could be added in the depression later. A simpler approach was to use colour to denote prims where terraforming was required. I used a short touch to toggle between white and green. The height increment or decrement from the prim height is a constant value defined as a float in the object’s description field. A long touch then terraforms according to the pattern. You can, of course, restore the colour en masse via the texture option in the build menu. The example below used a value of -0.25 in the description field.

To terraform on a larger scale I created a linkset of thin box prims, each the size of the TL with the TL in the root. Each prim was oriented as desired as part of the linkset and then a piece of code used to rez the TL and have it move between each prim and adopt the orientation before terraforming locally and moving onto the next position.

I’m fairly rubbish at terraforming so looking forward to seeing if this rather basic but functional approach helps.

Reposted with a better example and then code (no error handling, use at your own peril and back up terrain first)

default
{
    state_entry()
    {
        llListen(99, "", NULL_KEY, "");//used with rezzer
    }
    
    listen(integer c, string name, key id, string msg)//used with rezzer
    {
        if (c == 99)
        {
            list l = llParseString2List(msg, ["/"],[]);
            llSetRegionPos(llList2Vector(l, 0));
            llSetRot(llList2Rot(l, 1));
            integer i;
            for (i = 0; i < llGetNumberOfPrims(); i++)
            {
                list l = llGetLinkPrimitiveParams(i, [PRIM_POSITION]);
                vector v = llList2Vector(l, 0);
                osSetTerrainHeight((integer)v.x, (integer)v.y, v.z);
            }
        }
    }
            
    
    touch_start(integer n)
    {
        llResetTime();
    }    
            

    touch_end(integer n)
    {
        if (llGetTime() <= 1.0)//short touch
        {        
            llOwnerSay("setting color");
            //get link number touched
            integer i = llDetectedLinkNumber(0);
            list color = llGetLinkPrimitiveParams(i, [PRIM_COLOR, 0]);
            vector col = llList2Vector(color, 0);
            if (col == <0,1,0>)
            {
                llSetLinkColor(i, <1,1,1>, 0);
            }
            else
            {
                llSetLinkColor(i, <0,1,0>, 0);
            }
        }
        else //long touch
        {
            llOwnerSay("terraforming");//use height of prim or value in desc for green prims only
            if (llStringLength(llGetObjectDesc()) == 0)//use prim height
            {
                integer i;
                for (i = 0; i < llGetNumberOfPrims(); i++)
                {
                    list l = llGetLinkPrimitiveParams(i, [PRIM_POSITION]);
                    vector v = llList2Vector(l, 0);
                    osSetTerrainHeight((integer)v.x, (integer)v.y, v.z);
                } 
            }
            else//use prim height modified by desc value in z, else ignore
            {
                integer i;
                float inc = (float)llGetObjectDesc(); 
                for (i = 0; i < llGetNumberOfPrims(); i++)
                {
                    list color = llGetLinkPrimitiveParams(i, [PRIM_COLOR, 0]);
                    vector col = llList2Vector(color, 0);
                    if (col == <0,1,0>)
                    {                    
                        list l = llGetLinkPrimitiveParams(i, [PRIM_POSITION]);
                        vector v = llList2Vector(l, 0);
                        osSetTerrainHeight((integer)v.x, (integer)v.y, v.z + inc);
                    }
                } 
            }  
            llOwnerSay("done");            
        }            
    }    
}
Ball of Confusion @vrsimility