Function call applied to non-function
9 posts • Page 1 of 1
Function call applied to non-function
At my latest scene I've got a problem i simply dont get.
I ve created a Seesaw with a box at each end. 2 Lasers constantly point at both boxes. With this script it should ballance automaticly. But whenever scene.my.ballance is exectuted the following error appears:
> Scene.my.ballance
-- Warning: Failed to evaluate: Scene.my.sensor_R_y >= Scene.my.sensor_L_y(?)({Scene.my.ballance_ = false}), Function call applied to non-function: Scene.my.sensor_L_y(?)
-- Warning: Failed to evaluate: Scene.my.sensor_L_y >= Scene.my.sensor_R_y(?)({Scene.my.ballance_ = true}), Function call applied to non-function: Scene.my.sensor_R_y(?)
I do not see any reason why this should happen. I also tryed to change Scene.my.ballance to a function - same problem.
Here is the whole relevant code for this scene.
I ve created a Seesaw with a box at each end. 2 Lasers constantly point at both boxes. With this script it should ballance automaticly. But whenever scene.my.ballance is exectuted the following error appears:
> Scene.my.ballance
-- Warning: Failed to evaluate: Scene.my.sensor_R_y >= Scene.my.sensor_L_y(?)({Scene.my.ballance_ = false}), Function call applied to non-function: Scene.my.sensor_L_y(?)
-- Warning: Failed to evaluate: Scene.my.sensor_L_y >= Scene.my.sensor_R_y(?)({Scene.my.ballance_ = true}), Function call applied to non-function: Scene.my.sensor_R_y(?)
I do not see any reason why this should happen. I also tryed to change Scene.my.ballance to a function - same problem.
Here is the whole relevant code for this scene.
- Code: Select all
Scene.my.sensor_L_y=1;
Scene.my.sensor_R_y=1;
Scene.my.ballance_ = false;
Scene.my.ballance = {
Scene.my.sensor_R_y>=Scene.my.sensor_L_y ? {
Scene.my.ballance_ = false;
};
Scene.my.sensor_L_y>=Scene.my.sensor_R_y ? {
Scene.my.ballance_ = true;
};
};
- Code: Select all
Scene.addHinge {
(...)
ccw := {Scene.my.ballance_};
(...)
- Code: Select all
Scene.addBox {
(...)
onHitByLaser := (e)=>{Scene.my.sensor_L_y=e.pos(1);
(...)
}
Scene.addBox {
(...)
onHitByLaser := (e)=>{Scene.my.sensor_R_y=e.pos(1);
scene.my.ballance
(...)
- Attachments
-
ballance.phn- (15.97 KiB) Downloaded 33 times
-

SyntaxError - Posts: 11
- Joined: Sat Apr 30, 2011 9:00 pm
Re: Function call applied to non-function
The proper syntax for if then else commands is as follows:
Evaluation is just your comparison like (a>b)
Your code has "if" commands that don't have a ":{}" after the code to execute if the evaluation results as a true.
This...
Should be this...
Algodoo is taking your wrong code and changing it to an even more wrong code:
The code above results in the error you are seeing because the compiler thing sees Scene.my.sensor_L_y(?) and thinks you are trying to call a function.
Hope this helps!
- Code: Select all
(evaluation) ? {code to execute if evaluation results as true} : {code to execute if evaluation results as false};
Evaluation is just your comparison like (a>b)
Your code has "if" commands that don't have a ":{}" after the code to execute if the evaluation results as a true.
This...
- Code: Select all
Scene.my.sensor_R_y>=Scene.my.sensor_L_y ? {
Scene.my.ballance_ = false;
}
Should be this...
- Code: Select all
Scene.my.sensor_R_y>=Scene.my.sensor_L_y ? {
Scene.my.ballance_ = false;
}:{}
Algodoo is taking your wrong code and changing it to an even more wrong code:
- Code: Select all
Scene.my.sensor_R_y >= Scene.my.sensor_L_y(?)({Scene.my.ballance_ = false})
The code above results in the error you are seeing because the compiler thing sees Scene.my.sensor_L_y(?) and thinks you are trying to call a function.
Hope this helps!
Noobs are the best 
-

phunHunger - Posts: 31
- Joined: Mon Apr 26, 2010 10:01 pm
Re: Function call applied to non-function
That pretty will explains it. Good job! 
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: Function call applied to non-function
Thanks!
Now it works.
Here is the result:
Now it works.
Here is the result:
-

SyntaxError - Posts: 11
- Joined: Sat Apr 30, 2011 9:00 pm
Re: Function call applied to non-function
I'd be better if you used e.normal to generate an angle, then performed some simple operation on it and fed that into motorSpeed. The result would be a lot smoother, and would react much faster on a quickly-moving base.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: Function call applied to non-function
I'd be better if you used e.normal to generate an angle, then performed some simple operation on it and fed that into motorSpeed. The result would be a lot smoother, and would react much faster on a quickly-moving base.
Yes I know. This was jut the first version. I linked the difference between the height of the left and the right box to the speed of the hinge.
-

SyntaxError - Posts: 11
- Joined: Sat Apr 30, 2011 9:00 pm
Re: Function call applied to non-function
Or rather the direction of the hinge.
Let me know if you need an e.normal >> angle code. I've got a complicated, but good one.
Let me know if you need an e.normal >> angle code. I've got a complicated, but good one.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: Function call applied to non-function
Kilinich's one is my favourite: http://www.algodoo.com/forum/viewtopic.php?f=13&t=2900&start=0
-

bozbez - Posts: 149
- Joined: Tue Apr 12, 2011 7:01 pm
Re: Function call applied to non-function
I'm not completely sure that one works. Here's mine- call on it onCollide or onLaserHit, it saves the value in controllerAcc.
Also, Raydeg has a function that is actually shorter than Kilinich's, but gives NaN for just the wrong normal.
- Code: Select all
{math.asin(e.normal(0)) > 1} ? {controllerAcc = math.acos(e.normal(1))} : {controllerAcc = (-1) * math.acos(e.normal(1))}
Also, Raydeg has a function that is actually shorter than Kilinich's, but gives NaN for just the wrong normal.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
9 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 6 guests





