// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Rename this prim with a preview and confirmation // Not compiled or tested in-world // Setup: Put in your own prim and touch. Enter a name and choose Apply. // 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. Changes only this prim’s Name. Save the original first; removing the script does not restore it. Not suitable when another script depends on an exact inventory/object name. // License: see LICENSE in this distribution. // Original Incoprea example. MIT. integer active; integer handle; integer channel; integer expires; integer step; string proposed; string original; 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); } menu(string prompt,list buttons) { beginInput(); llDialog(llGetOwner(),prompt,buttons,channel); } default { touch_start(integer touches) { if(llDetectedKey(0)!=llGetOwner())return; step=1; original=llGetObjectName(); ask("Enter a new name, 1–40 printable ASCII characters."); 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; } if(step==1) { integer valid=llStringLength(input)>=1 && llStringLength(input)<=40; integer i; for(i=0;i126)valid=FALSE; if(!valid) { llOwnerSay("Invalid name."); step=0; } else { proposed=input; step=2; menu("Old: "+original+"\nNew: "+proposed,["Apply","Cancel"]); } } else if(step==2) { if(input=="Apply") { if(llGetObjectName()!=original)llOwnerSay("Name changed externally; restart to recheck."); else { llSetObjectName(proposed); llOwnerSay("Name updated. Original: "+original); } } step=0; } schedule(); } timer() { if(handle && llGetUnixTime()>=expires) { closeInput(); llOwnerSay("Input expired."); } schedule(); } changed(integer flags) { if(flags & CHANGED_OWNER)llResetScript(); } }