// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Fill a private template from notecard variables // Not compiled or tested in-world // Setup: Create a saved plain-text notecard named Data. Use unique name|value lines. Edit TEMPLATE in the script. Values may not contain pipe. Touch as owner to load it; touch again to use the cached content. // Stop / restore: Remove or disable. Reset or an inventory change discards the cache. No notecards are changed. // Notes: At most 60 lines, 300 characters per line, and 6000 total characters; blank lines and # comments are omitted. Incomplete reads are rejected. Unknown or unclosed placeholders reject the preview. Literal braces outside {{...}} are preserved. Output is clipped by a conservative 800-character guard. // License: see LICENSE in this distribution. // Original Incoprea example. MIT. string TEMPLATE="Welcome to {{place}}, made by {{creator}}."; list lines; integer lineNumber; integer characters; integer loaded; key pending=NULL_KEY; request() { pending=llGetNotecardLine("Data",lineNumber); llSetTimerEvent(20); } run() { list keys; list values; integer i; for(i=0;i800) { llOwnerSay("Expanded text too long."); return; } } llOwnerSay(out); } default { touch_start(integer touches) { if(llDetectedKey(0)!=llGetOwner())return; if(pending!=NULL_KEY) { llOwnerSay("Still loading."); return; } if(loaded) { run(); return; } if(llGetInventoryType("Data")!=INVENTORY_NOTECARD) { llOwnerSay("Add a saved Data notecard."); return; } lines=[]; lineNumber=0; characters=0; request(); } dataserver(key query,string data) { if(query!=pending || pending==NULL_KEY)return; if(data==EOF) { pending=NULL_KEY; llSetTimerEvent(0); loaded=TRUE; run(); return; } characters+=llStringLength(data); if(lineNumber>=60 || llStringLength(data)>300 || characters>6000) { pending=NULL_KEY; llSetTimerEvent(0); lines=[]; llOwnerSay("Read rejected: card exceeds bounds."); return; } data=llStringTrim(data,STRING_TRIM); if(data!="" && llGetSubString(data,0,0)!="#")lines += [data]; ++lineNumber; request(); } timer() { pending=NULL_KEY; lines=[]; llSetTimerEvent(0); llOwnerSay("Read timed out; touch to retry."); } changed(integer flags) { if(flags & (CHANGED_OWNER|CHANGED_INVENTORY))llResetScript(); } }