SetLinkText

Expired

I've always seen lots of scripts that used llMessageLinked() and llSetText() to be able to make hover text over prims other then the prim the script is in. it's because of this that i made this custom function which uses llSetLinkPrimitiveParamsFast() to set hover text over prims via one script other than the prim that the script is in. I first looked to see if someone else had done this and i found this page. that is pretty much what i did and the format for using it.


To use a custom function such as this the function you must put it be before default in the script which I will show in the example. Afterwords you can use it to your hearts desire within the script itself.

 

-Disclaimer- Your allowed to modify this any way you want and use it. If any way is found to use this for Griefing I am not to be held responsible.

 

SetLinkText(integer link, string text, vector color, float alpha)
{
    llSetLinkPrimitiveParamsFast(link,
        [PRIM_TEXT, text, color, alpha]);
}
 
default
{
    touch_start(integer num_detected)
    {
        integer link = llDetectedLinkNumber(0);
 
    //  red and opaque "Hello" over touched link
        SetLinkText(link, "Hello", <1 .0, 0.0, 0.0>, (float)TRUE);
    }
}

 

Sim Restart Notifyer

Expired

When the region (with object that runs this script) restarts, the script sends all registered residents an instant message telling the sim is online and what channel and version the sim is now. Also how many restarts the sim had sice the script itself was restarted.

 

This is practical when you want to know when you can return to your sim and continue working on your projects. Registered residents must not be online, when IM-to-mail service is activated, they receive the notification via email.

 

Usage

 

Create an object or use any created already as container for the script. Put the script into. In this case you only will receive restart reports. When you want register other residents, or your partner or alts as message recepient (please ask if they want to), create a notecard and fill it with names or keys, one key a line. For example this way:

 

# Put the keys of the recepients or the names here,
#
# Using keys is more effective - names need resolving
# You can combine keys and names by using a comment,
# like this:
#
eb66b7b7-7ddb-4c5a-95ad-bfeb9837ae29 # Jenna Felton
#
# Less effective but also possible:
Jenna Felton

 

Each key and name must go in other line. You can give the notecard any name. Than put it into the container and reset the script. After it reads the keys and resolved the avatar names, the script is ready.

 

The script writes as floating text the current sim version and restart counts. By cliking the prim, the script also whispers the restart report without sending it to other recepients (no provoced IM spam).

 

Notifyer script

 

//----------------------------------------------------------------------------
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 3 of
// the License, or (at your option) any later version.
//
// You may ONLY redistribute this program with copy, mod and transfer
// permissions and ONLY if this preamble is not removed.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, see .
//----------------------------------------------------------------------------
 
string  URL = "http://w-hat.com/name2key";
 
integer gStarts = 0;
string  sSince  = "";
 
list    lNotify = [];
integer gNotify = 0;
 
string  sNote;
integer gLine;
key     kRead;
 
list    lNames  = [];
integer gNames  = 0;
 
// --- -----------------------------------------------------------------------
 
notifyRestarts(integer whinfo) {
    string region  = llGetRegionName();
    string channel = llGetEnv("sim_channel");
    string version = llGetEnv("sim_version");
 
    llSetText(
        (string)gStarts+" restarts since "+sSince
        +"\n----------------"
        +"\nChannel: "+channel
        +"\nVersion: "+version, <1 .0, 1.0, 1.0>, 1.0);
 
    // Second Life RC LeTigre * 12.08.23.263929
    // http://wiki.secondlife.com/wiki/Release_Notes/Second_Life_RC_LeTigre/12#12.08.23.263929
 
    list   channsl = llParseString2List(channel, [" "], []);
    string srvlink = llDumpList2String(channsl, "_");
 
    srvlink = "http://wiki.secondlife.com/wiki/Release_Notes/"
        + srvlink + "/" + llGetSubString(version, 0, 1)
        + "#" + version;
 
    string message = "[RESTART MESSAGE]: Sim "+region
        +" is restarted and back online now."
        +"\nRestarts: "+(string)gStarts+" since "+sSince
        +"\nSimulator: "+channel+", v"+version
        +"\nRelease notes: "+srvlink;
 
    if (whinfo) llWhisper(0, message);
    else {  
        integer pos = gNotify;
        while (pos-- > 0) {
            llInstantMessage((key)llList2String(lNotify, pos), message);
        }
    }
}
 
// --- -----------------------------------------------------------------------
 
integer resolveNextName() {
    ++gLine;
    if (gLine >= gNames) return FALSE;
 
    sNote = llList2String(lNames, gLine);
 
    // "Jenna Felton" -> "jenna felton"
    // "jenna.felton" -> "jenna felton"
    // "Jenna"        -> "jenna resident"
    integer pos = llSubStringIndex(sNote, ".");
    if (pos > 0) {
        sNote = llGetSubString(sNote, 0, pos-1)+" "+llGetSubString(sNote, pos+1, -1);
    }
    else {
        pos = llSubStringIndex(sNote, " ");
        if (pos <0) sNote += " Resident";
    }
 
    llSleep(0.2);
 
    kRead = llHTTPRequest( URL + "?terse=1&name=" + llEscapeURL(sNote), [], "" );
 
    return TRUE;
}
 
// === =======================================================================
 
default {
    state_entry() {
        llSetText("Reading notification list", <1.0, .0, .0>, 1.0);
 
        // 1. Resolving the date
        if (sSince == "") {
            // The date is given as "YYY-MM-DD"
            sSince = llGetDate();
 
            // Date Format conversion
            list tmp = llParseString2List(sSince, ["-"], []);
 
            // EU format: "DD.MM.YYYY"
            sSince   = llList2String(tmp, 2)+"."+llList2String(tmp, 1)+"."+llList2String(tmp, 0);
 
            // US format: "MM-DD-YYYY"
            //sSince   = llList2String(tmp, 1)+"-"+llList2String(tmp, 2)+"-"+llList2String(tmp, 0);
        }
 
        // 2. Starting reading notecard
 
        sNote = llGetInventoryName(INVENTORY_NOTECARD, 0);
        if (sNote != "") {
            if (llGetInventoryKey(sNote) == NULL_KEY) sNote = "";
        }
 
        if (sNote == "") {
            llOwnerSay("To allow others to receive restart notifications as well, "
                + "please provide a notecard with stored names or keys "
                + "of the recepients, than reset the script or pick up "
                + "the notificator and rezz it again.");
 
            state Running;
        }
        else {
            gLine = 0;
            kRead = llGetNotecardLine(sNote, gLine);
        }
    }
 
    on_rez(integer start_param) {
        llResetScript();
    }
 
    dataserver(key requested, string data)  {
        if (requested != kRead) return;
 
        if (data == EOF) {
            if (lNames == []) state Running;
            else              state Resolving;
        }
        else kRead = llGetNotecardLine(sNote, ++gLine);
 
        integer pos = llSubStringIndex(data, "#");
        if      (pos == 0) data = "";
        else if (pos > 0)  data = llGetSubString(data, 0, pos -1);
 
        data = llStringTrim(data, STRING_TRIM);
 
        if (data != "") {
            // The recepient is a valide key?
            if (llStringLength(data) == 36) {
                key agent = (key)data;
                if (agent) {
                    if (llListFindList(lNotify, [agent]) <0) lNotify += [agent];
                }
                else {
                    llOwnerSay("ERROR ("+sNote+":"+(string)gLine
                        +") String '"+data+"' is no valide key.");
                }
            }
 
            // Otherwise could be name, save to resolve
            else lNames += [data];
        }
    }
}
 
// === =======================================================================
 
state Resolving {
    state_entry() {
        llSetText("Resolving recepient keys", <1.0, 1.0, 0.0>, 1.0);
 
        gNames = llGetListLength(lNames);
        llOwnerSay("Resolving "+(string)gNames+" keys.");
 
        gLine = -1;
        if (!resolveNextName()) state Running;
    }
 
    on_rez(integer start_param) {
        llResetScript();
    }
 
    http_response(key id, integer status, list meta, string body) {
        if ( id != kRead ) return;
 
        if ( status == 499 ){
            llOwnerSay("WARNING: name2key request timed out");
        }
        else if ( status != 200 ){
            llOwnerSay("WARNING: the internet exploded!!");
        }
        else if ( (key)body == NULL_KEY ){
            llOwnerSay("WARNING: No key found for " + sNote);
        }
 
        // Agent found
        else {
            kRead = (key)body;
            llOwnerSay("INFO: Key resolved: " + sNote + " = " + body);
            if (llListFindList(lNotify, [kRead]) <0) lNotify += [kRead];
        }
 
        if (!resolveNextName()) state Running;
    }
}
 
// === =======================================================================
 
state Running {
    state_entry() {
        llSetText("Sim not restartet yet", <1.0, 1.0, 1.0>, 1.0);
 
        kRead = llGetOwner();
        if (llListFindList(lNotify, [kRead]) <0) lNotify += [kRead];
 
        gNotify = llGetListLength(lNotify);
 
        llOwnerSay((string)gNotify+" recepients registered.");
    }
 
    on_rez(integer start_param) {
        llResetScript();
    }
 
    touch_start(integer total_number) {
        notifyRestarts(TRUE);
    }
 
    changed(integer change) {
        if (change & CHANGED_REGION_START) {
            ++gStarts;
            notifyRestarts(FALSE);
        }
    }
}
 
// === =======================================================================

 

Textbox 2 Hovertext

Expired

// Textbox2Hovertext by Ackley Bing & Omei Qunhua
// A simple script to allow object owners to change the "hovertext"
// on their prims using a text entry box (llTextBox).
 
integer listenhandle;
 
default
{
    touch_start(integer num)
    {
        key target = llDetectedKey(0);
        if(target!=llGetOwner()) return; // remove this line to allow anyone to change the hover text
        llListenRemove(listenhandle);
        llSetTimerEvent(60.0); // Time to input text until script closes listener in case target doesnt enter anything into textbox
        listenhandle=llListen(-12345, "", target, "");
        llTextBox( target, "Set Hovertext", -12345);
    }
    listen(integer channel, string name, key id, string message)
    {
        llSetText(message, <1 , 1, 1>, 1);
        llListenRemove(listenhandle);
        llSetTimerEvent(0.0);
    }
    timer()
    {
        llListenRemove(listenhandle);
        llSetTimerEvent(0.0);
    }
}

 

Floating Text LEFT/RIGHT Alignment ( V1 )

Expired

This script can turn a list of individual lines of text into a left or right aligned floating text display.

 

// V1 //
 
// SetTextAlign // Begin //
 
// Thank you to Silicon Plunkett for the "samples" the script uses to measure the width of the strings.
// He made a great effort to work these values out and I would have been at a massive disadvantage without them.
// This may never have existed.
 
string SetTextAlign(integer A, integer D, list S)
{
    list samples = [" ", "![]{}|:;'.,ijlIJ", "\/<>`()rtf", "*#\"yszxcvETYLZ", "_?upahkbnRPAFKCV", "~$^+qeodgmDB", "w=QUOSGHXN", "%WM", "@"];
    list result = [];
    string separate = "";
    if(A)
    {
        list scores = [];
        list scores_max = [];
        string line = "";
        string sample = "";
        string letter = "";
        string spaces = "";
        string to_pad = "";
        float score = 0.0;
        float max_score = 0.0;
        float next = 0.0;
        integer length = 0;
        integer s_length = 0;
        integer count = 0;
        integer count_a = 0;
        integer count_b = 0;
        integer count_c = 0;
        integer ssi = 0;
        integer padem = 0;
        integer space_count = 0;
        separate = "\n";
        length = llGetListLength(S);
        do
        {
            line = llList2String(S, count);
            s_length = llStringLength(line);
            count_a = 0;
            score = 0.0;
            do
            {
                letter = llGetSubString(line, count_a, count_a);
                count_b = 0;
                do
                {
                    count_c = 0;
                    do
                    {
                        sample = llList2String(samples, count_c);
                        ssi = llSubStringIndex(sample, letter);
                        if(ssi != -1)
                        {
                            if(count_c == 0)
                            score += 1.0;
                            else if(count_c == 1)
                            score += 1.5;
                            else if(count_c == 2)
                            score += 2.0;
                            else if(count_c == 3)
                            score += 2.5;
                            else if(count_c == 4)   // Thanx to some advice from a veritable genius ( Xzaviar Qarnac ) -
                            score += 3.0;           // - I have realised something very important about loops.
                            else if(count_c == 5)   // Since this realization I have cut out alot of potential drag.
                            score += 3.5;           // Thank you Xzaviar.
                            else if(count_c == 6)
                            score += 4.0;
                            else if(count_c == 7)
                            score += 4.5;
                            else
                            score += 5.0;
                            count_c = 9;    // This line is what I realized was needed.
                        }
                    }
                    while((++count_c) <9);
                }
                while((++count_b) < 1);
            }
            while((++count_a) < s_length);
            scores += [score];
        }
        while((++count) < length);
        scores_max = llListSort(scores, 1, FALSE);
        max_score = llList2Float(scores_max, padem);
        scores_max = [];
        do
        {
            next = llList2Float(scores, padem);
            spaces = "";
            space_count = 0;
            do
            {
                spaces += " ";
            }
            while((((float)(++space_count)) + next) < max_score);
            to_pad = llList2String(S, padem);
            if(D)
            result += [(to_pad + spaces)];
            else
            result += [(spaces + to_pad)];
        }
        while((++padem) < length);
        scores = [];
    }
    else
    result = S;
    return llDumpList2String(result, separate);
}
 
// SetTetAlign // End //
 
default
{
    state_entry()
    {
        float alpha = 1.0;
        vector color = <0.0,1.0,1.0>; // Turquoise!
 
// The text to display must be fed to the function as a list of strings each being one line (as below).
 
        list source = ["Hello there, Avatar!", "My script can align your text to the left or right.", "Touch me for a copy of it."];
 
        llSetText(SetTextAlign(TRUE, TRUE, source), color, alpha);
 
// SetTextAlign(Align (TRUE or FALSE), Direction (TRUE = left : FALSE = right), source).
 
    }
    touch_start(integer nd)
    {
        integer countnd = 0;
        do
        {
            key toucher = llDetectedKey(countnd);
            llGiveInventory(toucher, llGetScriptName()); // FREE!!! Enjoy.
        }
        while((++countnd)