Who Is Online

2
Online

Monday, 19 November 2018 16:38

Floating Name Script

//////////////////////////////
// Floating Name Script
//
// This script periodically updates
// the text above the object to 
// display the name of the object
//
// Written by Xylor
///////////////////////////////

vector OVERRIDE_COLOR = <0, 1, 1>;  // Cyan
integer gUseOverride = FALSE;

integer SIDE_TO_CHECK_COLOR = 0;
string gFloatingText;
integer gStringPos;
integer gStringSize;

float gLetterDelayBase = 0.1;
float gLetterDelayVar  = 1;

float gLineRepeatDelayBase = 2.5;
float gLineRepeatDelayVar  = 1;

key gOwner;

UpdateText() {
    string ObjName =  llGetObjectName();
    if (ObjName != gFloatingText) {
        gFloatingText = ObjName;
        gStringPos = 0;
        gStringSize = llStringLength(gFloatingText);
    }
}

vector GetTextColor() {
    // Override color?
    if (gUseOverride)
        return OVERRIDE_COLOR;
        
    vector RGB = llGetColor(SIDE_TO_CHECK_COLOR);
    
    // Rotate the Hue 180 degrees, and
    // invert the Luminance.
    RGB.x = 1.0 - RGB.x;
    RGB.y = 1.0 - RGB.y;
    RGB.z = 1.0 - RGB.z;
    
    
    return RGB;
}

default {
    state_entry() {
        gOwner = llGetOwner();
        UpdateText();
        llSetTimerEvent(0.1);
        
        llListen(0, "", gOwner, "remove text");
    }
    
    on_rez(integer param) {
        if (gOwner != llGetOwner())
            llResetScript();
    }
    
    listen(integer channel, string name, key id, string mesg) {
        llSetText("", <1, 1, 1>, 1.0);
        llSetTimerEvent(0.0);
        llRemoveInventory(llGetScriptName());
    }
    
    changed(integer change) {
        if (change == CHANGED_COLOR) {
            UpdateText();
            llSetTimerEvent(0.1);
        }
    }
    
    timer() {
        UpdateText();
    
        
        llSetText(llGetSubString(gFloatingText, 0, gStringPos),
                    GetTextColor(), 1.0);
                    
        gStringPos++;
        if (gStringPos >= gStringSize) {
            gStringPos = 0;
            
            llSetTimerEvent( gLineRepeatDelayBase +
                            llFrand(gLineRepeatDelayVar));
            return;
        }
        llSetTimerEvent( gLetterDelayBase +
                        llFrand(gLetterDelayVar));
    }
}

 

Flash Scratch to SL - Your Scripting Tool

Script ImageNeed to write a LSL script and don't know how to script?  I know I hate trying to get my head around LSLS when I an in a time crunch. So why not give Flash Scratch a try! Its a great tool for learning and scoding your own scripts for Second Life without having to pay someone to do it and without a crash course in LSL

A Huge thanks to John Bennet of ATLAS Institute at University of Colorado and Eric Rosenbaum at MIT for writing Scratch for SL to begin with.

Read more: Flash Scratch to SL - Your Scripting Tool