Jump to content

100% Menu Controlled Hover Text


Recommended Posts

My friend had one of these that was giving her issues because the author never removed the listen from the script, so I wrote one.

Figured I would share it since I borrowed a lot of it from the lsl wiki pages on llSetText and llDialog anyway.

Enjoy!

vector BLUE    = <0,0,0.8>;
vector GREEN   = <0,225,0>;
vector YELLOW  = <1,0.863,0>;
vector ORANGE  = <1,0.522,0.106>;
vector RED     = <225,0,0>;
vector PURPLE  = <0.694,0.051,0.788>;
vector WHITE   = <1,1,1>;
vector BLACK   = <0,0,0>;
vector PINK    = <0.941,0.071,0.745>;
 
string  hoverText   = "Touch To Set Text And Color"; //Default text goes between the parentheses 
vector  hoverColor  = WHITE;//  set color default from predefined vectors or use any RGB color vector
float   hoverAlpha  = 1.0; // Sets the text's transparency, 1.0 being opaque, while 0.0 would be transparent

list dialogButtons = ["-","Reset","Close","Set Text","Set Color","No Hover"]; //Defines dialog menu buttons
list colorButtons = ["Yellow", "Orange", "Pink","Red","Green","Purple","White","Black","Blue"];

string dialogMsg = "\nSelect An Option";
string dialogMsg2 = "\nPlease select what color you would like your hover text to be.";
string textbox = "\nWrite what you would like your hover text to say.";
integer dialogChan;
integer txtlisten;
integer dialogHandle;

open_menu(key inputKey, string inputString, list inputList)
{
    dialogChan = (integer)llFrand(DEBUG_CHANNEL)*-1;
    dialogHandle = llListen(dialogChan, "", inputKey, "");
    llDialog(inputKey, inputString, inputList, dialogChan);
    llSetTimerEvent(30.0);
}
 
close_menu()
{
    llSetTimerEvent(0.0);
    llListenRemove(dialogHandle);
}
 
default
{  
    state_entry()
    {
        llSetText(hoverText, hoverColor, hoverAlpha);
    }
    
    touch_start(integer num)
    {
        key toucher = llDetectedKey(0);
        if (toucher == llGetOwner())
        {
            open_menu(toucher, dialogMsg, dialogButtons);
        }
        
        else if (toucher != llGetOwner())
        {
            return;
        }
    }
    
    listen(integer chan, string name, key toucher, string msg)
    {   
        if (chan == dialogChan && msg == "Set Text")
        {
            txtlisten = llListen(-94652,"",toucher,"");
            llTextBox(toucher,textbox,-94652); 
            llSetTimerEvent(30);
        }
        
        else if (chan == -94652)
        {
            hoverText = (string)msg;
            llSetText(hoverText, hoverColor, hoverAlpha);
            llListenRemove(txtlisten);
            llSetTimerEvent(0);
        }
        
        else if (chan == dialogChan && msg == "Set Color")
        {
            open_menu(toucher,dialogMsg2,colorButtons);
        }
        
        else if (chan == dialogChan && msg == "Reset")
        {
            hoverText = "Touch To Set Text And Color";
            hoverColor = WHITE;
            llSetText(hoverText, hoverColor, hoverAlpha);
            close_menu();
        }
        
        else if (chan == dialogChan && msg == "No Hover")
        {
            hoverText = "";
            llSetText(hoverText, hoverColor, hoverAlpha);
            close_menu();
        }
        
        else if (chan == dialogChan && msg == "-")
        {
            close_menu();
        }
        
        else if (chan == dialogChan && msg == "Close")
        {
            close_menu();
        }
        
        else if (chan == dialogChan && msg == "Blue")
        {
            hoverColor = BLUE;
            llSetText(hoverText, hoverColor, hoverAlpha);
            close_menu();
        }
        
        else if (chan == dialogChan && msg == "Black")
        {
            hoverColor = BLACK;
            llSetText(hoverText, hoverColor, hoverAlpha);
            close_menu();
        }
        
        else if (chan == dialogChan && msg == "Red")
        {
            hoverColor = RED;
            llSetText(hoverText, hoverColor, hoverAlpha);
            close_menu();
        }
        
        else if (chan == dialogChan && msg == "Purple")
        {
            hoverColor = PURPLE;
            llSetText(hoverText, hoverColor, hoverAlpha);
            close_menu();
        }
        
        else if (chan == dialogChan && msg == "Yellow")
        {
            hoverColor = YELLOW;
            llSetText(hoverText, hoverColor, hoverAlpha);
            close_menu();
        }
        
        else if (chan == dialogChan && msg == "White")
        {
            hoverColor = WHITE;
            llSetText(hoverText, hoverColor, hoverAlpha);
            close_menu();
        }
        
        else if (chan == dialogChan && msg == "Green")
        {
            hoverColor = GREEN;
            llSetText(hoverText, hoverColor, hoverAlpha);
            close_menu();
        }
        
        else if (chan == dialogChan && msg == "Orange")
        {
            hoverColor = ORANGE;
            llSetText(hoverText, hoverColor, hoverAlpha);
            close_menu();
        }
        
        else if (chan == dialogChan && msg == "Pink")
        {
            hoverColor = PINK;
            llSetText(hoverText, hoverColor, hoverAlpha);
            close_menu();
        }
    }
    
    timer()
    {
        llListenRemove(txtlisten);
        close_menu();
        llOwnerSay("The dialog menu has timed out.");
    }
}
  • Thanks 2
Link to post
Share on other sites

That's a nice utility script.  Here's a way to squeeze it into a shorter script that the user can drop into any object, use, and then delete when done, so that it doesn't interfere with later scripts that may have touch* events.

// Modified Hover Text Script -- Rolig Loon -- June 2015// Adapted from "100% Menu Controlled Hover Text" by Lankarion Lock (posted at https://community.secondlife.com/t5/LSL-Library/100-Menu-Controlled-Hover-Text/m-p/2942411)// This version simplifies dialog options by refering to a strided list gColors and removing user functions. It also adds an option to remove the script when the owner has finished with it.list gColors = ["Blue",<0,0,0.8>,"Green",<0,225,0>,"Yellow",<1,0.863,0>,"Orange",<1,0.522,0.106>,"Red",<225,0,0>,"Purple",<0.694,0.051,0.788>,"White",<1,1,1>,"Black",<0,0,0>,"Pink",<0.941,0.071,0.745>]; string  hoverText   = "Touch To Set Text And Color"; //Default text goes between the parentheses vector  hoverColor  = <1.0,1.0,1.0>;//  set color default from predefined vectors or use any RGB color vectorfloat   hoverAlpha  = 1.0; // Sets the text's transparency, 1.0 being opaque, while 0.0 would be transparentlist dialogButtons = ["Reset","Close Menu","Set Text","Set Color","No Hover","Kill Script"]; //Defines dialog menu buttonslist colorButtons = ["Yellow", "Orange", "Pink","Red","Green","Purple","White","Black","Blue"];integer dialogChan;integer txtlisten;integer dialogHandle;default{      state_entry()    {        llSetText(hoverText, hoverColor, hoverAlpha);    }        touch_start(integer num)    {        key toucher = llDetectedKey(0);        if (toucher == llGetOwner())        {            dialogChan = (integer)llFrand(DEBUG_CHANNEL)*-1;            dialogHandle = llListen(dialogChan, "", toucher, "");            llDialog(toucher, "\nSelect An Option", dialogButtons, dialogChan);            llSetTimerEvent(30.0);        }     }        listen(integer chan, string name, key toucher, string msg)    {         llSetTimerEvent(0.0);  // Message received in time. Kill timer.        if (msg == "Set Text")        {            txtlisten = llListen(dialogChan - 1,"",toucher,""); //Set TextBox to listen on an offset to dialogChan            llTextBox(toucher,"\nWrite what you would like your hover text to say. Then click \"Submit\".",dialogChan - 1);             llSetTimerEvent(30.0);        }                else if (chan == dialogChan - 1)        {            hoverText = (string)msg;            llSetText(hoverText, hoverColor, hoverAlpha);            llListenRemove(txtlisten);            llDialog(toucher, "\nSelect An Option", dialogButtons, dialogChan);  //Return to main menu            llSetTimerEvent(30.0);        }                else if (msg == "Set Color")        {            llSetTimerEvent(30.0);            llDialog(toucher,"\nPlease select what color you would like your hover text to be.",colorButtons,dialogChan);        }                else if (msg == "Close Menu")        {            llListenRemove(dialogHandle);        }        else if (msg == "Kill Script") // Script no longer needed.  Remove.        {            llRemoveInventory(llGetScriptName());        }        else        {            if (msg == "Reset")            {                hoverColor = <1.0,1.0,1.0>;                hoverAlpha = 1.0;                hoverText = "Touch To Set Text And Color";            }                    if (msg == "No Hover")            {                 hoverAlpha = 0.0;            }            else            {                 integer idx = llListFindList(gColors,[msg]);                 hoverColor = (vector)llList2String(gColors,idx+1);                 hoverAlpha = 1.0;            }            llListenRemove(dialogHandle);                                llSetText(hoverText, hoverColor, hoverAlpha);        }    }        timer()    {        llSetTimerEvent(0.0);        llListenRemove(txtlisten);        llListenRemove(dialogHandle);        llOwnerSay("The dialog menu has timed out.");    }}

Edit: Clarified dialog nesting.

  • Like 1
  • Thanks 1
Link to post
Share on other sites
  • 5 years later...
On 6/22/2015 at 10:49 PM, Rolig Loon said:

That's a nice utility script.  Here's a way to squeeze it into a shorter script that the user can drop into any object, use, and then delete when done, so that it doesn't interfere with later scripts that may have touch* events.


// Modified Hover Text Script -- Rolig Loon -- June 2015// Adapted from "100% Menu Controlled Hover Text" by Lankarion Lock (posted at https://community.secondlife.com/t5/LSL-Library/100-Menu-Controlled-Hover-Text/m-p/2942411)// This version simplifies dialog options by refering to a strided list gColors and removing user functions. It also adds an option to remove the script when the owner has finished with it.list gColors = ["Blue",<0,0,0.8>,"Green",<0,225,0>,"Yellow",<1,0.863,0>,"Orange",<1,0.522,0.106>,"Red",<225,0,0>,"Purple",<0.694,0.051,0.788>,"White",<1,1,1>,"Black",<0,0,0>,"Pink",<0.941,0.071,0.745>]; string  hoverText   = "Touch To Set Text And Color"; //Default text goes between the parentheses vector  hoverColor  = <1.0,1.0,1.0>;//  set color default from predefined vectors or use any RGB color vectorfloat   hoverAlpha  = 1.0; // Sets the text's transparency, 1.0 being opaque, while 0.0 would be transparentlist dialogButtons = ["Reset","Close Menu","Set Text","Set Color","No Hover","Kill Script"]; //Defines dialog menu buttonslist colorButtons = ["Yellow", "Orange", "Pink","Red","Green","Purple","White","Black","Blue"];integer dialogChan;integer txtlisten;integer dialogHandle;default{      state_entry()    {        llSetText(hoverText, hoverColor, hoverAlpha);    }        touch_start(integer num)    {        key toucher = llDetectedKey(0);        if (toucher == llGetOwner())        {            dialogChan = (integer)llFrand(DEBUG_CHANNEL)*-1;            dialogHandle = llListen(dialogChan, "", toucher, "");            llDialog(toucher, "\nSelect An Option", dialogButtons, dialogChan);            llSetTimerEvent(30.0);        }     }        listen(integer chan, string name, key toucher, string msg)    {         llSetTimerEvent(0.0);  // Message received in time. Kill timer.        if (msg == "Set Text")        {            txtlisten = llListen(dialogChan - 1,"",toucher,""); //Set TextBox to listen on an offset to dialogChan            llTextBox(toucher,"\nWrite what you would like your hover text to say. Then click \"Submit\".",dialogChan - 1);             llSetTimerEvent(30.0);        }                else if (chan == dialogChan - 1)        {            hoverText = (string)msg;            llSetText(hoverText, hoverColor, hoverAlpha);            llListenRemove(txtlisten);            llDialog(toucher, "\nSelect An Option", dialogButtons, dialogChan);  //Return to main menu            llSetTimerEvent(30.0);        }                else if (msg == "Set Color")        {            llSetTimerEvent(30.0);            llDialog(toucher,"\nPlease select what color you would like your hover text to be.",colorButtons,dialogChan);        }                else if (msg == "Close Menu")        {            llListenRemove(dialogHandle);        }        else if (msg == "Kill Script") // Script no longer needed.  Remove.        {            llRemoveInventory(llGetScriptName());        }        else        {            if (msg == "Reset")            {                hoverColor = <1.0,1.0,1.0>;                hoverAlpha = 1.0;                hoverText = "Touch To Set Text And Color";            }                    if (msg == "No Hover")            {                 hoverAlpha = 0.0;            }            else            {                 integer idx = llListFindList(gColors,[msg]);                 hoverColor = (vector)llList2String(gColors,idx+1);                 hoverAlpha = 1.0;            }            llListenRemove(dialogHandle);                                llSetText(hoverText, hoverColor, hoverAlpha);        }    }        timer()    {        llSetTimerEvent(0.0);        llListenRemove(txtlisten);        llListenRemove(dialogHandle);        llOwnerSay("The dialog menu has timed out.");    }}

Edit: Clarified dialog nesting.

@Lankarion LockThank you for this script, it is right along the lines of what I need and works just fine, though I am hoping to then use Rolig's mod as I want to use another clickable script (an item giver) in the same object.  But scripters like you and Rolig who shar your expertise freely are such a blessing in SL.  (I do my little bit in other ways  *giggle*   ...   but scripting will never be one of them  :(  )

@Rolig LoonThank you for providing an alternative version.  Although your edit says it clarified the dialog nesting, in actual fact for me it still shows up here as one long line.  I would love to use your mod, but not sure how to fix that myself (I am afraid I am NO scripter, not even close).

Link to post
Share on other sites

Turns out the forums really don't like returns. for future reference, seems you have to open the file in a document editor like Libreoffice or Word before copy-pasting to get it to look right. I still had to fix the returns manually in vim though.

// Modified Hover Text Script -- Rolig Loon -- June 2015
// Adapted from "100% Menu Controlled Hover Text" by Lankarion Lock (posted at https:
//community.secondlife.com/t5/LSL-Library/100-Menu-Controlled-Hover-Text/m-p/2942411)
// This version simplifies dialog options by refering to a strided list gColors and removing user functions. It also adds an option to remove the script when the owner has finished with it.
list gColors =
[
    "Blue",<0,0,0.8>,
    "Green",<0,225,0>,
    "Yellow",<1,0.863,0>,
    "Orange",<1,0.522,0.106>,
    "Red",<225,0,0>,
    "Purple",<0.694,0.051,0.788>,
    "White",<1,1,1>,
    "Black",<0,0,0>,
    "Pink",<0.941,0.071,0.745>
];
string  hoverText   = "Touch To Set Text And Color"; 
//Default text goes between the parentheses
vector  hoverColor  = <1.0,1.0,1.0>;
//  set color default from predefined vectors or use any RGB color vector
float   hoverAlpha  = 1.0; 
// Sets the text's transparency, 1.0 being opaque, while 0.0 would be transparent
list dialogButtons = ["Reset","Close Menu","Set Text","Set Color","No Hover","Kill Script"]; 
//Defines dialog menu buttons
list colorButtons = ["Yellow", "Orange", "Pink","Red","Green","Purple","White","Black","Blue"];
integer dialogChan;
integer txtlisten;
integer dialogHandle;
default
{
    state_entry()
    {
        llSetText(hoverText, hoverColor, hoverAlpha);
    }
    touch_start(integer num)
    {
        key toucher = llDetectedKey(0);
        if (toucher == llGetOwner())
        {
            dialogChan = (integer)llFrand(DEBUG_CHANNEL)*-1;
            dialogHandle = llListen(dialogChan, "", toucher, "");
            llDialog(toucher, "\nSelect An Option", dialogButtons, dialogChan);
            llSetTimerEvent(30.0);
        }
     }
     listen(integer chan, string name, key toucher, string msg)
     {
         llSetTimerEvent(0.0);
  
          // Message received in time. Kill timer.
        if (msg == "Set Text")
        {
            txtlisten = llListen(dialogChan - 1,"",toucher,""); 
            //Set TextBox to listen on an offset to dialogChan
            llTextBox(toucher,"\nWrite what you would like your hover text to say. Then click \"Submit\".",dialogChan - 1);
             llSetTimerEvent(30.0);
        }
        else if (chan == dialogChan - 1)
        {
            hoverText = (string)msg;
            llSetText(hoverText, hoverColor, hoverAlpha);
            llListenRemove(txtlisten);
            llDialog(toucher, "\nSelect An Option", dialogButtons, dialogChan);  
            //Return to main menu
            llSetTimerEvent(30.0);
        }
        else if (msg == "Set Color")
        {
            llSetTimerEvent(30.0);
            llDialog(toucher,"\nPlease select what color you would like your hover text to be.",colorButtons,dialogChan);
        }
        else if (msg == "Close Menu")
        {
            llListenRemove(dialogHandle);
        }
        else if (msg == "Kill Script") 
        // Script no longer needed.  Remove.
        {
            llRemoveInventory(llGetScriptName());
        }
        else
        {
            if (msg == "Reset")
            {
                hoverColor = <1.0,1.0,1.0>;
                hoverAlpha = 1.0;
                hoverText = "Touch To Set Text And Color";
            }
            if (msg == "No Hover")
            {
                 hoverAlpha = 0.0;
            }
            else
            {
                 integer idx = llListFindList(gColors,[msg]);
                 hoverColor = (vector)llList2String(gColors,idx+1);
                 hoverAlpha = 1.0;
            }
            llListenRemove(dialogHandle);
            llSetText(hoverText, hoverColor, hoverAlpha);
        }
    }
    timer()
    {
        llSetTimerEvent(0.0);
        llListenRemove(txtlisten);
        llListenRemove(dialogHandle);
        llOwnerSay("The dialog menu has timed out.");
    }
}

 

Edited by Quistessa
added some more newlines after '{'s
  • Like 2
Link to post
Share on other sites

Thanks, @Quistessa . I haven't checked this forum in a few days, so I missed seeing Stephanie's note.  Yeah, each time the Lab has changed forum software, scripts have been messed up here. Thanks for doing the manual editing to get that script looking good again.

  • Like 1
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...