// SPDX-License-Identifier: MIT
// Copyright (c) 2026 Incoprea
// Height above local terrain and water
// Not compiled or tested in-world
// Setup: Use a rezzed object and touch as owner.
// Stop / restore: Remove or disable; it changes no object or parcel properties.
// Notes: Measures the prim center, not its bottom or collision shape. It does not probe other objects or avatars. Water and terrain behavior can vary by simulator.
// License: see LICENSE in this distribution.
// Original Incoprea example. MIT.
default
{
    touch_start(integer touches)
    {
        if(llDetectedKey(0)!=llGetOwner()) return;
        if(llGetAttached())
        {
            llOwnerSay("Use a rezzed object.");
            return;
        }
        vector position=llGetPos();
        float terrain=llGround(ZERO_VECTOR);
        float water=llWater(ZERO_VECTOR);
        llOwnerSay("Center above terrain: "+(string)(position.z-terrain)+" m");
        llOwnerSay("Center above water: "+(string)(position.z-water)+" m");
    }
    changed(integer flags)
    {
        if(flags & CHANGED_OWNER) llResetScript();
    }
}
