In short, we need to be able to do this:
Code: Select all
decl o = getobject();
This is not the best example, as this implementation could be simplified by using switches, but bear with me, the principals are here.
Lets say I make an array of pads. I want to use those pads as select buttons. Hitting a pad will cause it to light up, as well as turn off whichever other pad was currently lit.
So we have our object 'Pads', and inside 'Pads' we make an expression, 'selected=0' for tracking which pad was last pressed, by which we can setup a script elsewhere in the template that will fire when 'selected' is changed.
We also make a script to control which pad is lit, 'setGlow(p)' within 'Pads' that fires manually:
Code: Select all
decl i;
for (i=0;i<=sizeof(x);i++) {
if (i == p) {
light[i] = 0.325;
} else {
light[i] = 0;
}
}
Code: Select all
decl i;
for (i=0;i<=sizeof(x);i++) {
if (x[i] == 1) {
selected = i;
setGlow(i);
}
}
Why can't 'setGlow(p)' become a global script with 2 paramaters, 'setGlow(p,o)' ?
Code: Select all
decl i;
for (i=0;i<=sizeof(o.x);i++) {
if (i == p) {
o.light[i] = 0.325;
} else {
o.light[i] = 0;
}
}
Code: Select all
decl i;
decl o = getobject()
for (i=0;i<=sizeof(x);i++) {
if (x[i] == 1) {
selected = i;
setGlow(i,o);
}
}