// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Level a root while preserving heading // Not compiled or tested in-world // Setup: Put in an unattached nonphysical root whose forward axis is local +X. Owner-touch levels; touch again restores. // Stop / restore: Owner-touch again to restore the startup snapshot before removal or reset, unless setup describes a different cycle. Do not relink during a preview. // Notes: Use a spare modifiable build. Saved state lives only in script memory. Near-vertical forward directions have no stable heading and are rejected. Whole linkset geometry rotates; use clear space. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Not compiled or tested in-world. integer preview; rotation home; default { state_entry() { home=llGetRot(); } touch_start(integer n) { if(llDetectedKey(0)!=llGetOwner())return; if(llGetLinkNumber()>1||llGetAttached()||llGetStatus(STATUS_PHYSICS))return; vector forward=llRot2Fwd(home); forward.z=0.0; if(llVecMag(forward)<0.01)return; preview=!preview; if(preview) { vector headingForward=llRot2Fwd(home); float heading=llAtan2(headingForward.y,headingForward.x); llSetRot(llEuler2Rot(<0.0,0.0,heading>)); } else { llSetRot(home); } } }