Difference between revisions of "RLV Viewer Titler"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with "With upcoming new third party viewer policy, displaying of viewer tags is no more allowed and was also deactivated. Before the TPV changes, with some viewers it was possible to s…")
 
m (Replaced obsolete source tag with syntaxhighlight, addd banner and categories)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{LSL Header}}
With upcoming new third party viewer policy, displaying of viewer tags is no more allowed and was also deactivated. Before the TPV changes, with some viewers it was possible to see what viewer other residents are using, which is seen as injuring of privacy on the other side, but on the other side an improvement in giving viewer-dependant residental support. This advantage of viewer tags is taken by the TPV changes.
With upcoming new third party viewer policy, displaying of viewer tags is no more allowed and was also deactivated. Before the TPV changes, with some viewers it was possible to see what viewer other residents are using, which is seen as injuring of privacy on the other side, but on the other side an improvement in giving viewer-dependant residental support. This advantage of viewer tags is taken by the TPV changes.


Line 5: Line 7:
The comment block inside the script provides further info about features and usage of the script.
The comment block inside the script provides further info about features and usage of the script.


<lsl>
<syntaxhighlight lang="lsl2">
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// This program is free software; you can redistribute it and/or
// This program is free software; you can redistribute it and/or
Line 65: Line 67:
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// Author  Jenna Felton
// Author  Jenna Felton
// Version 1.0
// Version 1.0.1
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------


integer CHANNEL = 111;
integer CHANNEL = 111;


list   NAMES   = [
list NAMES = [
"WHITE", "GREY", "BLACK",
    "WHITE", "GREY", "BLACK",
"RED", "GREEN", "BLUE",
    "RED", "GREEN", "BLUE",
"YELLOW", "MAGENTA", "CYAN",
    "YELLOW", "MAGENTA", "CYAN",
"DEFAULT"];
    "DEFAULT"];
list   COLORS = [
 
<1.0, 1.0, 1.0>, <0.5, 0.5, 0.5>, <0.0, 0.0, 0.0>,
list COLORS = [
<1.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 1.0>,
    <1.0, 1.0, 1.0>, <0.5, 0.5, 0.5>, ZERO_VECTOR,
<1.0, 1.0, 0.0>, <1.0, 0.0, 1.0>, <0.0, 1.0, 1.0>,
    <1.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 1.0>,
<.98, .69, .36>];
    <1.0, 1.0, 0.0>, <1.0, 0.0, 1.0>, <0.0, 1.0, 1.0>,
    <0.98, 0.69, 0.36>];


integer hUserListen;
integer hUserListen;
Line 85: Line 88:
integer gRLVCChan;
integer gRLVCChan;


string sViewer = "";
string sViewer = "";
string sTitle = "";
string sTitle = "";
vector vColor = <.98, .69, .36>;
vector vColor = <0.98, 0.69, 0.36>;


key     kOwner;
key kOwner;


//--- ------------------------------------------------------------------------
// Added by Kireji Haiku to reduce memory usage and improve readability
reset_listeners_and_timer()
{
    llListenRemove(hRLVCListen);
    gRLVCChan  = 1000000 + (integer)llFrand(100000.0);
    hRLVCListen = llListen(gRLVCChan, "", kOwner, "");
 
    llOwnerSay("detecting viewer...");
    llOwnerSay("@version=" + (string)gRLVCChan);
 
    // set timer to go off every other minute
    llSetTimerEvent(60.0);
}


default {
default {
// init::UsedMem = 12312
    // init::UsedMem = 12312
state_entry() {
    state_entry() {
llSetAlpha(0.0, ALL_SIDES);
        // set transparent
sViewer    = "";
        llSetAlpha(.0, ALL_SIDES);
sTitle      = "";
 
kOwner     = llGetOwner();
        kOwner = llGetOwner();
        sViewer = "";
hUserListen = llListen(CHANNEL, "", kOwner, "");
        sTitle  = "";


llListenRemove(hRLVCListen);
        hUserListen = llListen(CHANNEL, "", kOwner, "");
gRLVCChan  = 1000000 + (integer)llFrand(100000.0);
hRLVCListen = llListen(gRLVCChan, "", kOwner, "");
llOwnerSay("detecting viewer...");


// Request the viewer version and starts a
        reset_listeners_and_timer();
// timeout of one minute.
llOwnerSay("@version="+(string)gRLVCChan);
llSetTimerEvent(60.0);


// Checks the memory usage and reduces by setting less
        // Checks the memory usage and reduces by setting less
llOwnerSay("init::UsedMem = "+(string)llGetUsedMemory());
        llOwnerSay("init::UsedMem = "+(string)llGetUsedMemory());
llSetMemoryLimit(24000);
        llSetMemoryLimit(24000);
}
    }


// onrez::UsedMem = 12410
    // onrez::UsedMem = 12410
on_rez(integer start_param) {
    on_rez(integer start_param) {
// Memory test
        // Memory test
llScriptProfiler(PROFILE_SCRIPT_MEMORY);
        llScriptProfiler(PROFILE_SCRIPT_MEMORY);


if (kOwner != llGetOwner()) llResetScript();
        if (kOwner != llGetOwner()) llResetScript();


llListenRemove(hRLVCListen);
        reset_listeners_and_timer();
gRLVCChan  = 1000000 + (integer)llFrand(100000.0);
hRLVCListen = llListen(gRLVCChan, "", kOwner, "");
llOwnerSay("detecting viewer...");
llOwnerSay("@version="+(string)gRLVCChan);
llSetTimerEvent(60.0);


// Memory test
        // Memory test
llScriptProfiler(PROFILE_NONE);
        llScriptProfiler(PROFILE_NONE);
llOwnerSay("onrez::UsedMem = " + (string)llGetSPMaxMemory());
        llOwnerSay("onrez::UsedMem = " + (string)llGetSPMaxMemory());
}
    }


// Viewer Check Teimeout
    // listen::UsedMem = 12378 (rougly min)
// timer::UsedMem = 12224
    // listen::UsedMem = 13490 (rougly max)
timer() {
    listen(integer chan, string name, key id, string message) {
// Memory test
        // Memory test
llScriptProfiler(PROFILE_SCRIPT_MEMORY);
        llScriptProfiler(PROFILE_SCRIPT_MEMORY);


llSetTimerEvent(.0);
        // User control
llListenRemove(hRLVCListen);
        if (chan == CHANNEL) {
            llSetTimerEvent(.0);
sViewer = "";
            llListenRemove(hRLVCListen);
llSetText(sTitle, vColor, 1.0);
llOwnerSay(
"No RLV-capable viewer detected (or RLV is off).\n"+
"To repeat the ckeck, please reattach or chat this:\n"+
"/"+(string)CHANNEL+" VERSION");


// Memory test
            name = llToUpper(message);
llScriptProfiler(PROFILE_NONE);
           
llOwnerSay("timer::UsedMem = " + (string)llGetSPMaxMemory());
            if (name == "HIDE") {
}
                llSetText("", vColor, .0);
            }
           
            else if (name == "SHOW") {
                llSetText(sViewer+sTitle, vColor, 1.0);
            }
           
            else if (name == "VERSION") {
                reset_listeners_and_timer();
            }
           
            else if (name == "STOP") {
                llOwnerSay("/me is frozen. To unfreeze, please reattach");
                llListenRemove(hUserListen);
            }
           
            else if (llGetSubString(name, 0, 5) == "COLOR ") {
                name = llGetSubString(name, 6, -1);
                name = llStringTrim(name, STRING_TRIM_HEAD);


// listen::UsedMem = 12378 (rougly min)
                // Look for color names. If found - use color value
// listen::UsedMem = 13490 (rougly max)
                chan = llListFindList(NAMES, [name]);
listen(integer chan, string name, key id, string message) {
                if (chan > -1) {
// Memory test
                    vColor = llList2Vector(COLORS, chan);
llScriptProfiler(PROFILE_SCRIPT_MEMORY);
                }


// User control
                // Not found - parse the given vector to color value
if (chan == CHANNEL) {
                else {
llSetTimerEvent(.0);
                    list tmp = llParseString2List(name, ["<", ",", " ", ">"], []);
llListenRemove(hRLVCListen);
                    vColor   = <llList2Float(tmp, 0), llList2Float(tmp, 1), llList2Float(tmp, 2)>;
                }
name = llToUpper(message);
if      (name == "HIDE")    llSetText("", vColor, .0);
else if (name == "SHOW")    llSetText(sViewer+sTitle, vColor, 1.0);
else if (name == "VERSION") {
llListenRemove(hRLVCListen);
gRLVCChan   = 1000000 + (integer)llFrand(100000.0);
hRLVCListen = llListen(gRLVCChan, "", kOwner, "");
llOwnerSay("detecting viewer...");
llOwnerSay("@version="+(string)gRLVCChan);
llSetTimerEvent(60.0);
}
else if (name == "STOP") {
llOwnerSay("/me is frozen. To unfreeze, please reattach");
llListenRemove(hUserListen);
}
else if (llGetSubString(name, 0, 5) == "COLOR ") {
name = llGetSubString(name, 6, -1);
name = llStringTrim(name, STRING_TRIM_HEAD);


// Look for color names. If found - use color value
                llSetText(sViewer+sTitle, vColor, 1.0);
chan = llListFindList(NAMES, [name]);
            }
if (chan > -1) vColor = llList2Vector(COLORS, chan);
           
            else if (name == "CLEAR") {
                sTitle = "";
                llSetText(sViewer, vColor, 1.0);
            }
           
            // Unknown command. Fine, the user gets a title.
            else {
                sTitle = message;
                llSetText(sViewer+sTitle, vColor, 1.0);
            }
        }


// Not found - parse the given vector to color value
        // Viewer version response. Example answers:
else {
        // message = "RestrainedLife viewer v1.17 (CV 1.22.11.0)"
list tmp = llParseString2List(name, ["<", ",", " ", ">"], []);
        //          "RestrainedLife viewer v1.18 (SL 1.23.4)"
vColor  = <llList2Float(tmp, 0), llList2Float(tmp, 1), llList2Float(tmp, 2)>;
        //          "RestrainedLife viewer v1.22.0 (Emerald Viewer - RLVa 1.0.5)"
}
        //          "RestrainedLife viewer v1.22.1 (1.22.12.0)
        //          "RestrainedLove viewer v2.2.0 (Phoenix Viewer 1.5.2.908 - RLVa 1.1.3)"
llSetText(sViewer+sTitle, vColor, 1.0);
        //          "RestrainedLife viewer v2.7.0 (Firestorm 3.3.0.24880 - RLVa 1.4.3)"
}
        else if (chan == gRLVCChan) {
else if (name == "CLEAR") {
            llSetTimerEvent(0.0);
sTitle = "";
            llListenRemove(hRLVCListen);
llSetText(sViewer, vColor, 1.0);
}


// Unknown command. Fine, the user gets a title.
            // Separate the name:
else {
            // message = "RLV version (viewer signature)"
sTitle = message;
            //  -> tmp = ["RLV version", "viewer signature"]
llSetText(sViewer+sTitle, vColor, 1.0);
            list tmp = llParseString2List(message, [" (", ")"], []);
}
            message  = llList2String(tmp, 1);
}


// Viewer version response. Example answers:
            // If no viewer name set, "(1.22.12.0)", use RLV version
// message = "RestrainedLife viewer v1.17 (CV 1.22.11.0)"
            name = llGetSubString(message, 0, 0);
//          "RestrainedLife viewer v1.18 (SL 1.23.4)"
            if (name == "" || name == "0" || (integer)name != 0) {
//          "RestrainedLife viewer v1.22.0 (Emerald Viewer - RLVa 1.0.5)"
                sViewer = llList2String(tmp, 0) + "\n";
//          "RestrainedLife viewer v1.22.1 (1.22.12.0)
            }
//          "RestrainedLove viewer v2.2.0 (Phoenix Viewer 1.5.2.908 - RLVa 1.1.3)"
            else {
//          "RestrainedLife viewer v2.7.0 (Firestorm 3.3.0.24880 - RLVa 1.4.3)"
                sViewer = message + "\n";
else if (chan == gRLVCChan) {
            }
llSetTimerEvent(.0);
llListenRemove(hRLVCListen);


// Separate the name:
            // Use extracted data
// message = "RLV version (viewer signature)"
            llSetText(sViewer+sTitle, vColor, 1.0);
//  -> tmp = ["RLV version", "viewer signature"]
        }
list tmp = llParseString2List(message, [" (", ")"], []);
message  = llList2String(tmp, 1);


// If no viewer name set, "(1.22.12.0)", use RLV version
        // Memory test
name = llGetSubString(message, 0, 0);
        llScriptProfiler(PROFILE_NONE);
if (name == "" || name == "0" || (integer)name != 0) {
        llOwnerSay("listen::UsedMem = " + (string)llGetSPMaxMemory());
sViewer = llList2String(tmp, 0) + "\n";
    }
}
else {
sViewer = message + "\n";
}


// Use extracted data
    // Viewer Check Timeout
llSetText(sViewer+sTitle, vColor, 1.0);
    // timer::UsedMem = 12224
}
    timer() {
        // Memory test
        llScriptProfiler(PROFILE_SCRIPT_MEMORY);


// Memory test
        llSetTimerEvent(.0);
llScriptProfiler(PROFILE_NONE);
        llListenRemove(hRLVCListen);
llOwnerSay("listen::UsedMem = " + (string)llGetSPMaxMemory());
 
}
        sViewer = "";
        llSetText(sTitle, vColor, 1.0);
 
        llOwnerSay(
            "No RLV-capable viewer detected (or RLV is off).\n"+
            "To repeat the ckeck, please reattach or chat this:\n"+
            "/"+(string)CHANNEL+" VERSION");
 
        // Memory test
        llScriptProfiler(PROFILE_NONE);
        llOwnerSay("timer::UsedMem = " + (string)llGetSPMaxMemory());
    }
}
}
</lsl>
</syntaxhighlight>
 
[[Category:LSL Examples]]
[[Category:RestrainedLove]]

Latest revision as of 13:16, 31 January 2025

With upcoming new third party viewer policy, displaying of viewer tags is no more allowed and was also deactivated. Before the TPV changes, with some viewers it was possible to see what viewer other residents are using, which is seen as injuring of privacy on the other side, but on the other side an improvement in giving viewer-dependant residental support. This advantage of viewer tags is taken by the TPV changes.

The Viewer Titler tries to help here. It works with RLV technology and requests the viewer version by using its RLV interface. After viewer response, the type and version of the viewer is shown as hover text.

The comment block inside the script provides further info about features and usage of the 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 <http://www.gnu.org/licenses/>.
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//
// Script: RLVVersionTitler
//
// Features
//
//   1. Displays the viewr version and additional message as hover text.
//   2. Requests Viewer and version by using it's RLV interface.
//      This works only by using on a RLV-capable viewer.
//   3. Hides, shows the title and allows setting a color.
//   4. Freezing reduces lag by releasing listeners.
//
// RLV API (version checking part)
//
//   http://wiki.secondlife.com/wiki/LSL_Protocol/RestrainedLifeAPI
//
// Usage
//
//   1. Rezz a prim (any shape and size) and rename it nicelly.
//   2. Put the script inside, the prim turns invisible.
//   3. Pick up the prim (highlight transparency.)
//   4. To use finally, just wear on HUD or avatar.
//
// User control
//
//   /111 VERSION     - Checks the RLV version (if startup check failed.)
//   /111 HIDE        - Hides the titler.
//   /111 SHOW        - Shows the titler.
//   /111 STOP        - Removes listen. To reactivate, simply reattach. 
//   /111 COLOR Name  - Sets titler color. Name is a LSL vector or one of
//                      White, Grey Black, Red, Green, Blue, Yellow, Magenta,
//                      Cyan, Default.
//   /111 Text        - Sets an additional titler text.
//   /111 CLEAR       - Removes the additional text, shows title.
//
// Note
//
// After script modifications and calculation of the memory usage, you may
// comment out the test code - this reduces script spam and script code.
//
//----------------------------------------------------------------------------
// Author  Jenna Felton
// Version 1.0.1
//----------------------------------------------------------------------------

integer CHANNEL = 111;

list NAMES = [
    "WHITE", "GREY", "BLACK",
    "RED", "GREEN", "BLUE",
    "YELLOW", "MAGENTA", "CYAN",
    "DEFAULT"];

list COLORS = [
    <1.0, 1.0, 1.0>, <0.5, 0.5, 0.5>, ZERO_VECTOR,
    <1.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 1.0>,
    <1.0, 1.0, 0.0>, <1.0, 0.0, 1.0>, <0.0, 1.0, 1.0>,
    <0.98, 0.69, 0.36>];

integer hUserListen;
integer hRLVCListen;
integer gRLVCChan;

string sViewer = "";
string sTitle = "";
vector vColor = <0.98, 0.69, 0.36>;

key kOwner;

// Added by Kireji Haiku to reduce memory usage and improve readability
reset_listeners_and_timer() 
{
    llListenRemove(hRLVCListen);
    gRLVCChan   = 1000000 + (integer)llFrand(100000.0);
    hRLVCListen = llListen(gRLVCChan, "", kOwner, "");

    llOwnerSay("detecting viewer...");
    llOwnerSay("@version=" + (string)gRLVCChan);

    // set timer to go off every other minute
    llSetTimerEvent(60.0);
}

default {
    // init::UsedMem = 12312
    state_entry() {
        // set transparent
        llSetAlpha(.0, ALL_SIDES);

        kOwner  = llGetOwner();
        sViewer = "";
        sTitle  = "";

        hUserListen = llListen(CHANNEL, "", kOwner, "");

        reset_listeners_and_timer();

        // Checks the memory usage and reduces by setting less
        llOwnerSay("init::UsedMem = "+(string)llGetUsedMemory());
        llSetMemoryLimit(24000);
    }

    // onrez::UsedMem = 12410
    on_rez(integer start_param) {
        // Memory test
        llScriptProfiler(PROFILE_SCRIPT_MEMORY);

        if (kOwner != llGetOwner()) llResetScript();

        reset_listeners_and_timer();

        // Memory test
        llScriptProfiler(PROFILE_NONE);
        llOwnerSay("onrez::UsedMem = " + (string)llGetSPMaxMemory());
    }

    // listen::UsedMem = 12378 (rougly min)
    // listen::UsedMem = 13490 (rougly max)
    listen(integer chan, string name, key id, string message) {
        // Memory test
        llScriptProfiler(PROFILE_SCRIPT_MEMORY);

        // User control
        if (chan == CHANNEL) {
            llSetTimerEvent(.0);
            llListenRemove(hRLVCListen);

            name = llToUpper(message);
            
            if (name == "HIDE") {
                llSetText("", vColor, .0);
            }
            
            else if (name == "SHOW") {
                llSetText(sViewer+sTitle, vColor, 1.0);
            }
            
            else if (name == "VERSION") {
                reset_listeners_and_timer();
            }
            
            else if (name == "STOP") {
                llOwnerSay("/me is frozen. To unfreeze, please reattach");
                llListenRemove(hUserListen);
            }
            
            else if (llGetSubString(name, 0, 5) == "COLOR ") {
                name = llGetSubString(name, 6, -1);
                name = llStringTrim(name, STRING_TRIM_HEAD);

                // Look for color names. If found - use color value
                chan = llListFindList(NAMES, [name]);
                if (chan > -1) {
                    vColor = llList2Vector(COLORS, chan);
                }

                // Not found - parse the given vector to color value
                else {
                    list tmp = llParseString2List(name, ["<", ",", " ", ">"], []);
                    vColor   = <llList2Float(tmp, 0), llList2Float(tmp, 1), llList2Float(tmp, 2)>;
                }

                llSetText(sViewer+sTitle, vColor, 1.0);
            }
            
            else if (name == "CLEAR") {
                sTitle = "";
                llSetText(sViewer, vColor, 1.0);
            }
            
            // Unknown command. Fine, the user gets a title.
            else {
                sTitle = message;
                llSetText(sViewer+sTitle, vColor, 1.0);
            }
        }

        // Viewer version response. Example answers:
        // message = "RestrainedLife viewer v1.17 (CV 1.22.11.0)"
        //           "RestrainedLife viewer v1.18 (SL 1.23.4)"
        //           "RestrainedLife viewer v1.22.0 (Emerald Viewer - RLVa 1.0.5)"
        //           "RestrainedLife viewer v1.22.1 (1.22.12.0)
        //           "RestrainedLove viewer v2.2.0 (Phoenix Viewer 1.5.2.908 - RLVa 1.1.3)"
        //           "RestrainedLife viewer v2.7.0 (Firestorm 3.3.0.24880 - RLVa 1.4.3)"
        else if (chan == gRLVCChan) {
            llSetTimerEvent(0.0);
            llListenRemove(hRLVCListen);

            // Separate the name:
            // message = "RLV version (viewer signature)"
            //  -> tmp = ["RLV version", "viewer signature"]
            list tmp = llParseString2List(message, [" (", ")"], []);
            message  = llList2String(tmp, 1);

            // If no viewer name set, "(1.22.12.0)", use RLV version
            name = llGetSubString(message, 0, 0);
            if (name == "" || name == "0" || (integer)name != 0) {
                sViewer = llList2String(tmp, 0) + "\n";
            }
            else {
                sViewer = message + "\n";
            }

            // Use extracted data
            llSetText(sViewer+sTitle, vColor, 1.0);
        }

        // Memory test
        llScriptProfiler(PROFILE_NONE);
        llOwnerSay("listen::UsedMem = " + (string)llGetSPMaxMemory());
    }

    // Viewer Check Timeout
    // timer::UsedMem = 12224
    timer() {
        // Memory test
        llScriptProfiler(PROFILE_SCRIPT_MEMORY);

        llSetTimerEvent(.0);
        llListenRemove(hRLVCListen);

        sViewer = "";
        llSetText(sTitle, vColor, 1.0);

        llOwnerSay(
            "No RLV-capable viewer detected (or RLV is off).\n"+
            "To repeat the ckeck, please reattach or chat this:\n"+
            "/"+(string)CHANNEL+" VERSION");

        // Memory test
        llScriptProfiler(PROFILE_NONE);
        llOwnerSay("timer::UsedMem = " + (string)llGetSPMaxMemory());
    }
}