# Random Wire Colourer

hi,
i was wondering if there is a way to randomize a series of values between X & Y. for my situation, i would like to use the wire colourer to make a random colour, therefore, the number has to be between 1 & 255. can anyone guide me in how to do this? any help is excellent.

cheers

Smako

Load one of the following into an E2 chip.

This one will make a random color every second.

``````

@name Randomizer
@outputs R G B
interval(1000)
R = randint(0,255)
G = randint(0,255)
B = randint(0,255)

``````

This one will make a random color ONCE, unless it’s reloaded again.

``````

@name Randomizer
@outputs R G B
if(first())
{
R = randint(0,255)
G = randint(0,255)
B = randint(0,255)
}

``````

This one will allow you to choose which two values the colors will be between.

``````
It will only make ONE random color, unless it's reloaded.

``````
``````

@name Randomizer
@inputs Min Max
@outputs R G B
if(first())
{
R = randint(Min,Max)
G = randint(Min,Max)
B = randint(Min,Max)
}

``````

This one will make a random color every x seconds. x is defined by the input.

``````

@name Randomizer
@inputs Seconds
@outputs R G B
interval(Seconds * 1000)
R = randint(0,255)
G = randint(0,255)
B = randint(0,255)

``````

This one is more customizable. You can control the seconds, and which values the color will be between.

``````

@name Randomizer
@inputs Seconds Min Max
@outputs R G B
interval(Seconds * 1000)
R = randInt(Min,Max)
G = randInt(Min,Max)
B = randInt(Min,Max)

``````

is there a way i can make one to fire when i, say, press a button or let it pass through a ranger? just so that it fires when the value = 1?

Wire a button/ranger to the colorer’s “Fire” input.

then what do i need the seconds measurement and all that for??

E.G.

You said you wanted a chip that made random colors. The chips listed make random colors, but do NOT tell the colorer when to fire.
The chip only controls two things about the colorer:

A: When to make the next random color.
B: Between which two clamped values should the color be in between.

[editline]13:37[/editline]
Would you mind telling me what you’d need this for? I have a feeling that if you want to set a certain prop a random color, it would be easier done with E2 completely.

i want to try my hand at making one of those neat little ‘box factories’ i have seen around, and i want to make it with a conveyor belt, but also with a cash register type thing, that recognizes the colour and the object type, EG “Object Type: Box; Colour: Red” if you know any scripting that could help me with this, could you please help me out? i think this may be a slight bit above me.

To randomly color a prop that is above the expression:

``````
@name Random colorer
interval(10)
E = ranger(100):entity() #change 100 for the distance of the ranger
E:setColor(randint(255),randint(255),randint(255))
#randint(255) is the same as randint(0,255) which is the same as round(random(255)) or round(random(0,255))

``````