// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Measure a scripted point light’s sampled duty // Not compiled or tested in-world // Setup: Put in your own rezzed test object. Start while an existing light-control script runs. Owner-touch starts a thirty-sample session; touch again ends early. // Stop / restore: Automatically stops after thirty samples. Disable/remove to stop; no scene properties are changed. // Notes: Uses previous sampled state over each elapsed interval; short flashes can be missed. This is not electrical energy or measured illumination. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Test on a spare copy first. integer active; integer samples; float began; integer wasOn; float intensity; float prior; float onTime; float exposure; finish() { llSetTimerEvent(0.0); active=FALSE; float duration=prior-began; float duty=0.0; if(duration>0.0)duty=onTime/duration; llOwnerSay("Sampled on-seconds="+(string)onTime+" duty fraction="+(string)duty+" intensity-seconds="+(string)exposure); } default { touch_start(integer n) { if(llDetectedKey(0)!=llGetOwner())return; if(active) { finish(); return; } samples=0; began=llGetTime(); list light=llGetLinkPrimitiveParams(LINK_THIS,[PRIM_POINT_LIGHT]); wasOn=llList2Integer(light,0); intensity=llList2Float(light,2); prior=llGetTime(); onTime=0.0; exposure=0.0; active=TRUE; llSetTimerEvent(1.0); llOwnerSay("Measurement session started."); } timer() { if(!active)return; ++samples; float now=llGetTime(); float dt=now-prior; if(wasOn) { onTime += dt; exposure += dt*intensity; } list light=llGetLinkPrimitiveParams(LINK_THIS,[PRIM_POINT_LIGHT]); wasOn=llList2Integer(light,0); intensity=llList2Float(light,2); prior=now; if(samples>=30)finish(); } changed(integer flags) { if(flags&CHANGED_OWNER)llResetScript(); } }