Jump to content

help with a color changing script


Cheaky Heron
 Share

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

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

Recommended Posts

hey all ok i need some help i have a object that cosists of 11 prims i need only 5 of them to to change the same  colour at the same time i have a script that allows me to link parts and have them change color the only problem is is they go through different shades of each colour i only want 1 shade of each color eg from red to yellow to green to blue to purple to orange back to red and repeat them colours can anyone help theis is the script ui have at the moment .......... added...... also i need it to where it will only change the 5 linked pieces because at the moment if i link them 5 pieces to the rest of the object it starts to change tother pieces and not the 5 i want then

// This script cycles through colours

float red = 1;
float green = 1;
float blue = 1;

vector currentColour = <1,1,1>;

float COLOUR_INCREMENT = 0.20;

float TIMER_INT = 0.5;


changeColour()
{
    if (red == 1.0)
    {
        if (blue > 0)
        {
            blue -= COLOUR_INCREMENT;
        }
        else if (green < 1.0)
        {
            green += COLOUR_INCREMENT;
        }
    }
    if (green == 1.0)
    {
        if (red > 0)
        {
            red -= COLOUR_INCREMENT;
        }
        else if (blue < 1.0)
        {
            blue += COLOUR_INCREMENT;
        }
    }
    if (blue == 1.0)
    {
        if (green > 0)
        {
            green -= COLOUR_INCREMENT;
        }
        else if (red < 1.0)
        {
            red += COLOUR_INCREMENT;
        }
    }
    currentColour = <red, green, blue>;
    llSetLinkColor(1,currentColour, ALL_SIDES);
    llSetLinkColor(2,currentColour, ALL_SIDES);
    llSetLinkColor(3,currentColour, ALL_SIDES);
    llSetLinkColor(4,currentColour, ALL_SIDES);
    llSetLinkColor(5,currentColour, ALL_SIDES);
    llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, currentColour, 1, 10, 2]);
    
}


default
{
    state_entry()
    {
        llSetTimerEvent(TIMER_INT);
        llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, TRUE]);
    }
    timer()
    {
        changeColour();
    }
}

Link to comment
Share on other sites

I would try two things.  First as a test increase the timer event time from .5 to 5 just to slow things down a bit.  It may be calling the function to fast.

Second I would use something like below to be more efficient and increase the speed of the color change.  This was pulled direct from the Wiki  : llSetLinkPrimitiveParamsFast

 

default{    touch_start(integer num_detected)    {    //  color the root prim red and the first linked-prim green        llSetLinkPrimitiveParamsFast(LINK_ROOT,                [PRIM_COLOR, ALL_SIDES, <1.0, 0.0, 0.0>, (float)TRUE,            PRIM_LINK_TARGET, 2,                PRIM_COLOR, ALL_SIDES, <0.0, 1.0, 0.0>, (float)TRUE]);     //  instead of:    //  llSetLinkPrimitiveParamsFast(LINK_ROOT,    //          [PRIM_COLOR, ALL_SIDES, <1.0, 0.0, 0.0>, (float)TRUE]);    //  llSetLinkPrimitiveParamsFast(2,    //          [PRIM_COLOR, ALL_SIDES, <0.0, 1.0, 0.0>, (float)TRUE]);    }}

 

Link to comment
Share on other sites

im confused lol as u can tell im no scripter and telling me to change something or add something to the script i have already pasted is well confusing lol

 

this was posted by someone else as i posted this in the wrong forum

 

Wrong forum**Only uploaded images may be used in postings**://secondlife.i.lithium.com/i/smilies/16x16_smiley-wink.gif" border="0" alt=":smileywink:" title="Smiley Wink" />

Instead of all that llSetLinkColor function calls you should use one LlSetLinkPrimitiveParamsFast instruction call

You need to figure out how prims are numbered in the link set

You will get a lot more support in the LSL Scripting forum

 

im lost lol i wouldnt know what to do lmao

Link to comment
Share on other sites

Well then I would try to start with simpler things and work your way up.  Maybe someone else will have the time to rewrite your entire script.  If not then break it down into smaller pieces, like one prim and a few fixed colors.  Then slowly add more prims and more colors.

Link to comment
Share on other sites

define your colors first...

then put a llMessageLinked, in the main script, and a link_message

in all the child prims you want to change?

 

vector white   = <1.0, 1.0, 1.0>;vector grey    = <0.5, 0.5, 0.5>;vector black   = <0.0, 0.0, 0.0>;vector red     = <1.0, 0.0, 0.0>;vector green   = <0.0, 1.0, 0.0>;vector blue    = <0.0, 0.0, 1.0>;vector yellow  = <1.0, 1.0, 0.0>;vector cyan    = <0.0, 1.0, 1.0>;vector magenta = <1.0, 0.0, 1.0>;
Link to comment
Share on other sites

I don't understand what effect you are trying to create.  Are you hoping to make each of the selected prims cycle through a set of colors, but have each prim colored differently each time the timer fires?  If so, something like this is fairly simple...

list gColors = [<1.0, 1.0, 1.0>,<0.5, 0.5, 0.5>,<0.0, 0.0, 0.0>,<1.0, 0.0, 0.0>,<0.0, 1.0, 0.0>,<0.0, 0.0, 1.0>,<1.0, 1.0, 0.0>,<0.0, 1.0, 1.0>,<1.0, 0.0, 1.0>];list gDisplayLinks;float TIMER_INT = 0.5;integer gCount;default{    state_entry()    {        llSetTimerEvent(TIMER_INT);        llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, TRUE]);        integer i = llGetNumberOfPrims();        while (i)        {            if (llGetLinkName(i) == "Display")  // Make a list of the links named "Display"            {                gDisplayLinks += [i];            }            --i;        }    }    timer()    {        ++gCount;        integer i;        for (i=0;i<(gDisplayLinks !=[]);++i)        {            vector CurrentColour = llList2Vector(gColors,(gCount+i)%(gColors!=[]));            llSetLinkPrimitiveParamsFast(llList2Integer(gDisplayLinks,i),[PRIM_COLOR,ALL_SIDES,CurrentColour,1.0,PRIM_POINT_LIGHT,TRUE,CurrentColour,1.0,10.0,2.0]);        }    }}

 It will only change colors on the child prims that you have named "Display", and it will change each to a different color each time.  You can play with  the list of color vectors to get a set that you like.

Link to comment
Share on other sites

hi there no i want them all to change color at the same time the same color im making a jukebox and have 5 prims joined that will be a flashing light it will look like a tubelight that will be shaped like a U upside down and to get that shape im having to use 5 prims to make that shape so i need all them 5 prims to flash the same colour at the same time whilst it is gonna be link to other prims

Link to comment
Share on other sites

Oh, well, then, that's easy.  Make one tiny change.  Find the line that says vector CurrentColour and substitute this one for it.

           

 vector CurrentColour = llList2Vector(gColors,gCount%(gColors!=[]));

 Oh, and for the sake of consistency, find the line earlier in the script that says llSetPrimitiveParams and substitute this for it.

        llSetLinkPrimitiveParams(LINK_SET,[PRIM_FULLBRIGHT, ALL_SIDES, TRUE]);

 The only other thing that I'd be likely to change if this were on my own parcel would be the intensity of the PRIM_POINT_LIGHT.  Instead of setting it at 1.0,10.0, as your original had it, I would personally tone it down to 0.5, 5.0 .  But that's just me.

EDIT:  Incidentally, you'll get a much more convincing tube (and have a lower prim count) if you make it a mesh object instead of gluing five prims together.  :smileywink:

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4209 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...