Variable springs

Post your tutorials here.

Variable springs

Postby maxovitsj » Fri Mar 19, 2010 10:46 pm

Hello,

I am new to Algodoo.
I've been playing around for a while and was wondering if its possible to make a spring thats variable.
With that i mean that for example when i press the up arrow on my keyboard the spring increases in length.
And when i press down arrow it decreases.

Thanks in advance

Max
maxovitsj
 
Posts: 3
Joined: Fri Mar 19, 2010 10:40 pm

Re: Variable springs

Postby Sonic » Fri Mar 19, 2010 11:56 pm

No sorry. I think it's impossible.
I do stuff and break things. You know how it is.
Image
User avatar
Sonic
 
Posts: 1467
Joined: Tue Sep 01, 2009 6:18 pm
Location: America!!!

Re: Variable springs

Postby RicH » Sat Mar 20, 2010 12:58 am

It's possible. Get a motor and attach to it 2 boxes with different on-collide codes(one to increase and one to decrease the variable). Now, just set it up so when you press up, only one box would hit and change the variable. Just that concept.
Millions of voices suddenly cried out in terror, and were suddenly silenced. Something terrible has happened.
User avatar
RicH
[Funniest Person 2010]
 
Posts: 2043
Joined: Tue Sep 01, 2009 9:01 am

Re: Variable springs

Postby maxovitsj » Sat Mar 20, 2010 1:36 am

Image

link to pic: http://i41.tinypic.com/s6re45.jpg

Ok so i made that "wheel" that collides with the boxes and then it does what it supposed to
only thing is that i have to keep pressing enter in the "Length" box for the spring otherwise it doesnt move.
I checked the console for Scene.My.Var and that changes.

Thanks in advance.

Max
maxovitsj
 
Posts: 3
Joined: Fri Mar 19, 2010 10:40 pm

Re: Variable springs

Postby RicH » Sat Mar 20, 2010 2:47 am

Type {scene.my.var} instead of scene.my.var.
I found it had a difference.
Millions of voices suddenly cried out in terror, and were suddenly silenced. Something terrible has happened.
User avatar
RicH
[Funniest Person 2010]
 
Posts: 2043
Joined: Tue Sep 01, 2009 9:01 am

Re: Variable springs

Postby Mystery » Sat Mar 20, 2010 3:02 am

Sonic wrote:No sorry. I think it's impossible.

Shut up.

Rich is correct, you need to add some braces ( { } ) around the variable

Also note you can also change the oncollide code to
Code: Select all
scene.my.var = scene.my.var + 0.5

And every time it is hit the spring will increase in length 0.5

Or you can have fun with thing like
Code: Select all
scene.my.var = sim.time *0.1

Which will make the spring longer at the rate of time but such code if better used with a laser.
User avatar
Mystery
 
Posts: 2802
Joined: Thu Sep 03, 2009 1:16 pm
Location: Southern Australia

Re: Variable springs

Postby RicH » Sat Mar 20, 2010 3:06 am

I think he wants it just to be set to predefined lengths. If not then:
http://i39.tinypic.com/10n7y91.png
You could also use gears.
Millions of voices suddenly cried out in terror, and were suddenly silenced. Something terrible has happened.
User avatar
RicH
[Funniest Person 2010]
 
Posts: 2043
Joined: Tue Sep 01, 2009 9:01 am

Re: Variable springs

Postby Mystery » Sat Mar 20, 2010 4:46 am

maxovitsj wrote: i press the up arrow on my keyboard the spring increases in length.
And when i press down arrow it decreases.


I would say a set up more like this would be better- http://i43.tinypic.com/10wtft3.jpg
User avatar
Mystery
 
Posts: 2802
Joined: Thu Sep 03, 2009 1:16 pm
Location: Southern Australia

Re: Variable springs

Postby RicH » Sat Mar 20, 2010 4:53 am

Oh right, we have lasers nao.
Millions of voices suddenly cried out in terror, and were suddenly silenced. Something terrible has happened.
User avatar
RicH
[Funniest Person 2010]
 
Posts: 2043
Joined: Tue Sep 01, 2009 9:01 am

Re: Variable springs

Postby KarateBrot » Sat Mar 20, 2010 6:58 am

RicH wrote:Type {scene.my.var} instead of scene.my.var.
I found it had a difference.

the reason is that { } brackets tell algodoo it's a variable and not only a constant.
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: Variable springs

Postby RicH » Sat Mar 20, 2010 7:06 am

Ah, okay.
Millions of voices suddenly cried out in terror, and were suddenly silenced. Something terrible has happened.
User avatar
RicH
[Funniest Person 2010]
 
Posts: 2043
Joined: Tue Sep 01, 2009 9:01 am

Re: Variable springs

Postby maxovitsj » Sat Mar 20, 2010 1:09 pm

Adding the { } to the spring's Length box works perfectly =D
thanks

@Mystery, how do you get the laser box to look like that o.0
maxovitsj
 
Posts: 3
Joined: Fri Mar 19, 2010 10:40 pm

Re: Variable springs

Postby Mystery » Sat Mar 20, 2010 1:13 pm

I was testing the latest beta.
Its an open beta so feel free to download it.
viewtopic.php?f=24&t=1701
User avatar
Mystery
 
Posts: 2802
Joined: Thu Sep 03, 2009 1:16 pm
Location: Southern Australia


Return to Tutorials

Who is online

Users browsing this forum: No registered users and 13 guests