Blockland Forums > Modification Help
Getting the darkest color from the colorset
Pages: (1/1)
chrisbot6:
Hi, i've been trying to make a mod that doesn't require the default colorset to work properly, but I don't know how I can get the darkest color from the given color set. I looked in the duplicator's script and found this:
--- Code: --- function determineBrightestColor()
{
%target = "1 1 1 1";
for(%i = 0; %i < 64; %i++)
{
%colori = getColorIdTable(%i);
%dist = vectorDist(%colori, %target);
if(%dist < %best || %best $= "")
{
%best = %dist;
$Duplicator::HighlightColor = %i;
}
}
}
--- End code ---
I cannot understand it. Can someone help?
chrisbot6:
Bump.
Monocle:
That's just the part that detects the colour and then sets it to the highlight colour.
Ash:
--- Code: ---function determineBrightestColor()
{
%target = "1 1 1 1"; //Goal
for(%i = 0; %i < 64; %i++) //Loop 64 times (Aka through the whole colorset)
{
%colori = getColorIdTable(%i); //Find the values of the 64 colors
%dist = vectorDist(%colori, %target); //Find the distance between the goal and the found values
if(%dist < %best || %best $= "") //If a better color is found...
{
%best = %dist; //... make that color the new best color
$Duplicator::HighlightColor = %i; //Highlight the best color
}
}
}
--- End code ---
Tada? This code reads like plain english. Is all code this simple?
Change the "1 1 1 1" to "0 0 0 1" and you should then get the darkest color. I think that the color is in R G B A using the 0 - 1 type thingy.
Pages: (1/1)