If statement parse error

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

If statement parse error

Postby VFB1210 » Sun Oct 17, 2010 4:33 am

Hey all, I'm still having a lot of trouble with my if statements. It seems no matter how I write them it tells me that I have a parse error and that I am missing a period ('.') somewhere. But I can't for the life of me figure out where. The only places I should even have periods are in my variables, such as scene.my.whatever and scene.my.example, and thats where they all are, exactly where they should be! I don't get what I am doing wrong, and it is becoming extremely frustrating. The code I'm trying to use is
Code: Select all
scene.my.iftest1 = (scene.my.color1)=>{scene.my.color1 == [0.0,0.0,1.0,1.0]}?{scene.my.colortest1 = 1}:{scene.my.colortest1 = 0}



Also, yes, I have looked at the thyme tutorials at the top of the page. That is what I am doing to get my examples. :P


Thanks again!
-Jake
VFB1210
 
Posts: 5
Joined: Sun Oct 03, 2010 4:48 am

Re: If statement parse error

Postby Kilinich » Sun Oct 17, 2010 7:24 am

First, you mess with local and global variables, scene.my.blablabla cannot be used as argument.
Also, you better not use {} everywhere - it means "procedure" type.

So correct code is:
Code: Select all
scene.my.iftest1 = (color) => {color == [0.0,0.0,1.0,1.0] ? {scene.my.colortest1 = 1} : {scene.my.colortest1 = 0}}

btw - in your example "if" is unnecessary ;)
Code: Select all
scene.my.iftest1 = (color) => {scene.my.colortest1 = (color == [0.0,0.0,1.0,1.0])}
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: If statement parse error

Postby VFB1210 » Sun Oct 17, 2010 8:41 pm

Thank you very much! I finally got it to work! :clap:
VFB1210
 
Posts: 5
Joined: Sun Oct 03, 2010 4:48 am


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 6 guests