Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Color changing script question

Jennifer McLuhan
Smiles and Hugs are Free
Join date: 22 Aug 2005
Posts: 441
11-11-2005 15:46
I am trying to put a color changing script in some prim shoes, I made. I was given the script below. However, I know nothing of scripting. I placed it in a rezzed box and tried the usual, “/color black & /1 color black” commands with no success.

Can someone tell me how to make this script work?

Thanks,
Jen

vector c;
default
{
state_entry()
{
llListen(0,"","","colors";);
llListen(0,"","","stop";);
c=llGetColor(0);
}
listen (integer channel, string name, key id, string message)
{
if (message == "colors";)
{
float random = llFrand(1.9)+.5;
llSetTimerEvent(random);
}
if (message == "stop";)
{
llSetTimerEvent(0.0);
llSetColor(c,-1);
}

}
timer()
{
float x = llFrand(1.0);
float y = llFrand(1.0);
float z = llFrand(1.0);
llSetColor(<x,y,z>,-1);
}

}
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
11-11-2005 15:51
With that script if anyone says "colors" in regular chat, it begins to change the color of the prim at random, with a random interval between two and two and a half seconds. Anyone saying "stop" on the regular chat channel will cause it to revert to its original color.
_____________________
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
11-12-2005 10:01
I believe with the way the llSetColor command works, the x,y,z value in there represents the Red,Green,Blue values from 0 to 1, where <1,1,1> is white, <0,0,0> is black, <1,0,0> is red, etc. you'd need to add in a listen command that goes something like this to the script. also you need a ALL_SIDES in there, as right now it is only effecting one side of the prim the shoes are made out of. will update with a full working script for you soon.

***Disclaimer*** I'm not an experienced programmer/scripter by any means so this is probably very sloppy my most people's standards:

CODE

COMPLETE SCRIPT POSTED BELOW



I may mess around with this script some more and post a "complete" version of it later since it's teaching me a bit about the listen command
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
11-12-2005 10:21
If you want a more custom and/or elaborate script, message me in game and I'll see what I can do

CODE

default
{
state_entry()
{
// listen on channel zero for any chat spoken by the object owner. you can change the 0 to whatever channel you wish the person to use. if you set it to 1 the owner will have to say /1 red to change the color to red for example, and it would keep the general chat area spam free.
llListen(0,"",llGetOwner(),"");
}

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

if (llToLower(message) == "red")
{
llSetColor(<1,0,0>,ALL_SIDES);//the ALL_SIDES is where you set what sides you want the color change applied. usually I use ALL_SIDES, but if you start using multi-colored themes, you can take advantage of appling different shades to different sides (designated numerically you would have to play around with the numbers based on the shape of the prim), you can also use a llSetTexture command in a similar manner to change the texture of the shoes on command as well
}
if (llToLower(message) == "black")
{
llSetColor(<0,0,0>,ALL_SIDES);
}
if (llToLower(message) == "white")
{
llSetColor(<1,1,1>,ALL_SIDES);
}
if (llToLower(message) == "green")
{
llSetColor(<0,1,0>,ALL_SIDES);
}
if (llToLower(message) == "blue")
{
llSetColor(<0,0,1>,ALL_SIDES);
}
if (llToLower(message) == "purple")
{
llSetColor(<1,0,1>,ALL_SIDES);
}
if (llToLower(message) == "orange")
{
llSetColor(<1,.6,.5>,ALL_SIDES);
}

if (llToLower(message) == "concrete")
{
llSetTexture("Concrete",ALL_SIDES); //include any texture named Concrete in the prim with this script (that is, drag it into the contents), and when the owner says concrete in chat they can go swim with the fishes. :)
}
}
}
DianaJones Dawn
Registered User
Join date: 19 Dec 2003
Posts: 20
Color change script
11-13-2005 05:11
Jennifer - I have an open source color changing script that is freely available with my color change skirt. It *will* change the color of all linked objects.

Will send you a copy if you like, or find it via my freebies in SLX or SLB.

Also a $1L more or less freebie at The House of The Twisted Prim, upstairs.

-DianaJones Dawn
_____________________
DianaJones Dawn from the House of the Twisted Prim
My page of designs available at SLBoutique
Gaz Hornpipe
Registered User
Join date: 29 Sep 2005
Posts: 36
11-14-2005 11:20
Just a little tidying up here. Just call llToLower() once, also if you are not going to use ELSE statements to separate your IF's, you should use some sort of BREAK, such as a return statement after you process the command (message). No point for the script to check the remaining IF statements if it has already found a match. Also.. since you are using a llListen() call in the state_entry() event, you will need to reset the script when it rezzes, in case the original owner changes.. or alternatively, you could check to see if the owner has changed and then reset the script if the data in any variables was important.

CODE

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

state_entry()
{
llListen(0,"",llGetOwner(),"");
}

listen(integer channel, string name, key id, string message)
{
message = llToLower(message);
if (message == "red")
{
llSetColor(<1,0,0>,ALL_SIDES);
return;
}

if (message == "black")
{
llSetColor(<0,0,0>,ALL_SIDES);
return;
}
if (message == "concrete")
{
llSetTexture("Concrete",ALL_SIDES);
return;
}
}
}
Jennifer McLuhan
Smiles and Hugs are Free
Join date: 22 Aug 2005
Posts: 441
11-15-2005 14:40
I would just like to say thank you to everyone who posted here and in-game to help me.

((Hugs))

Jen