// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Check a short caption against a word goal // Not compiled or tested in-world // Setup: Set MIN_WORDS and MAX_WORDS, then touch to enter a caption. // Stop / restore: Remove, disable, or reset to stop timers and discard session state. Temporary input listeners expire after 45 seconds. // Notes: Only the current owner can control this example. Timing is approximate and can be delayed by simulator load. Punctuation is attached to tokens; this is not a linguistic word counter. It never uploads or publishes the caption. // License: see LICENSE in this distribution. // Original Incoprea example. MIT. integer active; integer handle; integer channel; integer expires; integer MIN_WORDS=8; integer MAX_WORDS=20; closeInput() { if(handle)llListenRemove(handle); handle=0; } schedule() { if(active || handle)llSetTimerEvent(1.0); else llSetTimerEvent(0.0); } beginInput() { closeInput(); channel=-10000-(integer)llFrand(1000000000); handle=llListen(channel,"",llGetOwner(),""); expires=llGetUnixTime()+45; schedule(); } ask(string prompt) { beginInput(); llTextBox(llGetOwner(),prompt,channel); } default { touch_start(integer touches) { if(llDetectedKey(0)!=llGetOwner())return; ask("Enter a short caption for a word-budget check."); schedule(); } listen(integer c,string name,key speaker,string input) { if(c!=channel || speaker!=llGetOwner() || !handle)return; closeInput(); if(llStringLength(input)>200) { llOwnerSay("Reply is too long."); schedule(); return; } integer words=llGetListLength(llParseString2List(input,[" ","\n",llUnescapeURL("%09")],[])); if(MIN_WORDS<0 || MAX_WORDSMAX_WORDS)llOwnerSay("Consider shortening the caption."); else llOwnerSay("Within the configured word range."); } schedule(); } timer() { if(handle && llGetUnixTime()>=expires) { closeInput(); llOwnerSay("Input expired."); } schedule(); } changed(integer flags) { if(flags & CHANGED_OWNER)llResetScript(); } }