Table of Contents

for Elizabeth Tinsley.

Introduction

This is a simple script that changes the name of the primitive it is in after a certain configurable interval.

Setup

Code

timed_primitive_name_changer.lsl
///////////////////////////////////////////////////////////////////////////
//  Copyright (C) Wizardry and Steamworks 2011 - License: GNU GPLv3      //
//  Please see: http://www.gnu.org/licenses/gpl.html for legal details,  //
//  rights of fair usage, the disclaimer and warranty conditions.        //
///////////////////////////////////////////////////////////////////////////
 
//////////////////////////////////////////////////////////
//                   CONFIGURATION                      //
//////////////////////////////////////////////////////////
 
// Set this to the amount of time before the script 
// changes the name of the primitive.
 
integer NAME_CHANGE_INTERVAL = 1;
 
///////////////////////////////////////////////////////////////////////////
//                              INTERNALS                                //
///////////////////////////////////////////////////////////////////////////
key qQuery;
integer qLine;
list qList = [];
 
integer comHandle;
 
default
{
    state_entry()
    {
        integer itra;
        for(itra=0, qList=[], qLine=0; itra<llGetInventoryNumber(INVENTORY_NOTECARD); ++itra) {
            if(llGetInventoryName(INVENTORY_NOTECARD, itra) == "Names")
                jump found_quotes;
        }
        llOwnerSay("Names notecard not found, please add a notecard called Names and list all the names line by line making sure that you have a blank line at the end.");
        return;
@found_quotes;
        qQuery = llGetNotecardLine("Names", qLine);
    }
 
    changed(integer change) {
        if(change & CHANGED_INVENTORY) {
            llResetScript();
        }
    }
 
    timer() {
        llSetTimerEvent(0);
        string name = llList2String((qList = llDeleteSubList((qList = []) + qList, 0, 0)), 0);
        llSetObjectName(name);
        qList += name;
        llSetTimerEvent(NAME_CHANGE_INTERVAL);
    }
 
    dataserver(key id, string data) {
        if(id != qQuery) return;
        if(data == EOF) {
            if(!llGetListLength(qList)) {
                llOwnerSay("The Name notecard is empty, please add some names and make sure you have a blank line at the end.");
                return;
            }
            llOwnerSay("List read, setting object name in " + (string)NAME_CHANGE_INTERVAL + "s intervals.");
            llSetTimerEvent(NAME_CHANGE_INTERVAL);
            return;
        }
        if(data == "") jump next_line;
        qList += data;
@next_line;
        qQuery = llGetNotecardLine("Names", ++qLine);
    }
}