creating variables with for-loop (ascending number)
Posted: Sun Oct 25, 2020 6:29 pm
Hi there!
At first, this is my context of code:
So, now the problem:
is the part where i would like to have something like this:
and of course i know that's not how it works. I actually don't know if it can be done at all. In the end there should exist (for this example 54) some variables, named with ascending numbers at the end of their name.
Could anybody tell me if it is possible and if not if there is an easy workaround because i found none (besides of creating the lasers and then go into every single script menue and typing in the variables by hand which reaaally annoys and is prone to typos). Please help! Thanks in advance!
At first, this is my context of code:
- Code: Select all
p=(-1);
q=0;
x=54; //Gesamtmenge
y=9; //Zeilen, Spalten => x/y
offset=[0,0];
for(x, (i)=>{
math.mod(i,y) == 0 ? {p = p+1; q=0}:{p = p; q = q+1};
Scene.addLaserPen({
pos:=[p,q]+offset;
fadeDist:=10;
colorHSVA:=[(i*5), 1.0, 1.0, 1.0];
buttonDestroy:="f";
size:=0.5;
maxRays:=1;
rotation:=math.pi;
onLaserHit:=(e)=>{scene.my.perceptron=e.other.colorHSVA(2)};
});
})
So, now the problem:
- Code: Select all
onLaserHit:=(e)=>{scene.my.test = something};
is the part where i would like to have something like this:
- Code: Select all
onLaserHit:=(e)=>{scene.my.test {i} = something};
and of course i know that's not how it works. I actually don't know if it can be done at all. In the end there should exist (for this example 54) some variables, named with ascending numbers at the end of their name.
- Code: Select all
scene.my.test0 = something;
scene.my.test1 = something;
scene.my.test2 = something;
scene.my.test3 = something;
...
Could anybody tell me if it is possible and if not if there is an easy workaround because i found none (besides of creating the lasers and then go into every single script menue and typing in the variables by hand which reaaally annoys and is prone to typos). Please help! Thanks in advance!