Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Seperating my scripts

Cunundrum Alcott
A Sardonic Pessimist
Join date: 15 Jan 2007
Posts: 773
02-22-2008 16:40
I don't understand what I change here so that each script is changing by intself and not items next to i

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


init() {
llListenRemove(listen_handle);
owner = llGetOwner();
//channel = llFloor(llFrand(2000000)); //random channel so multiple scripts don't interfere with each other
listen_handle = llListen(9000, "", owner, "";);
}


default
{
on_rez(integer s) { init(); }
state_entry() { init(); }

listen(integer channel, string name, key id, string message) {

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;

//llDialog(owner, "\n\nSelect a color", llList2ListStrided(sub_menu, 0, -1, 2), 9000);
return;
}

integer index = llListFindList(sub_menu, [message]);
if (index != -1) {
vector color_vector = llList2Vector(sub_menu, index+1);
//if (llGetLinkNumber() == 1) llSetLinkColor(LINK_SET, color_vector, ALL_SIDES); //If it's root prim, do whole set
if (llSetColor(color_vector, ALL_SIDES));
if (llSetPrimitiveParams ([PRIM_POINT_LIGHT, TRUE, color_vector, 1.0, 15.0, 0.75]));

}

}

touch_start(integer s) {
if (llDetectedKey(0) == owner) {
llDialog(owner, "\n\nSelect a color group", main_menu, 9000);
}
}
}
_____________________
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
02-22-2008 17:44
Your script is hard-coded to use channel 9000, so, when the llDialog executes it will relay its message to all scripts listening on that same channel.

However, this line (which is commented out): //channel = llFloor(llFrand(2000000)); //random channel so multiple scripts don't interfere with each other

...is designed to combat that very effect.

So, reinstate that line of code, declare a global variable: integer channel; and then use 'channel' in place of '9000'.