Array cell access [help needed].
50 posts • Page 2 of 2 • 1, 2
Re: Array cell access [help needed].
savask wrote:Yes, immibis was right. This is cause of for-loop limit.
Can you show me some examples of using your for-function?
okay sorry i thought you mean the number of cells you can use in an array like you said above
@immibis:
what's the "max" variable for?
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Array cell access [help needed].
You wasn't far from the truth
I "couldn't use" more than 50 cells, because I couldn't make more than 50 cells in the loop
I "couldn't use" more than 50 cells, because I couldn't make more than 50 cells in the loop
-
savask - Posts: 162
- Joined: Mon Oct 12, 2009 2:53 pm
- Location: Russia, Siberia
Re: Array cell access [help needed].
oh that explains a lot
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Array cell access [help needed].
Some questions
Should I write this function in the console?
Will it be saved in the phz file?
Should I write this function in the console?
Will it be saved in the phz file?
-
savask - Posts: 162
- Joined: Mon Oct 12, 2009 2:53 pm
- Location: Russia, Siberia
Re: Array cell access [help needed].
yes if you write any variable/function with "scene.my." in front of it it will be saved to your .phz file. and yes, functions normally are typed into the console
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Array cell access [help needed].
Ok, thanks!
Now we should wait for immibis answer...
Now we should wait for immibis answer...
-
savask - Posts: 162
- Joined: Mon Oct 12, 2009 2:53 pm
- Location: Russia, Siberia
Re: Array cell access [help needed].
Just use Scene.my.for2 instead of for. For example, instead of:
write
- Code: Select all
for(1000, (i)=>{do some stuff})
write
- Code: Select all
Scene.my.for2(1000, (i)=>{do some stuff})
Thymechanic
- immibis
- Posts: 87
- Joined: Wed Sep 30, 2009 12:24 am
Re: Array cell access [help needed].
Thank you!
It is very good that your function use the same syntax as default for-loop
It is very good that your function use the same syntax as default for-loop
-
savask - Posts: 162
- Joined: Mon Oct 12, 2009 2:53 pm
- Location: Russia, Siberia
Re: Array cell access [help needed].
the for2 function is nice and works but whenever i use scene.my.for2 in complex functions it doesn't work. algodoo freezes and windows has to force it to close. any ideas?
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Array cell access [help needed].
It works fine for me, but may be my scripts isn't so complex as yours.
-
savask - Posts: 162
- Joined: Mon Oct 12, 2009 2:53 pm
- Location: Russia, Siberia
Re: Array cell access [help needed].
i don't know what's wrong. maybe it's because i have a spawn script in the for2 function (which should normally work)
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Array cell access [help needed].
Can you show the script?
-
savask - Posts: 162
- Joined: Mon Oct 12, 2009 2:53 pm
- Location: Russia, Siberia
Re: Array cell access [help needed].
- Code: Select all
Scene.my.ln = (x) => { (x^0.001 - 1) / 0.001 };
scene.my.physicsstuff = (g,m,v,a,d,x) => { big physics formula here };
scene.my.q = (x) =>
{
n := math.tofloat(x);
scene.my.for2(n, (i)=> {
scene.addcircle({
radius := 0.005;
color := [1,1,1,1];
pos := [i/10, scene.my.physicsstuff(9.8,2,10,math.pi/4,2.5,i/10)]
})
})
};
With the normal for function it works but with the for2 function Algodoo crashes. It's weird.
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Array cell access [help needed].
I tried a spawn script in for2-loop and it works.
-
savask - Posts: 162
- Joined: Mon Oct 12, 2009 2:53 pm
- Location: Russia, Siberia
Re: Array cell access [help needed].
i know. normally it works.
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Array cell access [help needed].
But you said that Algodoo crashes, didn't you?
-
savask - Posts: 162
- Joined: Mon Oct 12, 2009 2:53 pm
- Location: Russia, Siberia
Re: Array cell access [help needed].
yes normally it works but this code above doesn't work. it only works with the normal for function.
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Array cell access [help needed].
May be the problem with the n variable?
-
savask - Posts: 162
- Joined: Mon Oct 12, 2009 2:53 pm
- Location: Russia, Siberia
Re: Array cell access [help needed].
Thanks, that's the error. I tested it with a simple code but the for2 function can't handle it with specific values
Not working
Scene.my.test(0)
Scene.my.test(1)
If you choose a value above 1 it's working. I tested it with scene.my.value(2), scene.my.value(10), scene.my.value(100) and scene.my.value(1000). They all work. Weird...
I'll write a PM to immibis.
[EDIT]
If you make x a float value it only works with scene.my.test(2). All other values don't work.
- Code: Select all
Scene.my.test = (x) => { scene.my.for2(x, (i)=>{ print ((i+1) + " text lines") }) };
Not working
Scene.my.test(0)
Scene.my.test(1)
If you choose a value above 1 it's working. I tested it with scene.my.value(2), scene.my.value(10), scene.my.value(100) and scene.my.value(1000). They all work. Weird...
I'll write a PM to immibis.
[EDIT]
If you make x a float value it only works with scene.my.test(2). All other values don't work.
- Code: Select all
Scene.my.test = (x) =>
{
n := math.tofloat(x);
scene.my.for2(n, (i)=>{ print ((i+1) + " text lines") })
};
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Array cell access [help needed].
Yes, really, it don't work with 0 and 1.
So I have to use default "for" function
So I have to use default "for" function
-
savask - Posts: 162
- Joined: Mon Oct 12, 2009 2:53 pm
- Location: Russia, Siberia
Re: Array cell access [help needed].
I already let immibis know about this bug. I wrote a PM. Let's wait.
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Array cell access [help needed].
Ok, I wish he will fix it.
-
savask - Posts: 162
- Joined: Mon Oct 12, 2009 2:53 pm
- Location: Russia, Siberia
Re: Array cell access [help needed].
I've edited my original post here to the "Thyme math functions" thread: viewtopic.php?f=13&t=371&p=8695#p8695
Thymechanic
- immibis
- Posts: 87
- Joined: Wed Sep 30, 2009 12:24 am
Re: Array cell access [help needed].
Ok, thanks!
-
savask - Posts: 162
- Joined: Mon Oct 12, 2009 2:53 pm
- Location: Russia, Siberia
Re: Array cell access [help needed].
Very good! Now it's awesome
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
50 posts • Page 2 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 2 guests