I've been coding for 6 years but am still rusty when it comes to Expression 2. If you find any places that are unclear please tell me.
Alright, E2 isn't as hard as it looks, as this tutorial will show (hopefully).
What this is going to do is make your character flash a random color very quickly. (Your first E2 is supposed to be pointless)
First, take out your E2 tool in the
Wire tab. Then right click and the editor should come up. You can erase all the crap that's on there except the first 5 lines. Make sure it looks like this so far:
Code:
@name Party Time
@inputs
@outputs
@persist
@trigger all
Now you've set the name of the E2.
Since we want it to change color quickly we have to tell it to run quickly.
So now a few lines down type
Now for the coloring itself, setColor() uses 3 variables, Red, Green, and Blue. Each one can be any number between 1 (darkest) and 255 (lightest). So if you wanted red you would use setColor(255,0,0).
However, we want a random color. So first we have to make some variables.
Go a couple lines down and type
Code:
A=random(1,255)
B=random(1,255)
C=random(1,255)
This makes new variables A, B, and C. The variables now have a value of a random number between 1 and 255. This ensures you will turn all kinds of crazy colors. So now instead of setColor(0,0,0) we would use setColor(A,B,C). See where this is going?
Go down and type
Code:
owner():setColor(A,B,C)
Now wait a minute, where did the owner() come from? Well we have to tell it what to color, and whoever spawns the Expression chip is considered the 'owner'. So we link that function to the other one with a colon. You can link all kinds of them together.
The final code should look something like this:
Code:
@name Party Time
@inputs
@outputs
@persist
@trigger all
interval(10)
A=random(1,255)
B=random(1,255)
C=random(1,255)
owner():setColor(A,B,C)
Now all you have to do is spawn it and you will flash all kinds of colors! Impress your friends! Give them seizures! Whatever you want.