User talk:ZachSmith Resident: Difference between revisions

From Second Life Wiki
Jump to navigation Jump to search
Blanked the page
No edit summary
Line 1: Line 1:
[[User:ZachSmith Resident|ZachSmith Resident]] 14:52, 27 May 2012 (PDT)This is a script made for hovertext. It has a listen so it can hear chat commands to set color and text.


//Advanced hovertext script by ZachSmith Resident
//This is a very useful and easy to use advanced hovertext script.
//Hopefully you can use this script or maybe even have it help you to better learn scripting.
//global variables
string Htext;
vector red = <1,0,0>;
vector green = <0,1,0>;
vector blue = <0,0,1>;
vector white = <1,1,1>;
vector grey = <.5,.5,.5>;
vector black = <0,0,0>;
vector yellow = <1,1,0>;
vector cyan = <0,1,1>;
vector magenta = <1,0,1>;
vector cur_color;
//premade function for saying the help text
llHelp()
{
    llSay(0, "All commands are said in local chat\nChat commands:\n 'help'\n'text color red'\n'text color green'\n'text color blue'\n'text color white'\n'text color grey'\n'text color black'\n'text color yellow'\n'text color cyan'\n'text color magenta'\n'text on'\n'text off'\n'text set'");
}
default
{
    on_rez(integer start_params)
    {
        //when this item enters world say the help text
        llHelp();
    }
    state_entry()
    {
        //Set cur_color to white, text to default and turn the listen on
        cur_color = white;
        Htext = "Hello, Avatar!";
        llListen(0, "", llGetOwner(), "");
        //set the text on the prim to current text and color
        llSetText(Htext,cur_color, 1);
    }
    listen(integer channel, string name, key id, string message)
    {
        if(message == "text on")
        {
            //narrow scope and filter for only the proper chat commands.
            llSetText(Htext,cur_color, 1);
            //set the text on the prim to current text and color
        }
        else if(message == "text off")
        {
            //narrow scope and filter for only the proper chat commands.
            llSetText(Htext,cur_color, 0);
            //set the text on the prim to current text and color but set the alpha so it is not seen
        }
        else if(message == "text color red")
        {
            cur_color = red;
            //set new cur_color
            llSetText(Htext,cur_color, 1);
            //set the text on the prim to current text and color
        }
        else if(message == "text color green")
        {
            cur_color = green;
            //set new cur_color
            llSetText(Htext,cur_color, 1);
            //set the text on the prim to current text and color
        }
        else if(message == "text color blue")
        {
            cur_color = blue;
            //set new cur_color
            llSetText(Htext,cur_color, 1);
            //set the text on the prim to current text and color
        }
        else if(message == "text color white")
        {
            cur_color = white;
            //set new cur_color
            llSetText(Htext,cur_color, 1);
            //set the text on the prim to current text and color
        }
        else if(message == "text color grey")
        {
            cur_color = grey;
            //set new cur_color
            llSetText(Htext,cur_color, 1);
            //set the text on the prim to current text and color
        }
        else if(message == "text color black")
        {
            cur_color = black;
            //set new cur_color
            llSetText(Htext,cur_color, 1);
            //set the text on the prim to current text and color
        }
        else if(message == "text color yellow")
        {
            cur_color = yellow;
            //set new cur_color
            llSetText(Htext,cur_color, 1);
            //set the text on the prim to current text and color
        }
        else if(message == "text color cyan")
        {
            cur_color = cyan;
            //set new cur_color
            llSetText(Htext,cur_color, 1);
            //set the text on the prim to current text and color
        }
        else if(message == "text color magenta")
        {
            cur_color = magenta;
            //set new cur_color
            llSetText(Htext,cur_color, 1);
            //set the text on the prim to current text and color
        }
        else if(message == "help")
        {
            llHelp();
            //say help message
        }
        else if(message == "text set")
        {
            llListen(7, "", llGetOwner(), "");
            //listen on channel 7 so that you can hear the new text.
            llSay(0, "Please say what you want your message to be on channel 7. EX: /7 Hello, Avatar!");
            //give instructions on how to set the new text
        }
        else
        {
            //if the message didn't fit any of the other messages above
            if(channel == 7)
            {
                //if what was said was on channel 7
                Htext = message;
                //set text to what the script heard
                llSetText(Htext,cur_color, 1);
                //set the text on the prim to current text and color
                llListenRemove(llListen(7, "", llGetOwner(), ""));
                //turn the listener on channel 7 off to reduce lag.
            }
        }
    }
}

Revision as of 14:52, 27 May 2012

ZachSmith Resident 14:52, 27 May 2012 (PDT)This is a script made for hovertext. It has a listen so it can hear chat commands to set color and text.


//Advanced hovertext script by ZachSmith Resident //This is a very useful and easy to use advanced hovertext script. //Hopefully you can use this script or maybe even have it help you to better learn scripting.

//global variables string Htext; vector red = <1,0,0>; vector green = <0,1,0>; vector blue = <0,0,1>; vector white = <1,1,1>; vector grey = <.5,.5,.5>; vector black = <0,0,0>; vector yellow = <1,1,0>; vector cyan = <0,1,1>; vector magenta = <1,0,1>; vector cur_color;

//premade function for saying the help text llHelp() {

   llSay(0, "All commands are said in local chat\nChat commands:\n 'help'\n'text color red'\n'text color green'\n'text color blue'\n'text color white'\n'text color grey'\n'text color black'\n'text color yellow'\n'text color cyan'\n'text color magenta'\n'text on'\n'text off'\n'text set'");

}

default {

   on_rez(integer start_params)
   {
       //when this item enters world say the help text
       llHelp();
   }
   state_entry()
   {
       //Set cur_color to white, text to default and turn the listen on
       cur_color = white;
       Htext = "Hello, Avatar!";
       llListen(0, "", llGetOwner(), "");
       //set the text on the prim to current text and color
       llSetText(Htext,cur_color, 1);
   }
   listen(integer channel, string name, key id, string message)
   {
       if(message == "text on")
       {
           //narrow scope and filter for only the proper chat commands.
           llSetText(Htext,cur_color, 1);
           //set the text on the prim to current text and color
       }
       else if(message == "text off")
       {
           //narrow scope and filter for only the proper chat commands.
           llSetText(Htext,cur_color, 0);
           //set the text on the prim to current text and color but set the alpha so it is not seen
       }
       else if(message == "text color red")
       {
           cur_color = red;
           //set new cur_color
           llSetText(Htext,cur_color, 1);
           //set the text on the prim to current text and color
       }
       else if(message == "text color green")
       {
           cur_color = green;
           //set new cur_color
           llSetText(Htext,cur_color, 1);
           //set the text on the prim to current text and color
       }
       else if(message == "text color blue")
       {
           cur_color = blue;
           //set new cur_color
           llSetText(Htext,cur_color, 1);
           //set the text on the prim to current text and color
       }
       else if(message == "text color white")
       {
           cur_color = white;
           //set new cur_color
           llSetText(Htext,cur_color, 1);
           //set the text on the prim to current text and color
       }
       else if(message == "text color grey")
       {
           cur_color = grey;
           //set new cur_color
           llSetText(Htext,cur_color, 1);
           //set the text on the prim to current text and color
       }
       else if(message == "text color black")
       {
           cur_color = black;
           //set new cur_color
           llSetText(Htext,cur_color, 1);
           //set the text on the prim to current text and color
       }
       else if(message == "text color yellow")
       {
           cur_color = yellow;
           //set new cur_color
           llSetText(Htext,cur_color, 1);
           //set the text on the prim to current text and color
       }
       else if(message == "text color cyan")
       {
           cur_color = cyan;
           //set new cur_color
           llSetText(Htext,cur_color, 1);
           //set the text on the prim to current text and color
       }
       else if(message == "text color magenta")
       {
           cur_color = magenta;
           //set new cur_color
           llSetText(Htext,cur_color, 1);
           //set the text on the prim to current text and color
       }
       else if(message == "help")
       {
           llHelp();
           //say help message
       }
       else if(message == "text set")
       {
           llListen(7, "", llGetOwner(), "");
           //listen on channel 7 so that you can hear the new text.
           llSay(0, "Please say what you want your message to be on channel 7. EX: /7 Hello, Avatar!");
           //give instructions on how to set the new text
       }
       else
       {
           //if the message didn't fit any of the other messages above
           if(channel == 7)
           {
               //if what was said was on channel 7
               Htext = message;
               //set text to what the script heard
               llSetText(Htext,cur_color, 1);
               //set the text on the prim to current text and color
               llListenRemove(llListen(7, "", llGetOwner(), ""));
               //turn the listener on channel 7 off to reduce lag.
           }
       }
   }

}