Script help! Please help, my scripts become values?

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

Script help! Please help, my scripts become values?

Postby Rrobba » Sun Dec 20, 2009 3:06 pm

Ok, what happens is my scripts become the values that they are worth. Exampe:

I type 'scene.my.speed = 0.0' in the console.

Then I type '(e)=>{scene.my.speed = 2.5}' in the on-collide section of a polygon.

Then, I make a vehicle, and type 'scene.my.speed' in the motor speed section of the hinge, so that the speed of the vehicle is equal to the value of the variable 'scene.my.speed'.

So, the speed of the vehicle is 0.0 at the start, and should become 2.5 when the polygon collides. But this doesn't happen. Instead, when I type 'scene.my.speed' in the motor speed section, the motor speed becomes 0.0, and is no longer scene.my.speed, so it doesn't change to 2.5 when the polygon collides. Why does this happen? And more importantly, how can I fix this?
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 help! Please help, my scripts become values?

Postby KarateBrot » Sun Dec 20, 2009 3:08 pm

Put the code into { } brackets. they tell that your variable is a variable and not only a constant.

Code: Select all
{scene.my.speed}
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: Script help! Please help, my scripts become values?

Postby Rrobba » Sun Dec 20, 2009 6:05 pm

KarateBrot wrote:Put the code into { } brackets. they tell that your variable is a variable and not only a constant.

Code: Select all
{scene.my.speed}


Thanks!
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 help! Please help, my scripts become values?

Postby KarateBrot » Sun Dec 20, 2009 11:39 pm

No problem :thumbup:

You can also do this with variables so they update themselves without a need of onCollide or Lasers. For example
Code: Select all
scene.my.difference = { 3 - scene.my.number }

If you change scene.my.number scene.my.difference changes automatically according to scene.my.number. if scene.my.number is 10 scene.my.difference will be automatically -7
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 1 guest

cron