140 Farben

Ein einfaches Menü zur Darstellung von 140 Farben, die ich aus einem Freebie-Skript hab. Der Farbvektor wird auch mit angezeigt.

// script copyright by Rebekka Revnik

list colors;
list codes;
string s;
integer i;

string NEXT = ">>>";						// Schaltflächen für vor und zurück
string PREV = "<<<";

string DLGTITLE = "Wähle bitte eine Farbe";	// Dialog-Text
integer DLGCHANNEL = 100;					// Chatkanal
list DlgItems = [];							// die Schaltflächen des Dialogs
integer DlgPage = 0;

list C1 = [
"aliceblue","antiquewhite","aqua","aquamarine",
"azure","beige","bisque","black",
"blanchedalmond","blue","blueviolet","brown",
"burlywood","cadetblue","chartreuse","chocolate",
"coral","cornflowerblue","cornsilk","crimson",
"cyan","darkblue","darkcyan","darkgoldenrod",
"darkgray","darkgreen","darkkhaki","darkmagenta",
"darkolivegreen","darkorange","darkorchid","darkred",
"darksalmon","darkseagreen","darkslateblue","darkslategray",
"darkturquoise","darkviolet","deeppink","deepskyblue",
"dimgray","dodgerblue","firebrick","floralwhite",
"forestgreen","fuchsia","gainsboro","ghostwhite"];
list C2 = [
"gold","goldenrod","gray","green",
"greenyellow","honeydew","hotpink","indianred",
"indigo","ivory","khaki","lavender",
"lavenderblush","lawngreen","lemonchiffon","lightblue",
"lightcoral","lightcyan","lightgoldenrodyellow","lightgreen",
"lightgrey","lightpink","lightsalmon","lightseagreen",
"lightskyblue","lightslategray","lightsteelblue","lightyellow",
"lime","limegreen","linen","magenta",
"maroon","mediumauqamarine","mediumblue","mediumorchid",
"mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen",
"mediumturquoise","mediumvioletred","midnightblue","mintcream",
"mistyrose","moccasin","navajowhite","navy"];
list C3 = [
"oldlace","olive","olivedrab","orange",
"orangered","orchid","palegoldenrod","palegreen",
"paleturquoise","palevioletred","papayawhip","peachpuff",
"peru","pink","plum","powderblue",
"purple","red","rosybrown","royalblue",
"saddlebrown","salmon","sandybrown","seagreen",
"seashell","sienna","silver","skyblue",
"slateblue","slategray","snow","springgreen",
"steelblue","tan","teal","thistle",
"tomato","turquoise","violet","wheat",
"white","whitesmoke","yellow","yellowgreen"];
list D1 = [
<0.941176, 0.972549, 1.000000>,<0.980392, 0.921569, 0.843137>,<0.000000, 1.000000, 1.000000>,<0.498039, 1.000000, 0.831373>,
<0.941176, 1.000000, 1.000000>,<0.960784, 0.960784, 0.862745>,<1.000000, 0.894118, 0.768627>,<0.000000, 0.000000, 0.000000>,
<1.000000, 0.921569, 0.803922>,<0.000000, 0.000000, 1.000000>,<0.541176, 0.168627, 0.886275>,<0.647059, 0.164706, 0.164706>,
<0.870588, 0.721569, 0.529412>,<0.372549, 0.619608, 0.627451>,<0.498039, 1.000000, 0.000000>,<0.823529, 0.411765, 0.117647>,
<1.000000, 0.498039, 0.313726>,<0.392157, 0.584314, 0.929412>,<1.000000, 0.972549, 0.862745>,<0.862745, 0.078431, 0.235294>,
<0.000000, 1.000000, 1.000000>,<0.000000, 0.000000, 0.545098>,<0.000000, 0.545098, 0.545098>,<0.721569, 0.525490, 0.043137>,
<0.662745, 0.662745, 0.662745>,<0.000000, 0.392157, 0.000000>,<0.741176, 0.717647, 0.419608>,<0.545098, 0.000000, 0.545098>,
<0.333333, 0.419608, 0.184314>,<1.000000, 0.549020, 0.000000>,<0.600000, 0.196078, 0.800000>,<0.545098, 0.000000, 0.000000>,
<0.913725, 0.588235, 0.478431>,<0.560784, 0.737255, 0.560784>,<0.282353, 0.239216, 0.545098>,<0.184314, 0.309804, 0.309804>,
<0.000000, 0.807843, 0.819608>,<0.580392, 0.000000, 0.827451>,<1.000000, 0.078431, 0.576471>,<0.000000, 0.749020, 1.000000>,
<0.411765, 0.411765, 0.411765>,<0.117647, 0.564706, 1.000000>,<0.698039, 0.133333, 0.133333>,<1.000000, 0.980392, 0.941176>,
<0.133333, 0.545098, 0.133333>,<1.000000, 0.000000, 1.000000>,<0.862745, 0.862745, 0.862745>,<0.972549, 0.972549, 1.000000>];
list D2 = [
<1.000000, 0.843137, 0.000000>,<0.854902, 0.647059, 0.125490>,<0.501961, 0.501961, 0.501961>,<0.000000, 0.501961, 0.000000>,
<0.678431, 1.000000, 0.184314>,<0.941176, 1.000000, 0.941176>,<1.000000, 0.411765, 0.705882>,<0.803922, 0.360784, 0.360784>,
<0.294118, 0.000000, 0.509804>,<1.000000, 1.000000, 0.941176>,<0.941176, 0.901961, 0.549020>,<0.901961, 0.901961, 0.980392>,
<1.000000, 0.941176, 0.960784>,<0.486275, 0.988235, 0.000000>,<1.000000, 0.980392, 0.803922>,<0.678431, 0.847059, 0.901961>,
<0.941176, 0.501961, 0.501961>,<0.878431, 1.000000, 1.000000>,<0.980392, 0.980392, 0.823529>,<0.564706, 0.933333, 0.564706>,
<0.827451, 0.827451, 0.827451>,<1.000000, 0.713726, 0.756863>,<1.000000, 0.627451, 0.478431>,<0.125490, 0.698039, 0.666667>,
<0.529412, 0.807843, 0.980392>,<0.466667, 0.533333, 0.600000>,<0.690196, 0.768627, 0.870588>,<1.000000, 1.000000, 0.878431>,
<0.000000, 1.000000, 0.000000>,<0.196078, 0.803922, 0.196078>,<0.980392, 0.941176, 0.901961>,<1.000000, 0.000000, 1.000000>,
<0.501961, 0.000000, 0.000000>,<0.400000, 0.803922, 0.666667>,<0.000000, 0.000000, 0.803922>,<0.729412, 0.333333, 0.827451>,
<0.576471, 0.439216, 0.847059>,<0.235294, 0.701961, 0.443137>,<0.482353, 0.407843, 0.933333>,<0.000000, 0.980392, 0.603922>,
<0.282353, 0.819608, 0.800000>,<0.780392, 0.082353, 0.521569>,<0.098039, 0.098039, 0.439216>,<0.960784, 1.000000, 0.980392>,
<1.000000, 0.894118, 0.882353>,<1.000000, 0.894118, 0.709804>,<1.000000, 0.870588, 0.678431>,<0.000000, 0.000000, 0.501961>];
list D3 = [
<0.992157, 0.960784, 0.901961>,<0.501961, 0.501961, 0.000000>,<0.407843, 0.556863, 0.137255>,<1.000000, 0.647059, 0.000000>,
<1.000000, 0.270588, 0.000000>,<0.854902, 0.439216, 0.839216>,<0.933333, 0.909804, 0.666667>,<0.596078, 0.984314, 0.596078>,
<0.686275, 0.933333, 0.933333>,<0.847059, 0.439216, 0.576471>,<1.000000, 0.937255, 0.835294>,<1.000000, 0.854902, 0.725490>,
<0.803922, 0.521569, 0.247059>,<1.000000, 0.752941, 0.796078>,<0.866667, 0.627451, 0.866667>,<0.690196, 0.878431, 0.901961>,
<0.501961, 0.000000, 0.501961>,<1.000000, 0.000000, 0.000000>,<0.737255, 0.560784, 0.560784>,<0.254902, 0.411765, 0.882353>,
<0.545098, 0.270588, 0.074510>,<0.980392, 0.501961, 0.447059>,<0.956863, 0.643137, 0.376471>,<0.180392, 0.545098, 0.341176>,
<1.000000, 0.960784, 0.933333>,<0.627451, 0.321569, 0.176471>,<0.752941, 0.752941, 0.752941>,<0.529412, 0.807843, 0.921569>,
<0.415686, 0.352941, 0.803922>,<0.439216, 0.501961, 0.564706>,<1.000000, 0.980392, 0.980392>,<0.000000, 1.000000, 0.498039>,
<0.274510, 0.509804, 0.705882>,<0.823529, 0.705882, 0.549020>,<0.000000, 0.501961, 0.501961>,<0.847059, 0.749020, 0.847059>,
<1.000000, 0.388235, 0.278431>,<0.250980, 0.878431, 0.815686>,<0.933333, 0.509804, 0.933333>,<0.960784, 0.870588, 0.701961>,
<1.000000, 1.000000, 1.000000>,<0.960784, 0.960784, 0.960784>,<1.000000, 1.000000, 0.000000>,<0.603922, 0.803922, 0.196078>];

list DlgNice(list Dlg)						// "schöneres" Aussehen
{
	list l = [];
	integer len = llGetListLength(Dlg);
	integer i;
	
	for(i = 0; i< 3; i++) if(i + 9 < len) l += llList2List(Dlg, i + 9, i + 9); else l += [" "];
	for(i = 3; i< 6; i++) if(i + 3 < len) l += llList2List(Dlg, i + 3, i + 3); else l += [" "];
	for(i = 6; i< 9; i++) if(i - 3 < len) l += llList2List(Dlg, i - 3, i - 3); else l += [" "];
	for(i = 9; i< 12; i++) if(i - 9 < len) l += llList2List(Dlg, i - 9, i - 9); else l += [" "];
	return l;
}

DlgShow(string msg, integer channel)		// die eigentliche Dialogprozedur
{
	list Dlg = [];
	integer Count = llGetListLength(DlgItems);
	integer Start = (DlgPage - 1) * 10 + 11;
	if(DlgPage == 0)
	{
		if(Count < 13) Dlg = DlgItems;
		else Dlg = llList2List(DlgItems, 0, 1) + [NEXT] + llList2List(DlgItems, 2, 10);
	} else
	{
		if(Count < Start + 12) Dlg = [PREV] + llList2List(DlgItems, Start, Start + 11);
		else Dlg = [PREV] + llList2List(DlgItems, Start, Start) + [NEXT] + llList2List(DlgItems, Start + 1, Start + 9);
	}
	//llDialog(llGetOwner(), msg, Dlg, channel);
	llDialog(llGetOwner(), msg, DlgNice(Dlg), channel);
}

default
{
	state_entry()
	{
		colors = C1+C2+C3;
		codes = D1+D2+D3;
		DlgItems = colors;
	}
	touch_start(integer total_number)
	{
		llListen(DLGCHANNEL, "", llGetOwner(), "");
		DlgShow(DLGTITLE, DLGCHANNEL);
	}
	listen(integer channel, string name, key id, string message)
	{
		if(message == PREV)
		{
			DlgPage--;
			DlgShow(DLGTITLE, DLGCHANNEL);
			return;
		} else if(message == NEXT)
		{
			DlgPage++;
			DlgShow(DLGTITLE, DLGCHANNEL);
			return;
		} else if(message == " ")
		{
			DlgShow(DLGTITLE, DLGCHANNEL);
			return;
		} else
		{
			i = llListFindList(colors, [message]);
			s = llList2String(codes, i);
			llOwnerSay(message + ": " + llList2String(codes, i));
			llSetText(message + "\n" + llList2String(codes, i),<1,1,1>,1);
			llSetColor(llList2Vector(codes,i),ALL_SIDES);
			DlgShow(DLGTITLE, DLGCHANNEL);
		}
	}
}