Jump to content

Menu Color Changer Script:: Any Help Appreciated


AnnieBumbleclaw
 Share

You are about to reply to a thread that has been inactive for 4075 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

So I am currently working on a 5 prim creation and I only want two of those prims to change color that is accessed through a menu. I have my "switch" script and my "bulb" script that I will be displaying for you. I am not having a problem setting anything up and the menu works great. However, it only allows 12 entries and I have plenty more colors I want to add to the menu. The script is full perm and I am able to modify. Any help would be appreciated if someone can let me know how do I make this menu have more than 12 entries?

Switch Prim Script:

 

list menu_button = [ // the button to be shown on the drop down menu, maximum 12 entrys
"Red",
"Orange",
"Yellow",
"Green",
"Blue",
"Purple",
"Black",
"White" // Note: no [ , ] comma for the last entry
];


//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
//_/_/_/_/_/_/_/_/_/ No need to change from here _/_/_/_/_/_/_/_/_/
//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

key toucher = NULL_KEY; // who touches to use
integer menu_chan = -1; // channel to use in the menu
integer listen_num = -1; // menu listen event handler

default
{
state_entry()
{
}
touch_start(integer total_number)
{
toucher = llDetectedKey(0);
menu_chan = 0 - (integer)llFrand(2147483647);
listen_num = llListen(menu_chan,"", toucher,"");
llDialog(toucher, "Select options:", menu_button, menu_chan);
llSetTimerEvent(60.0); // 60 sec timer used to in case the "ignore" button is pressed or time out
}
timer()
{ // 60 sec timer used to in case the "ignore" button is pressed or time out
llListenRemove(listen_num);
llSetTimerEvent(0.0);
}
listen(integer channel, string name, key id, string message)
{
integer msg_index = llListFindList(menu_button,(list)message);
if (msg_index != -1)
llMessageLinked(LINK_SET,0,(string)msg_index,NULL_KEY);

llSetTimerEvent(0.1); // just to save resources
}
}

 

 

Bulb Prim Script:

list color_value = [ // the color value corresponding to the menu_button on the [ Switch ] script
<1.0,0.0,0.0>, // Red
<1.0,0.5,0.0>, // Orange
<1.0,1.0,0.0>, // Yellow
<0.0,1.0,0.0>, // Green
<0.0,0.0,1.0>, // Blue
<0.5,0.0,1.0>, // Purple
<0.0,0.0,0.0>, // Black
<1.0,1.0,1.0> // White
];

integer face_number = ALL_SIDES; // the face number to change on the bulb prim


//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
//_/_/_/_/_/_/_/_/_/ No need to change from here _/_/_/_/_/_/_/_/_/
//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

default
{
state_entry()
{
}
link_message(integer sender,integer num,string msg,key id)
{
integer msg_index = (integer)msg;
llSetColor(llList2Vector(color_value,msg_index),face_number);
}
}

 

Can someone please help? :)

Link to comment
Share on other sites

Once you settle on a dialog approach, it would be an improvement to remove the scripts from the bulb prims and replace them with llSetLinkPrimitiveParamsFast called from the single "switch" script. You just need a way to distinguish the "bulb" prims from others in the linkset. This is often done using a distinctive prim name so the script can readily scan through the linkset to make a list of the links it should re-color.

  • Like 1
Link to comment
Share on other sites

Before your scripts get much larger, it might be pointed out that you would benefit from merging them into one and using llSetLinkPrimitiveParamsFast ( http://wiki.secondlife.com/wiki/LlSetLinkPrimitiveParamsFast )  to set the colors of your light prims. That way, you'd not only avoid having to send messages between scripts, you'd consolidate your lists in one place, making your code much easier to maintain and update.

 

(Edited to add: must learn to type faster. lol)

  • Like 1
Link to comment
Share on other sites

If you follow the suggestion of controllling everything from one script -- which, to my mind, is a wise thing to do -- I would recommend that you read the prim names (or descriptions) when the script starts or when links change rather than at run-time, on the argument that it's a waste of time and effort checking the prim names every time you want to turn the lights on or off.   Store the link numbers in a list and then run through that.

The only gotcha is that if you change the names of the prims after putting the script in, you need to reset it to make it re-read the list.

This example should demonstrate the method:

NOW CORRECTED

integer toggle;list bulbs;list find_prims(string which){    which = llToLower(llStringTrim(which,STRING_TRIM));    list prims;    integer max = llGetNumberOfPrims();    integer i;    if (max>1){//if it's part of a linkset        i=1;    }    do {        if(which ==llToLower(llStringTrim(llGetLinkName(i),STRING_TRIM))){            prims+=[i];        }    }    while (++i<=max);    return prims;}default{    state_entry()    {        bulbs = find_prims("bulb");    }    changed(integer change)    {        if(change & CHANGED_LINK){            find_prims("bulb");        }    }    on_rez(integer start_param)    {        bulbs = find_prims("bulb");    }    touch_start(integer total_number)    {        vector colour;        list params;        integer max = -llGetListLength(bulbs);        toggle=!toggle;        if(toggle){            colour=<1.0,0.0,0.0>;        }        else{            colour = <0.0,0.0,1.0>;        }        do{            params+=[PRIM_LINK_TARGET,llList2Integer(bulbs,max),PRIM_COLOR,ALL_SIDES,colour,1.0];        }        while(++max);        llSetLinkPrimitiveParamsFast(LINK_SET,params);        params=[];    }}

 

 

  • Like 2
Link to comment
Share on other sites

I appreciate all of the help I am receiving. This script worked well and it does color the two prims I want to color out of the 5. However, I want the script to be menu driven and when the menu pops up, I want the person to have the option of choosing various colors (about 20-50). How do I add it to the script so that when they click on the prim a menu pops up for them to change to different colors?

Link to comment
Share on other sites

I would use something like this.  I've just used  llDialog but you can easily, I think, adapt it to use one of the multi-page dialog methods mentioned earlier.

integer dialogChan;integer handle;list buttons;list colours =[	"Red",<1.0,0.0,0.0>,	"Greeen",<0.0,1.0,0.0>,	"Blue",<0.0,0.0,1.0>		//and so on		];default{	state_entry()	{		buttons = llList2ListStrided(colours,0,-1,2);  // create a new list comprising the colour names		dialogChan = (integer)llFrand(100000.0)+1000;	}	touch_start(integer total_number)	{		key k = llDetectedKey(0);		llListenRemove(handle);		handle = llListen(dialogChan,"",k,"");		llDialog(k,"Please choose a colour",buttons,dialogChan);		llSetTimerEvent(30.0);	}	timer()	{		llListenRemove(handle);		llSetTimerEvent(0.0);	}	listen(integer channel, string name, key id, string message)	{		integer n = llListFindList(colours, [message]);//find the index of the chosen colour name		if(~n){//check that you have found it -- hard to see how it couldn't be there, but check anyway			vector v = llList2Vector(colours,n+1);//the appropriate vector is the next item in the list			// do colour changing stuff here			llListenRemove(handle);			llSetTimerEvent(0.0);		}	}}

 

  • Like 1
Link to comment
Share on other sites

Keeping in mind that anything over 12 choices is going to have to involve submenus, are you sertain you want to present 20-50 named color choices? Why not have each color channel (red, blue and green) adjustable by (say) 10% up or down on each choice? That would give you nearly 1000 variations using only 6 buttons.

Link to comment
Share on other sites

I am certain I want to present my chosen colors between 20-50. I do realize it does involve submenus so I did some digging on some scripts and the closest I came to what I want is using the script I will be posting. The only thing is tha if I link all of them, it colors everything when I only want two specified prims colored. Any ideas on how to adjust this script so that it colors only two prims? 

 

Script:

// Default is to make the entire object change color, even if multiple prims.
integer ChangeAllPrims = FALSE; // set this to FALSE for this prim only

//-----START COLORS-----------------------------

list grayscale =["black",<0,0,0>,"white",<1,1,1>,"gray",<0.5,0.5,0.5>,"silver",<0.75,0.75,0.75>,"darkgray",<0.4,0.4,0.4>,
"lightgrey",<0.83,0.83,0.83>];
list reds = ["red",<1,0,0>,"darkred",<0.55,0,0>,"crimson",<0.86,0.08,0.24>,"indianred",<0.8,0.36,0.36>,
"orangered",<1,0.27,0>];
list pinks = ["hotpink",<1,0.41,0.71>,"pink", <1,0.75,0.8>,"lightpink",<1,0.71,0.76>,"deeppink",<1,0.08,0.58>,
"fuchsia",<1,0,1>,"orchid",<0.85,0.44,0.84>,"plum",<0.87,0.63,0.87>];
list violets = ["violet",<0.8,0.51,0.8>,"indigo",<0.29,0,0.51>,"lavender",<0.7,0.7,1>,"magenta",<1,0,1>,
"purple",<0.5,0,0.5>,"darkmagenta",<0.55,0,0.55>,"darkviolet",<0.58,0,0.83>,"blueviolet",<0.54,0.17,0.89>];
list dk_blues = ["darkblue",<0,0,0.55>,"blue",<0,0,1>,"deepskyblue",<0,0.75,1>,"mediumblue",<0,0,0.8>,
"midnightblue",<0.1,0.1,0.44>,"royalblue",<0.25,0.41,0.88>,"slateblue",<0.42,0.35,0.8>,"steelblue",<0.27,0.51,0.71>];
list lt_blues = ["teal",<0,0.5,0.5>,"turquoise",<0.25,0.88,0.82>,"darkcyan",<0,0.55,0.55>, "lightblue", <0.68,0.85,0.9>,
"aquamarine",<0.5,1,0.83>,"azure",<0.8,1,1>,"cyan",<0,1,0.9>,"skyblue",<0.53,0.81,0.92>];
list yellows = ["yellow",<1,1,0>,"gold",<1,0.84,0>,"lightyellow",<1,1,0.88>,"goldenrod",<0.85,0.65,0.13>,
"yellowgreen",<0.6,0.8,0.2>];
list dk_greens = ["darkgreen",<0,0.39,0>,"green",<0,0.5,0>,"forestgreen",<0.13,0.55,0.13>,"lawngreen",<0.49,0.99,0>,
"springgreen",<0,1,0.5>];
list lt_greens = ["lightgreen",<0.56,0.93,0.56>,"chartreuse",<0.5,1,0>,"greenyellow",<0.68,1,0.18>,"honeydew",<0.94,1,0.94>,
"limegreen",<0.2,0.8,0.2>,"mintcream",<0.96,1,0.98>,"seagreen",<0.18,0.55,0.34>];
list oranges = ["orange",<1,0.65,0>,"darkorange",<1,0.55,0>,"coral",<1,0.5,0.31>,"navajowhite",<1,0.87,0.68>,
"salmon",<0.98,0.5,0.45>,"seashell",<1,0.96,0.93>,"brown",<.24,.17,.15>];

//-----END COLORS-----------------------------

key toucher = NULL_KEY;
list sub_menu;
list main_menu = ["grayscale", "reds", "pinks", "violets", "dk_blues", "lt_blues", "yellows", "dk_greens", "lt_greens", "oranges"];

 

//FUNCTIONS

//owner menu
integer menu_handler;
integer menu_channel;
menu(key user,string title,list buttons)
{
llListenRemove(menu_handler);
menu_channel = (integer)(llFrand(99999.0) * -1);
menu_handler = llListen(menu_channel,"","","");
llDialog(user,title,buttons,menu_channel);
llSetTimerEvent(60.0);
}

default
{
on_rez( integer sparam )
{
llResetScript();
}

state_entry()
{
//
}

touch_start(integer total_number)
{
toucher = llDetectedKey(0);
menu(toucher, "\n \nSelect a color category.", main_menu);
}

// use link message instead of touch in case you have more menu in another script.
//link_message(integer sender_num, integer num, string str, key id)
//{
//if (str == "Colors") // from main script
//{
//toucher = id;
//menu(toucher, "\n \nSelect a color category.", main_menu);
//}
//}

timer()
{
llSetTimerEvent(0.0);
llListenRemove(menu_handler);
toucher = NULL_KEY;
}

listen(integer channel, string name, key is, string message)
{
if (channel == menu_channel)
{
llSetTimerEvent(0.0);
llListenRemove(menu_handler);

if (llListFindList(main_menu, [message]) != -1) {
if (message == "grayscale") sub_menu = grayscale;
else if (message == "reds") sub_menu = reds;
else if (message == "pinks") sub_menu = pinks;
else if (message == "violets") sub_menu = violets;
else if (message == "dk_blues") sub_menu = dk_blues;
else if (message == "lt_blues") sub_menu = lt_blues;
else if (message == "yellows") sub_menu = yellows;
else if (message == "dk_greens") sub_menu = dk_greens;
else if (message == "lt_greens") sub_menu = lt_greens;
else if (message == "oranges") sub_menu = oranges;

menu(toucher, "\n \nSelect a color.", llList2ListStrided(sub_menu, 0, -1, 2));
return;
}

integer index = llListFindList(sub_menu, [message]);
if (index != -1)
{
vector color_vector = llList2Vector(sub_menu, index+1);
if (ChangeAllPrims == TRUE)
{
llSetLinkColor(LINK_SET, color_vector, ALL_SIDES); //all prims
}
else
{
llSetColor(color_vector, ALL_SIDES); //only prim script is in
}
}
}
}
}

Link to comment
Share on other sites


AnnieBumbleclaw wrote:

I am certain I want to present my chosen colors between 20-50. I do realize it does involve submenus so I did some digging on some scripts and the closest I came to what I want is using the script I will be posting. The only thing is tha if I link all of them, it colors everything when I only want two specified prims colored. Any ideas on how to adjust this script so that it colors only two prims? 

That code has already been given to you. If you're not taking the time to see what is being offered and study why it works they way it does, you have no interest in writing code of your own.

 

And, frankly, I have no interest in writing it for you.

Link to comment
Share on other sites

I have been spending days reading and working on this script. I can build like nothing but scripting has always been an issue for me. Thank you for all of your help. If anyone can "kindly" point me in the direction so that I can take some classes to learn how to write code without asking for help, please feel free to share. Any classes or tutorials that anyone found useful to learn as a beginner in code? 

 

And LepreKhaun thank you for all of your help. My apologies if you feel I am not trying to figure this out on my own and to get you to write my code for me. It would most definitely help but I wouldn't learn much so if you can share some classes that would greatly help.

 

Thank you all so much for your time! 

Link to comment
Share on other sites

I apologize for the tone I used.

 

It's alright to admit you need help with a script. I can't draw worth a squat but I still need things textured at times. Just understand, please, that this was really the wrong forum for your request. This one is meant for scripters to discuss their scripts and scripting problems within, nothing more, nothing less. Looking for someone to write or rework a script for you is best done in the Wanted or InWorld Employment forums from now on. OK?

 

With that said, if you truly want to learn scripting, I can recommend both the NCI Scripters and the Builders Brewery groups. Both of them regularly offer beginner through advanced scripting classes. And they both have a good number of individuals willing to help a novice get started. In the meantime, you can simply begin by going to any number of scripting depositories where you can download working scripts and study them to see how they do what they do. Each and everything you come across that you can't figure out, Google it. In other words, if you come across a "llListen" and you have no idea what it's about, put that word into Google and its wiki page will come up, read it and reread it until it makes sense. If a term on that page is unknown to you, it will most likely have a link to an explanation of it. Follow those links, deep as you have to, until it does make sense. Or, let it go for awhile and come back later, after you've learned some more about something else. Sooner or later it'll all come together for you.

 

And maybe it won't. Some of us simply aren't meant to be scripters, their talents lay elsewhere. And LSL is (most definitely!) not the easiest first language to learn programming in. That's fine too. We all can't be great texture artists either. So, you can do as I do, find a good texture artist  when I need one and trade what I am capable of offering. And, if you join those two groups I recommended, you'll find plenty of good scripters willing to trade.

  • Like 2
Link to comment
Share on other sites

Thank you so much LepreKhaun for all of the advice. I will definitely seek out those groups and take some classes. I am sure I will eventually figure this thing out. Sorry for posting in the wrong area! :) Thank you all so much. This was my first time ever posting in a forum for Second Life. I am sure I will be back. 

Link to comment
Share on other sites

I remember this script from when I started learning to script, and I remember thinking at the time there should be a more elegant approach t than ploughing through a load of "if... else if... else if ..." clauses.

Following a tip from Void here, way back when, here's a neater way to do it.   I've only bothered with the first few colour groups.

 

integer dialogChan;integer handle;list main_menu = ["grayscale", "reds", "pinks", "violets"];//, "dk_blues", "lt_blues", "yellows", "dk_greens", "lt_greens", "oranges"];list colours =[	"grayscale",6,//name of colour group, number of colours in that group	"black",<0,0,0>,"white",<1,1,1>,"gray",<0.5,0.5,0.5>,"silver",<0.75,0.75,0.75>,"darkgray",<0.4,0.4,0.4>,"lightgrey",<0.83,0.83,0.83>,	"reds",5,//name of colour group, number of colours in that group	"red",<1,0,0>,"darkred",<0.55,0,0>,"crimson",<0.86,0.08,0.24>,"indianred",<0.8,0.36,0.36>,"orangered",<1,0.27,0>,	"pinks",7,//name of colour group, number of colours in that group	"hotpink",<1,0.41,0.71>,"pink", <1,0.75,0.8>,"lightpink",<1,0.71,0.76>,"deeppink",<1,0.08,0.58>,"fuchsia",<1,0,1>,"orchid",<0.85,0.44,0.84>,"plum",<0.87,0.63,0.87>,	"violets",8,//name of colour group, number of colours in that group	"violet",<0.8,0.51,0.8>,"indigo",<0.29,0,0.51>,"lavender",<0.7,0.7,1>,"magenta",<1,0,1>,"purple",<0.5,0,0.5>,"darkmagenta",<0.55,0,0.55>,"darkviolet",<0.58,0,0.83>,"blueviolet",<0.54,0.17,0.89>		//and so on		];list sub_menu;default{	state_entry()	{		dialogChan = (integer)llFrand(100000.0)+1000;//generate a random channel for the dialogs	}	touch_start(integer total_number)	{		llListenRemove(handle);//close any open listener		key k = llDetectedKey(0);//get uuid of avatar who just touched me		handle = llListen(dialogChan,"",k,"");//start listening to messages from that avatar		llDialog(k,"Please choose a colour group",main_menu,dialogChan);//present a menu giving the main colour groups		llSetTimerEvent(30.0);	}	listen(integer channel, string name, key id, string message)	{		integer n;		if (~llListFindList(main_menu,[message])){//is the message an entry in the main_menu list?			n = llListFindList(colours,[message]);//find the corresponding entry in the colours list			integer NumOfEntries = llList2Integer(colours,n+1);//find the number following the entry			NumOfEntries*=2;//double it, because each colour comprises 2 elements, name and colour value			integer Start = n+1; //start with second entry after name of colour group + number of entries -- i.e. name of first colour in the group			integer Finish = Start + NumOfEntries;//index of final colour value in the gorup			list temp = llList2List(colours,Start+1,Finish);//get colur names and values for the colour group			sub_menu = llList2ListStrided(temp,0,-1,2);//pull out the colour names			llDialog(id,"Please Choose a colour",sub_menu,dialogChan);//use them to build the sub menu		}		else if (~llListFindList(sub_menu,[message])){			n = llListFindList(colours,[message]);			vector colour = llList2Vector(colours, n+1);			//do colour changing stuff here			llSetColor(colour,ALL_SIDES);			llSetTimerEvent(30.0);			llDialog(id,"Please choose a colour group",main_menu,dialogChan);//present a menu giving the main colour groups		}	}	timer()	{//shut down listener if no reply after 30 seconds		llListenRemove(handle);		llSetTimerEvent(0.0);	}}

 

Link to comment
Share on other sites

Glad you like it.   I realised later that, so long as the colours in the main menu list are in the same order as they are in the colours list, you don't even need to count them -- the script can find the appropriate entries for the submenus.

So, rather to my surprise, I ended up with this:

integer dialogChan;integer handle;list main_menu = ["grayscale", "reds", "pinks", "violets", "dk_blues", "lt_blues", "yellows", "dk_greens", "lt_greens", "oranges"];list colours =[	"grayscale",	"black",<0,0,0>,"white",<1,1,1>,"gray",<0.5,0.5,0.5>,"silver",<0.75,0.75,0.75>,"darkgray",<0.4,0.4,0.4>,"lightgrey",<0.83,0.83,0.83>,	"reds",	"red",<1,0,0>,"darkred",<0.55,0,0>,"crimson",<0.86,0.08,0.24>,"indianred",<0.8,0.36,0.36>,"orangered",<1,0.27,0>,	"pinks",	"hotpink",<1,0.41,0.71>,"pink", <1,0.75,0.8>,"lightpink",<1,0.71,0.76>,"deeppink",<1,0.08,0.58>,"fuchsia",<1,0,1>,"orchid",<0.85,0.44,0.84>,"plum",<0.87,0.63,0.87>,	"violets",	"violet",<0.8,0.51,0.8>,"indigo",<0.29,0,0.51>,"lavender",<0.7,0.7,1>,"magenta",<1,0,1>,"purple",<0.5,0,0.5>,"darkmagenta",<0.55,0,0.55>,"darkviolet",<0.58,0,0.83>,"blueviolet",<0.54,0.17,0.89>,	"dk_blues",	"darkblue",<0,0,0.55>,"blue",<0,0,1>,"deepskyblue",<0,0.75,1>,"mediumblue",<0,0,0.8>,"midnightblue",<0.1,0.1,0.44>,"royalblue",<0.25,0.41,0.88>,"slateblue",<0.42,0.35,0.8>,"steelblue",<0.27,0.51,0.71>,	"lt_blues",	"teal",<0,0.5,0.5>,"turquoise",<0.25,0.88,0.82>,"darkcyan",<0,0.55,0.55>, "lightblue", <0.68,0.85,0.9>,"aquamarine",<0.5,1,0.83>,"azure",<0.8,1,1>,"cyan",<0,1,0.9>,"skyblue",<0.53,0.81,0.92>,	"yellows",	"yellow",<1,1,0>,"gold",<1,0.84,0>,"lightyellow",<1,1,0.88>,"goldenrod",<0.85,0.65,0.13>,"yellowgreen",<0.6,0.8,0.2>,	"dk_greens",	"darkgreen",<0,0.39,0>,"green",<0,0.5,0>,"forestgreen",<0.13,0.55,0.13>,"lawngreen",<0.49,0.99,0>,"springgreen",<0,1,0.5>,	"lt_greens",	"lightgreen",<0.56,0.93,0.56>,"chartreuse",<0.5,1,0>,"greenyellow",<0.68,1,0.18>,"honeydew",<0.94,1,0.94>,"limegreen",<0.2,0.8,0.2>,"mintcream",<0.96,1,0.98>,"seagreen",<0.18,0.55,0.34>,	"oranges",	"orange",<1,0.65,0>,"darkorange",<1,0.55,0>,"coral",<1,0.5,0.31>,"navajowhite",<1,0.87,0.68>,"salmon",<0.98,0.5,0.45>,"seashell",<1,0.96,0.93>,"brown",<.24,.17,.15>		];list sub_menu;default{	state_entry()	{		dialogChan = (integer)llFrand(100000.0)+1000;//generate a random channel for the dialogs	}	touch_start(integer total_number)	{		llListenRemove(handle);//close any open listener		key k = llDetectedKey(0);//get uuid of avatar who just touched me		handle = llListen(dialogChan,"",k,"");//start listening to messages from that avatar		llDialog(k,"Please choose a colour group",main_menu,dialogChan);//present a menu giving the main colour groups		llSetTimerEvent(30.0);	}	listen(integer channel, string name, key id, string message)	{		integer n = llListFindList(main_menu,[message]);		if(~n){			string next = llList2String(main_menu,n+1);			//list temp;			integer start = llListFindList(colours,[message]);			integer finish = llListFindList(colours,[next]);			if(~finish){//if the string is not the last colour group (orange, in this case)				--finish;			}			sub_menu = llList2ListStrided(llList2List(colours,++start,finish),0,-1,2);			llDialog(id,"Please Choose a colour",sub_menu,dialogChan);//use them to build the sub menu		}		else if (~llListFindList(sub_menu,[message])){			n = llListFindList(colours,[message]);			vector colour = llList2Vector(colours, n+1);			//do colour changing stuff here			llSetColor(colour,ALL_SIDES);			llSetTimerEvent(30.0);			llDialog(id,"Please choose a colour group",main_menu,dialogChan);//present a menu giving the main colour groups		}	}	timer()	{//shut down listener if no reply after 30 seconds		llListenRemove(handle);		llSetTimerEvent(0.0);	}}

 

Link to comment
Share on other sites

Very well done. Except you have introduced an infinite loop of llDialogs and the OP still has to change just the prims she wishes (the code you had previously given in posting #6). So:

[Edited to include the on_rez event, which is necessaary.]

[Re-Edited to remove the on_rez event, which I see serves no purpose after all. Linkage can't change in inventory.]

 

integer dialogChan;integer handle;list main_menu = ["grayscale", "reds", "pinks", "violets", "dk_blues", "lt_blues", "yellows", "dk_greens", "lt_greens", "oranges"];list colours =[	"grayscale",	"black",<0,0,0>,"white",<1,1,1>,"gray",<0.5,0.5,0.5>,"silver",<0.75,0.75,0.75>,"darkgray",<0.4,0.4,0.4>,"lightgrey",<0.83,0.83,0.83>,	"reds",	"red",<1,0,0>,"darkred",<0.55,0,0>,"crimson",<0.86,0.08,0.24>,"indianred",<0.8,0.36,0.36>,"orangered",<1,0.27,0>,	"pinks",	"hotpink",<1,0.41,0.71>,"pink", <1,0.75,0.8>,"lightpink",<1,0.71,0.76>,"deeppink",<1,0.08,0.58>,"fuchsia",<1,0,1>,"orchid",<0.85,0.44,0.84>,"plum",<0.87,0.63,0.87>,	"violets",	"violet",<0.8,0.51,0.8>,"indigo",<0.29,0,0.51>,"lavender",<0.7,0.7,1>,"magenta",<1,0,1>,"purple",<0.5,0,0.5>,"darkmagenta",<0.55,0,0.55>,"darkviolet",<0.58,0,0.83>,"blueviolet",<0.54,0.17,0.89>,	"dk_blues",	"darkblue",<0,0,0.55>,"blue",<0,0,1>,"deepskyblue",<0,0.75,1>,"mediumblue",<0,0,0.8>,"midnightblue",<0.1,0.1,0.44>,"royalblue",<0.25,0.41,0.88>,"slateblue",<0.42,0.35,0.8>,"steelblue",<0.27,0.51,0.71>,	"lt_blues",	"teal",<0,0.5,0.5>,"turquoise",<0.25,0.88,0.82>,"darkcyan",<0,0.55,0.55>, "lightblue", <0.68,0.85,0.9>,"aquamarine",<0.5,1,0.83>,"azure",<0.8,1,1>,"cyan",<0,1,0.9>,"skyblue",<0.53,0.81,0.92>,	"yellows",	"yellow",<1,1,0>,"gold",<1,0.84,0>,"lightyellow",<1,1,0.88>,"goldenrod",<0.85,0.65,0.13>,"yellowgreen",<0.6,0.8,0.2>,	"dk_greens",	"darkgreen",<0,0.39,0>,"green",<0,0.5,0>,"forestgreen",<0.13,0.55,0.13>,"lawngreen",<0.49,0.99,0>,"springgreen",<0,1,0.5>,	"lt_greens",	"lightgreen",<0.56,0.93,0.56>,"chartreuse",<0.5,1,0>,"greenyellow",<0.68,1,0.18>,"honeydew",<0.94,1,0.94>,"limegreen",<0.2,0.8,0.2>,"mintcream",<0.96,1,0.98>,"seagreen",<0.18,0.55,0.34>,	"oranges",	"orange",<1,0.65,0>,"darkorange",<1,0.55,0>,"coral",<1,0.5,0.31>,"navajowhite",<1,0.87,0.68>,"salmon",<0.98,0.5,0.45>,"seashell",<1,0.96,0.93>,"brown",<.24,.17,.15>		];list sub_menu;list bulbs;list find_prims(string which){    which = llToLower(llStringTrim(which,STRING_TRIM));    list prims;    integer max = llGetNumberOfPrims();    integer i;    if (max>1){//if it's part of a linkset        i=1;    }    do {        if(which ==llToLower(llStringTrim(llGetLinkName(i),STRING_TRIM))){            prims+=[i];        }    }    while (++i<=max);    return prims;}default{	state_entry()	{		dialogChan = (integer)llFrand(100000.0)+1000;//generate a random channel for the dialogs        bulbs = find_prims("bulb");    }    changed(integer change)    {        if(change & CHANGED_LINK){            find_prims("bulb");        }    }	touch_start(integer total_number)	{		llListenRemove(handle);//close any open listener		key k = llDetectedKey(0);//get uuid of avatar who just touched me		handle = llListen(dialogChan,"",k,"");//start listening to messages from that avatar		llDialog(k,"Please choose a colour group",main_menu,dialogChan);//present a menu giving the main colour groups		llSetTimerEvent(30.0);	}	listen(integer channel, string name, key id, string message)	{		integer n = llListFindList(main_menu,[message]);		if(~n){			string next = llList2String(main_menu,n+1);			//list temp;			integer start = llListFindList(colours,[message]);			integer finish = llListFindList(colours,[next]);			if(~finish){//if the string is not the last colour group (orange, in this case)				--finish;			}			sub_menu = llList2ListStrided(llList2List(colours,++start,finish),0,-1,2);			llDialog(id,"Please Choose a colour",sub_menu,dialogChan);//use them to build the sub menu		} else if (~llListFindList(sub_menu,[message])){			n = llListFindList(colours,[message]);			vector colour = llList2Vector(colours, n+1);			//do colour changing stuff here        list params;        integer max = -llGetListLength(bulbs);        do{            params+=[PRIM_LINK_TARGET,llList2Integer(bulbs,max),PRIM_COLOR,ALL_SIDES,colour,1.0];        }        while(++max);        llSetLinkPrimitiveParamsFast(LINK_SET,params);        params=[];//		llSetTimerEvent(30.0);//		llDialog(id,"Please choose a colour group",main_menu,dialogChan);//present a menu giving the main colour groups		}	}	timer()	{//shut down listener if no reply after 30 seconds		llListenRemove(handle);		llSetTimerEvent(0.0);	}}

 

 

Link to comment
Share on other sites

Yeah,  I was not, in fact, attempting to give the OP the full code, since between us we have -- as you correctly noted earlier -- given her all of it in bits and pieces.  I thought that if she was still interested in trying to learn how to write code she might find it rewarding to try putting it all together.   

Link to comment
Share on other sites

I realize that. But when I saw a flaw in the user interface that needed correcting and having contributed little more to this thread than a few (obvious) suggestions and an uncalled for rant, I figured the reader might benefit from seeing how all our efforts would work together. And seeing the OP is now a participant in the Builders Brewery, I had no qualms.

Link to comment
Share on other sites

Depends what your customers consider a flaw in the UI, I guess.   Certainly in my experience people are a lot more likely to complain if a texture/colour changer doesn't remenu than if it does.  

in a completed script I''d keep remenuing, I think, and include a button to dismiss the menu (in addition to "ignore", of course).

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4075 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...