Notifications
Clear all

[Closed] compare vertexcolor

hi there!
i have a simple qustion. i want to compare the wirecolor of 2 objects. if it is the same, than it should change. i have an idea for the script, my only problem is the comarison.

for the change of an object from black to white i tried:

if $.wirecolor = color 0 0 0 then $.wirecolor = color 255 255 255

[size=2]i get an error message. it seems like i can only use bool-variables for the if-sentence.[/size]
[size=2][/size]
[size=2]after that, i tried to make an array of the wirecolor and compare the 3 color-values after and after:[/size]

array = #($.wirecolor)

when i compare this array with another array, i get the same (bool) error-message. and in this array, there are not only numbers; the string:color is included

i think this is an easy operation. where is my fault?

greez
stegge

2 Replies

if $.wirecolor = color 0 0 0 then $.wirecolor = color 255 255 255

should be

if $.wirecolor == color 0 0 0 then $.wirecolor = color 255 255 255

because the isEqual boolean operation is denoted by ==, while = is assignment.
What you told MAXScript was

if (color 0 0 0) then $.wirecolor = color 255 255 255

because after the assignment, the value in $.wirecolor IS the color 0 0 0, but an IF cannot use a color, only a BOOL value – True or False.

Also note that for the main colors like Black, White, Red, Yellow etc., there are pre-defined global variables you can use:

if $.wirecolor == black do $.wirecolor = white

This was exactly my problem. Some things are easier than they seem! Thank you for your quick answer!