simple code doesn't works
9 posts • Page 1 of 1
simple code doesn't works
Hello everybody, I have a little problem, my code doesn't works and I don't understand why.
I try to make an "automatic crane". The black boxes between the wheels control the sequence of the crane. It's a laser control. But when I press Enter (to activate laser), nothing happen ...
I share the scene.
variable:
scene.my.pos0: X pos of the ball
scene.my.pos1: Y pos of the ball
scene.my.pos00: X pos of the shoe
scene.my.pos11: Y pos of the shoe
scene.my.(a/b/c/d1): length of the different springs.
I try to make an "automatic crane". The black boxes between the wheels control the sequence of the crane. It's a laser control. But when I press Enter (to activate laser), nothing happen ...
I share the scene.
variable:
scene.my.pos0: X pos of the ball
scene.my.pos1: Y pos of the ball
scene.my.pos00: X pos of the shoe
scene.my.pos11: Y pos of the shoe
scene.my.(a/b/c/d1): length of the different springs.
- Attachments
-
Crane I.phz- (78.71 KiB) Downloaded 45 times
- francky380a380
- Posts: 48
- Joined: Tue Dec 17, 2013 8:12 pm
Re: simple code doesn't works
if statment shold be like this:
a == b ? {} : {}
but you use =
a == b ? {} : {}
but you use =
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: simple code doesn't works
Thank you !! I'm so stupid --"
An other question, is it possible to "cut" a number, I explain, the length of the spring is 3.97542152 but I want to use only 3.98 (easier to compare value). I know the Mat.toInt function but it "cut" too much so I loose a lot of precision. That's why I want 2/3 number after the coma.
An other question, is it possible to "cut" a number, I explain, the length of the spring is 3.97542152 but I want to use only 3.98 (easier to compare value). I know the Mat.toInt function but it "cut" too much so I loose a lot of precision. That's why I want 2/3 number after the coma.
- francky380a380
- Posts: 48
- Joined: Tue Dec 17, 2013 8:12 pm
Re: simple code doesn't works
Math.toint( scene.my.var * 100) / 100
That should do the trick, think there is another way to do it, however that should work.
That should do the trick, think there is another way to do it, however that should work.
When asking for help, READ THE STICKIES!
- electronicboy
- Posts: 1694
- Joined: Mon Aug 31, 2009 6:18 pm
Re: simple code doesn't works
hummmm, very clever, I love !! Thank you !!
- francky380a380
- Posts: 48
- Joined: Tue Dec 17, 2013 8:12 pm
Re: simple code doesn't works
It doesn't works, he doesn't want to put the comas. He reduce 7.99 to 8 or 7.5 to 8 etc ...
- francky380a380
- Posts: 48
- Joined: Tue Dec 17, 2013 8:12 pm
Re: simple code doesn't works
I try to write || *10^(-2) || and it works more or less!! When I move it doesn't work but when I stop, to stabilize me, ir works, it writes 7.99 instead of 8.
I try now to increase the efficiency of the code
I try now to increase the efficiency of the code
- francky380a380
- Posts: 48
- Joined: Tue Dec 17, 2013 8:12 pm
Re: simple code doesn't works
algodoo automatically set type of result depending on first value:
5/2 will return 2
5.0/2 will return 2.5
5/2 will return 2
5.0/2 will return 2.5
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: simple code doesn't works
A very simple solution, I still stupid, it's to use Math.toInt( scene.my.var * 100 ) , without the *10^(-2). Because if I compare a Math.toInt( scene.my.var * 100 ) to an other Math.toInt( scene.my.var * 100 ) it's the same as if I use it with the *10^(-2).
So now the V2.2 of my crane is ready and uploaded
please download rate and comment, thanks 
So now the V2.2 of my crane is ready and uploaded
- francky380a380
- Posts: 48
- Joined: Tue Dec 17, 2013 8:12 pm
9 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 7 guests



