Script for spring

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

Script for spring

Postby Bartimans » Sat Oct 09, 2010 5:04 pm

Hey :D ,

I just want a simple script to change the power of the spring. From 10000 N/m to 0 N/m. And one from 0 N/m to 10000 N/m. Anybody?
Thanks!

Bartimans
Bartimans
 
Posts: 17
Joined: Sat Jul 17, 2010 7:34 pm

Re: Script for spring

Postby Rrobba » Sat Oct 09, 2010 7:58 pm

When do you want the spring's strength to change? After a certain amount of time? When a certain object collides with another object?
Image
I don't suffer from insanity. I enjoy every minute of it.
User avatar
Rrobba
[Best Sig 2010]
 
Posts: 1480
Joined: Mon Aug 31, 2009 6:01 pm
Location: Gibraltar

Re: Script for spring

Postby Kilinich » Sat Oct 09, 2010 8:14 pm

First you need to define custom variable scene.my.x (type in console scene.my.x = 0).
Then set spring strength in script menu to "{scene.my.x}".
Now you can control spring via scene.my.x variable.
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: Script for spring

Postby Bartimans » Sat Oct 09, 2010 8:29 pm

Thanks. It works :thumbup:
Bartimans
 
Posts: 17
Joined: Sat Jul 17, 2010 7:34 pm

Re: Script for spring

Postby Bartimans » Mon Oct 11, 2010 4:48 pm

Ehm, other question. What is the script for springs that it goes every time that the i push ( say 1 or something) go up with 1. I have {scene.my.x = +1} and on the spring i have {scene.my.x}, it works one time, after that not more. So?? :crazy: (Sorry for my English)
Bartimans
 
Posts: 17
Joined: Sat Jul 17, 2010 7:34 pm

Re: Script for spring

Postby Kilinich » Mon Oct 11, 2010 6:35 pm

Bartimans wrote:Ehm, other question. What is the script for springs that it goes every time that the i push ( say 1 or something) go up with 1. I have {scene.my.x = +1} and on the spring i have {scene.my.x}, it works one time, after that not more. So?? :crazy: (Sorry for my English)


scene.my.x = scene.my.x+1

?
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: Script for spring

Postby Bartimans » Mon Oct 11, 2010 7:01 pm

Kilinich wrote:
Bartimans wrote:Ehm, other question. What is the script for springs that it goes every time that the i push ( say 1 or something) go up with 1. I have {scene.my.x = +1} and on the spring i have {scene.my.x}, it works one time, after that not more. So?? :crazy: (Sorry for my English)


scene.my.x = scene.my.x+1

?

Yeah i have that. When i add the script on the spring {scene.my.x} it colors white and don't change??
Bartimans
 
Posts: 17
Joined: Sat Jul 17, 2010 7:34 pm

Re: Script for spring

Postby Chronos » Tue Oct 12, 2010 3:45 am

Sounds like you put the code in the color box instead of the length box. You sure you put it in the right one?

Also, yeah, scene.my.x = +1 doesn't work. You need scene.my.x = scene.my.x + 1.
TheWinkits wrote:They both looks of cuking amazing
User avatar
Chronos
[Most Active Member 2010]
 
Posts: 4457
Joined: Mon Aug 31, 2009 6:00 pm
Location: Californania

Re: Script for spring

Postby Bartimans » Tue Oct 12, 2010 3:29 pm

i have now on the circle "(e)=>{scene.my.x = scene.my.x + 1}" on the spring i want to add the cript {scene.my.x}. But the code collors white. Not the spring (sorry for the miss understand). It means it's isn't good, the script.
Bartimans
 
Posts: 17
Joined: Sat Jul 17, 2010 7:34 pm

Re: Script for spring

Postby Chronos » Tue Oct 12, 2010 4:00 pm

Have you defined scene.my.x in the console yet?
TheWinkits wrote:They both looks of cuking amazing
User avatar
Chronos
[Most Active Member 2010]
 
Posts: 4457
Joined: Mon Aug 31, 2009 6:00 pm
Location: Californania

Re: Script for spring

Postby Bartimans » Tue Oct 12, 2010 4:16 pm

I have made a simple scene. http://www24.zippyshare.com/v/7254773/file.html. The bleu springs i want to let "grow". The green are just for fun. So don't know what i do wrong?
Bartimans
 
Posts: 17
Joined: Sat Jul 17, 2010 7:34 pm

Re: Script for spring

Postby Chronos » Tue Oct 12, 2010 5:17 pm

Chronos wrote:Have you defined scene.my.x in the console yet?
TheWinkits wrote:They both looks of cuking amazing
User avatar
Chronos
[Most Active Member 2010]
 
Posts: 4457
Joined: Mon Aug 31, 2009 6:00 pm
Location: Californania

Re: Script for spring

Postby Bartimans » Tue Oct 12, 2010 5:29 pm

Chronos wrote:
Chronos wrote:Have you defined scene.my.x in the console yet?

uhm... When you tell me what a console is that i can tell you of i did. :oops:
Bartimans
 
Posts: 17
Joined: Sat Jul 17, 2010 7:34 pm

Re: Script for spring

Postby Chronos » Tue Oct 12, 2010 6:12 pm

Press the tilde key (~), type scene.my.x = 1, then press enter. After that, enter your codes in the object and spring again and it should work.
TheWinkits wrote:They both looks of cuking amazing
User avatar
Chronos
[Most Active Member 2010]
 
Posts: 4457
Joined: Mon Aug 31, 2009 6:00 pm
Location: Californania

Re: Script for spring

Postby Bartimans » Tue Oct 12, 2010 6:38 pm

Jep it work. Thanks again :thumbup:
Bartimans
 
Posts: 17
Joined: Sat Jul 17, 2010 7:34 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 2 guests