If Structures question?

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

If Structures question?

Postby 9373 » Fri Aug 20, 2010 9:43 pm

Hi,

I am makeing a computer that is based off thyme but i am haveing problems with my if structures. Every time i try to make one it doesint work. I have tryed to follow the thyme tutorial but i still cant get it to work. Here is the code
Code: Select all
(e)=>{e.other.color = [1.0, 0.0, 0.0, 1.0] ? {e.this.text = e.other.text; e.this.color = e.other.color} : {e.this.color = [0.0, 0.0, 0.0, 1.0]}}
I am trying to make it so that a blocks can do a true fasle action based on the color of a block.

For example, block 1 is the receving block, block 2 is blue and block 3 is red.
Block 1 is scripted with a true false script that only activates when the block it is hit with is blue
Block 1 hits block 3 but it does nothing, but block 1 hits block 2 and it copys the color and text to its self.

What is wrong with my script?
Thanks,
9373
9373
 
Posts: 12
Joined: Tue Oct 27, 2009 10:54 pm

Re: If Structures question?

Postby Mystery » Sat Aug 21, 2010 4:58 am

Code: Select all
(e)=>{{e.other.color == [1.0, 0.0, 0.0, 1.0]} ? {e.this.text = e.other.text; e.this.color = e.other.color} : {e.this.color = [0.0, 0.0, 0.0, 1.0]}}

Fix'd

So in English it now reads:
If other color is [1, 0, 0, 1] then change this text to the other text and this color to the other color. Otherwise change this color to [0, 0, 0, 1]

Your mistake was forgetting the double plus sign "==" for the first section.
In the "If" stage the rules go like this
== If equal to
< If less then
> If more then
>= If more then or equal to
<= If less then or equal to
!= If not equal to

Simple guide to remember
{If}?{Then}:{Else}
User avatar
Mystery
 
Posts: 2802
Joined: Thu Sep 03, 2009 1:16 pm
Location: Southern Australia

Re: If Structures question?

Postby 9373 » Sat Aug 21, 2010 7:32 am

Thanks alot! :thumbup:
9373
 
Posts: 12
Joined: Tue Oct 27, 2009 10:54 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 3 guests