// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Irregular floor area by vertices // Not compiled or tested in-world // Setup: Put in a spare prim you own. Replace POINTS with your boundary in clockwise or counterclockwise order, without repeating the first point. Touch. // Stop / restore: Disable or remove the script. It only reports to its owner and does not change prim properties. Reset clears its temporary state. // Notes: Assumes a simple, non-self-intersecting polygon. Z is ignored. Signed area also reveals winding; no prim measurements are changed. // License: see LICENSE in this distribution. // Original Incoprea example. MIT. Owner-only calculation; no scene changes. list POINTS = [<0.0,0.0,0.0>, <6.0,0.0,0.0>, <6.0,2.0,0.0>, <3.0,4.0,0.0>, <0.0,4.0,0.0>]; default { touch_start(integer detectedCount) { if (llDetectedKey(0) != llGetOwner()) return; integer n = llGetListLength(POINTS); if (n < 3) { llOwnerSay("Need at least three vertices."); return; } float twiceArea = 0.0; integer i; for (i = 0; i < n; ++i) { vector a = llList2Vector(POINTS, i); vector b = llList2Vector(POINTS, (i + 1) % n); twiceArea += a.x * b.y - b.x * a.y; } llOwnerSay("Area: " + (string)(llFabs(twiceArea) * 0.5) + " square metres; signed: " + (string)(twiceArea * 0.5)); } changed(integer change) { if (change & CHANGED_OWNER) llResetScript(); } }