Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Change script so that anyone can change the color not just owner

Satai Diaz
Humble Bounty Hunter
Join date: 9 Aug 2003
Posts: 133
07-13-2005 00:10
Hey guys, I've been tinkering with this script so it allows anyone to change the color and not just the owner. I'm an amateur scripter and can only modify scripts and not create so the answer eludes me. I was thinking of just getting rid of the llGetOwner tags but I came up with errors.

Can you all think of anything?

CODE

// Global variables

integer g_listener = FALSE; // Listen Handler
integer randomChannel = 0; // Our random channel
integer place = 0; // Place in the Script
integer exit = FALSE; // Exit param
vector color = <1,1,1>; // Global color param

list colors = ["Orange","Purple","Lime","Pink","Teal","Gray","Blue","Red","Green","White","Yellow","Custom"];

list custom = ["0.8","0.9","1.0","0.5","0.6","0.7","0.2","0.3","0.4","0.0","0.1"];


default
{
touch_start(integer total_number)
{
if(llDetectedKey(0) == llGetOwner())
{
// Refresh the goods
place = 0;
llListenRemove(g_listener);

// Add a random channel
randomChannel = 10 + (integer)llFrand(100000);
g_listener = llListen(randomChannel,"",llGetOwner(),"");

// Fire up the expiration timer
llSetTimerEvent(720.0);

// Fire up the dialog
llDialog(llGetOwner(),"Select a Color Theme:",colors,randomChannel);
}
}
listen(integer chan, string name, key id, string msg)
{
// When we receive a dialog response...
if(chan == randomChannel) // Redundant, unless you want more chans
{
// This depth is reserved for Configuration Options
if(place == 0)
{
llSetTimerEvent(720.0);
++place;

integer test = llListFindList(colors,(list)msg);
if(test != -1)
{
// If we select "Orange"
if(test == 0)
{
color = <1,0.6,0>;
}

// If we select "Purple"
else if(test == 1)
{
color = <0.6,0,1>;
}

// If we select "Lime"
else if(test == 2)
{
color = <0.6,1,0>;
}

// If we select "Pink"
else if(test == 3)
{
color = <1,0,0.6>;
}

// If we select "Teal"
else if(test == 4)
{
color = <0,1,1>;
}

// If we select "Gray"
else if(test == 5)
{
color = <0.5,0.5,0.5>;
}

// If we select "Blue"
else if(test == 6)
{
color = <0.3,0.3,1>;
}

// If we select "Red"
else if(test == 7)
{
color = <1,0.3,0.3>;
}

// If we select "Green"
else if(test == 8)
{
color = <0.3,1,0.3>;
}

// If we select "White"
else if(test == 9)
{
color = <1,1,1>;
}

// If we select "Yellow"
else if(test == 10)
{
color = <1,1,0>;
}

// If we select "Custom"
else if(test == 11)
{
llDialog(llGetOwner(),"Custom Color Mode Selected! Choose a value for RED (Second Life RGB).",custom,randomChannel);
return;
}

llSetLinkColor(LINK_ALL_CHILDREN,color,ALL_SIDES);

exit = TRUE;
llSetTimerEvent(0.1);
return;
}
else
llSetTimerEvent(0.1);

}
// This depth is reserved for Custom Colors ONLY!
else if(place == 1)
{
llSetTimerEvent(720.0);
++place;

color.x = (float)msg;
llDialog(llGetOwner(),"Choose a value for GREEN (Second Life RGB).",custom,randomChannel);
}
else if(place == 2)
{
llSetTimerEvent(720.0);
++place;

color.y = (float)msg;
llDialog(llGetOwner(),"Choose a value for BLUE (Second Life RGB).",custom,randomChannel);
}
else if(place == 3)
{
llSetTimerEvent(720.0);
++place;

color.z = (float)msg;

llSetLinkColor(LINK_ALL_CHILDREN,color,ALL_SIDES);

exit = TRUE;
llSetTimerEvent(0.1);
return;
}
}
}
timer()
{
llSetTimerEvent(0.0);
if(exit == FALSE) llOwnerSay("Timer Expired. Please try again.");
llListenRemove(g_listener);
}
}
_____________________
Satai Diaz
Owner of SD Designs
DJ for Crystal Blue @ Cafe Hailey
Producer of Digital Paradise Studios & Cinema
Admiral of Kazenojin
Owner of SLRA
Kris Ritter
paradoxical embolism
Join date: 31 Oct 2003
Posts: 6,627
07-13-2005 00:22
You can't just get rid of it, its a required parameter. But you could replace it with a pair of quotes ("";) in the listeners and dialog handlers, which means 'accept anything'.

Oh yeah. And you'll need to remove the line " if(llDetectedKey(0) == llGetOwner()) {" ... and of course a corresponding closing parentheses at the end :)
Satai Diaz
Humble Bounty Hunter
Join date: 9 Aug 2003
Posts: 133
07-13-2005 00:31
Thanks! I have a quesiton tho.

What do I do with this line?

CODE

if(llDetectedKey(0) == llGetOwner())


Just add the "" there too?
_____________________
Satai Diaz
Owner of SD Designs
DJ for Crystal Blue @ Cafe Hailey
Producer of Digital Paradise Studios & Cinema
Admiral of Kazenojin
Owner of SLRA
Kris Ritter
paradoxical embolism
Join date: 31 Oct 2003
Posts: 6,627
07-13-2005 00:42
no. as I said above, remove it completely - its a condition you no longer need to check for. and remember to remove the closing bracket!
_____________________
Velox Severine
Network Slave
Join date: 19 May 2005
Posts: 73
07-13-2005 00:44
Remove that line and its closing brace.
_____________________
--BEGIN SIGNATURE STRING--
IkkgY2FtZSwgSSBzYXcsIEkgY29ucXVlcmVkLiIgLS1KdWxpdXMgQ2Flc2Fy
--END SIGNATURE STRING--
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
07-13-2005 02:10
Just in case that's not quite clear enough the touch_start event should look like this (you can actually take out the commented areas:

CODE

touch_start(integer total_number)
{
// remove this line: if(llDetectedKey(0) == llGetOwner())
// and remove this brace, curly bracket whatever you call it {
// Refresh the goods
place = 0;
llListenRemove(g_listener);

// Add a random channel
randomChannel = 10 + (integer)llFrand(100000);
g_listener = llListen(randomChannel,"","",""); //the llGetOwner() in the listener has gone, but you'd done that.

// Fire up the expiration timer
llSetTimerEvent(720.0);

// Fire up the dialog
llDialog(llGetOwner(),"Select a Color Theme:",colors,randomChannel);
// and you need to get shot of this closing one too }
}


The llOwnerSay() right at the bottom might give you problems too, and llWhisper() might be a better bet, although there are less chat intrusive ways to do it.
Jon Marlin
Builder, Coder, RL & SL
Join date: 10 Mar 2005
Posts: 297
07-13-2005 05:34
Shouldn't the last line read:

CODE
 llDialog(llDetectedKey(0),"Select a Color Theme:",colors,randomChannel);


- Jon
_____________________
Come visit Marlin Engineering at Horseshoe (222, 26) to see my line of flying vehicles.
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
07-13-2005 07:24
Good catch, yes Jon, thanks!