How do you bind keys to adjust a spring's length?

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

How do you bind keys to adjust a spring's length?

Postby metalmaggot66 » Thu Aug 05, 2010 3:01 am

really what i'm asking what commands increase and decrease a spring's length, so i can bind some keys to those, also i want to variate the speed with with they extend, retract. Thanks ahead of time.
metalmaggot66
 
Posts: 5
Joined: Mon Oct 19, 2009 10:47 pm

Re: How do you bind keys to adjust a spring's length?

Postby Cristianol » Thu Aug 05, 2010 5:01 am

I'm not a script master, but i know a little bit. Use a variable like scene.my.springlenght=*spring lenght* then, in the spring script menu, you put in the lenght part: {scene.my.springlenght} then, you can put an oncollide mechanism like scene.my.springlenght=scene.my.springlenght+*value you want to add and scene.my.springlenght=scene.my.springlenght-*value you want to subtract
;)

*instead of springlenght you can put anything you want for variable
User avatar
Cristianol
 
Posts: 28
Joined: Mon Nov 16, 2009 7:58 pm
Location: Rio de Janeiro Brazil

Re: How do you bind keys to adjust a spring's length?

Postby metalmaggot66 » Thu Aug 05, 2010 7:37 am

See, I want it to change by a constant speed as long as im holding down the button, not incrementally.



*Edit* Nevermind, i just used onHitByLaser and a small increase value, thanks for the info
metalmaggot66
 
Posts: 5
Joined: Mon Oct 19, 2009 10:47 pm

Re: How do you bind keys to adjust a spring's length?

Postby Nxdt » Thu Aug 05, 2010 2:39 pm

make two lasers and two boxes. like this;

[laser]----------------[Box]
[laser]----------------[Box]


One laser acivates on for example the up key, the other on the down key.

Put this code in the first box's onlaserhit; "scene.my.springlength = scene.my.springlength + 0.1" Lengthens
In the second box do the same but with this code; "scene.my.springlength = scene.my.springlength - 0.1" Shortens

And in the spring length script box;"{scene.my.springlenght}"

You can add maximuin and minimum lengths using if statements; eg.
{if} ? {true} : {false}
{scene.my.springlenght =< 1} ? {scene.my.springlenght = 1} : {scene.my.springlength = scene.my.springlenght - 0.1}
User avatar
Nxdt
 
Posts: 1019
Joined: Mon Aug 31, 2009 6:32 pm
Location: Scotland!


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 3 guests