simple code doesn't works

About advanced scenes, and the Thyme scripting language used in Algodoo.

simple code doesn't works

Postby francky380a380 » Sun Jul 06, 2014 11:58 am

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.
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

Postby Kilinich » Sun Jul 06, 2014 1:09 pm

if statment shold be like this:

a == b ? {} : {}

but you use =
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: simple code doesn't works

Postby francky380a380 » Sun Jul 06, 2014 7:31 pm

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.
francky380a380
 
Posts: 48
Joined: Tue Dec 17, 2013 8:12 pm

Re: simple code doesn't works

Postby electronicboy » Mon Jul 07, 2014 1:10 pm

Math.toint( scene.my.var * 100) / 100

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

Postby francky380a380 » Mon Jul 07, 2014 8:38 pm

hummmm, very clever, I love !! Thank you !!
francky380a380
 
Posts: 48
Joined: Tue Dec 17, 2013 8:12 pm

Re: simple code doesn't works

Postby francky380a380 » Wed Jul 09, 2014 4:00 pm

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

Postby francky380a380 » Wed Jul 09, 2014 7:38 pm

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 ;)
francky380a380
 
Posts: 48
Joined: Tue Dec 17, 2013 8:12 pm

Re: simple code doesn't works

Postby Kilinich » Thu Jul 10, 2014 12:47 am

algodoo automatically set type of result depending on first value:

5/2 will return 2
5.0/2 will return 2.5
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: simple code doesn't works

Postby francky380a380 » Fri Jul 18, 2014 8:00 pm

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 ;)
francky380a380
 
Posts: 48
Joined: Tue Dec 17, 2013 8:12 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 7 guests