what does (a, b, c, d)=>{} mean?
12 posts • Page 1 of 1
what does (a, b, c, d)=>{} mean?
Can someone explain why some script look like
- Code: Select all
(e, k, g, u, y)=>{insert script here}
make sure to check out my work.
-
Rideg - Posts: 948
- Joined: Tue Dec 15, 2009 5:17 pm
- Location: Östersund, Sweden
Re: what does (a, b, c, d)=>{} mean?
This is function, for example
Ps
And how are you going to teach them?
- Code: Select all
scene.my.function:=(r,t,u)=>{r=t*u};
scene.my.function(var, 10,13)
// and after this var=130
Ps
Rideg wrote:Want to learn how to script? PM me and I'll teach you the basics and advanced parts of scripting.
And how are you going to teach them?
-
Nait - Posts: 224
- Joined: Fri Oct 30, 2009 1:56 am
- Location: Eastern Russia, Vladivostok
Re: what does (a, b, c, d)=>{} mean?
Nait wrote:PsRideg wrote:Want to learn how to script? PM me and I'll teach you the basicsAnd how are you going to teach them?
fixed
Cave Johnson wrote:Do you know who I am? I'm the man who's gonna burn your house down! With the lemons! I'm gonna get my engineers to invent a combustible lemon that burns your house down!
-
Matten - Posts: 435
- Joined: Mon Apr 05, 2010 2:03 pm
- Location: The Netherlands
Re: what does (a, b, c, d)=>{} mean?
Basics should be more exactly I'll change that in a second. When will I have use for this?
make sure to check out my work.
-
Rideg - Posts: 948
- Joined: Tue Dec 15, 2009 5:17 pm
- Location: Östersund, Sweden
Re: what does (a, b, c, d)=>{} mean?
Hm, when you have to do many identical calculations...
For ex. instead of writing this
You can write this
For ex. instead of writing this
- Code: Select all
A=((A/180*Math.Pi)+120)/(B^2);
B=((B/180*Math.Pi)+120)/(B^2);
C=((C/180*Math.Pi)+120)/(C^2);
...
You can write this
- Code: Select all
func:=(t)=>{t=((t/180*Math.Pi)+120)/(t^2)};
func(A);
func(B);
func(C);
...
-
Nait - Posts: 224
- Joined: Fri Oct 30, 2009 1:56 am
- Location: Eastern Russia, Vladivostok
Re: what does (a, b, c, d)=>{} mean?
Nait wrote:You can write this
- Code: Select all
func:=(t)=>{t=((t/180*Math.Pi)+120)/(t^2)};
func(A);
func(B);
func(C);
...
1) Please use "Scene.my.".
2) The substitution(t = ...) should be outside of the finction (or use "eval").
It should be like below.
- Code: Select all
Scene.my.func:=(t)=>{((t/180*math.pi)+120)/(t^2)};
Scene.my.A = 1;
Scene.my.A = Scene.my.func(Scene.my.A);
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
-
tatt61880 - [Most Helpful Person 2010]
- Posts: 1150
- Joined: Mon Aug 31, 2009 5:45 pm
- Location: Tokyo, Japan
Re: what does (a, b, c, d)=>{} mean?
Maybe I asked for more than I got. I don't understand. Can you use it in a example?
make sure to check out my work.
-
Rideg - Posts: 948
- Joined: Tue Dec 15, 2009 5:17 pm
- Location: Östersund, Sweden
Re: what does (a, b, c, d)=>{} mean?
tatt61880, Okay, I'll take it into consideration
(and scene.my can be not used if you are not going so save scene))))
_________
Hm...
For example, you have many color sensors
And now in every sensor you can write
You can check that, it is working... (in algodoo of course)
PS "in algodoo of course" - deleting object via "density=0"
PSS
(and scene.my can be not used if you are not going so save scene))))
_________
Hm...
For example, you have many color sensors
- Code: Select all
scene.my.detect:=(c, d)=>{c==[1.0,1.0,1.0,1.0]?{}:{d.other.density=0}}
And now in every sensor you can write
- Code: Select all
oncollide=(e)=>{scene.my.detect(e.other.color, e)}
You can check that, it is working... (in algodoo of course)
PS "in algodoo of course" - deleting object via "density=0"
PSS
-
Nait - Posts: 224
- Joined: Fri Oct 30, 2009 1:56 am
- Location: Eastern Russia, Vladivostok
Re: what does (a, b, c, d)=>{} mean?
Or just a simple mathematical example you can test in your console could also be this:
You got a function f(x) = x² and you want to include it in Algodoo. You can open your console and type in
or whatever. Press enter and now you can type in scene.my.f(2) for example and your displayed solution would be 4. Or scene.my.f(5) and your solution in the console will be 25. The function always will calculate the square of your input.
You can make pretty complex functions which get calculated dependent from a bunch of variables (or just one in this example).
You got a function f(x) = x² and you want to include it in Algodoo. You can open your console and type in
- Code: Select all
scene.my.f := (x) => { x^2 }
or whatever. Press enter and now you can type in scene.my.f(2) for example and your displayed solution would be 4. Or scene.my.f(5) and your solution in the console will be 25. The function always will calculate the square of your input.
You can make pretty complex functions which get calculated dependent from a bunch of variables (or just one in this example).
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: what does (a, b, c, d)=>{} mean?
also, you can declare functions inside geometries automatically.
Jrv wrote:TC42 wrote:Quite honestly, I didn't think anyone on 4chan has that good a use of grammar, spelling, usage, mechanics, ect.
But I've never been there, so I may be wrong.
GTFO newfgt
-
RA2lover - Posts: 607
- Joined: Mon Aug 31, 2009 8:43 pm
- Location: Brazil
Re: what does (a, b, c, d)=>{} mean?
RA2lover wrote:also, you can declare functions inside geometries automatically.
Sounds interesting. Could you show me an example?
make sure to check out my work.
-
Rideg - Posts: 948
- Joined: Tue Dec 15, 2009 5:17 pm
- Location: Östersund, Sweden
Re: what does (a, b, c, d)=>{} mean?
- Code: Select all
oncollide=
(e)=>{
e.this.foo=(bar)=>{baz}
}
Jrv wrote:TC42 wrote:Quite honestly, I didn't think anyone on 4chan has that good a use of grammar, spelling, usage, mechanics, ect.
But I've never been there, so I may be wrong.
GTFO newfgt
-
RA2lover - Posts: 607
- Joined: Mon Aug 31, 2009 8:43 pm
- Location: Brazil
12 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 7 guests