Jump to content

Color blending script(s)


Doogz Weston
 Share

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

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

Recommended Posts

I was hoping I could get help on an idea I have.  I want to be able to click on 2 objects then have a 3rd object change to the blended color of the 2.  Any help on how to accomplish this or guiding me to where to go for help is greatly appreciated.

Link to comment
Share on other sites

Thank you Dora for the reply but there is a problem.  I used the llGetColor in the 2 objects I need blended but when I use llSetColor in the 3rd I get a syntax error when I used the below part of code.  I tried to divide (color1 +color2) by 2 as well and came up with same error.  I hope to find a solution.  I am going to keep looking and trying but any help is still very appreciated.

 

vector color_blended = 0.5*( color1 + color2);
Link to comment
Share on other sites

I tried using this.  Yes, I am not good with scripts so what I tried may make you laugh so bare with me.  I have gained a basic understanding of scripts but writing them causes problems.

 

vector color1;

vector color2;
vector color_blended = 0.5*( color1 + color2);


default
{
touch_start(integer num)
{
llSetColor(0.5*( color1 + color2);
}
}

Link to comment
Share on other sites

You can't do mathematics when creating global variables, so in this script color_blended will always give an error, and is not actually needed since the calculation is done in the llSetColor function, I think you can delete the color_blended line completely.

Also you have to specify the face to be colored, and close the second parenthesis at the end of the llSetColor function:

llSetColor(0.5*( color1 + color2), face);

You can replace face with the face number, or with ALL_SIDES if you just need to change the color of the whole object.

 

With those corrections you shouldn't get any error, although I'm not sure how the color1 and color2 variables will be filled, so far this script will only turn your object black, you might eventually need a listen event if your objects are not linked.

Link to comment
Share on other sites

Four suggestions:

1. You can't do calculations in the declaration of a global variable, so vector color_blended = 0.5*( color1 + color2); is out.

2. You don't need to declare global variables unless you are going to use them globally.  That gets rid of all three of yours.

3. If you are going to use variables of any kind, you need to give them values. So, in your touch_start event, you should define (for example)

vector color1 = <0.5,0.5,0.0>;vector color2 = <0.8,0.0,0.0>;

 Or maybe provide some way to input those variables in a listen event, for example.

4. You'll need to check to be sure that every open bracket or parenthesis is matched by a closed one.  Yours aren't.

If you really want to investigate how colors blend, take a look at http://wiki.secondlife.com/wiki/Color

 

 

Link to comment
Share on other sites


Doogz Weston wrote:

I tried using this.  Yes, I am not good with scripts so what I tried may make you laugh so bare with me.  I have gained a basic understanding of scripts but writing them causes problems.

 

vector color1;

vector color2;

vector color_blended = 0.5*( color1 + color2);

 

default

{

touch_start(integer num)

{

llSetColor(0.5*( color1 + color2);

}

}

Or you can add the closing parentheses;

default

{

touch_start(integer num)

{

llSetColor( 0.5* ( color1 + color2) );

}

}

 

NOTE: Most mistakes are missing semi-colons, non-closed brackets, etc. Check those errors first.

 

Link to comment
Share on other sites

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