Possible bug in Thyme script
15 posts • Page 1 of 1
Possible bug in Thyme script
I wrote the following script to animate a PACMAN face which is composed of four overlayed faces, each with a mouth at different angles of being open. The script sequences the four faces by making only one face opaque, while three others are transparent. When I originally wrote the script, it would not work, but after hours of trying different things, I finally figured out that there are two statements which will not execute if there are curly brackets at the beginning and end of each statement. Here is the script that will NOT work:
{scene.my.mouthtimer == 0} ? {
{scene.my.mouthtimer = scene.my.mouthtimerseed};
{scene.my.facepointer = scene.my.facepointer + scene.my.facepointerdirection};
{scene.my.facepointer == 4} ? {scene.my.facepointerdirection = (-1)} : {};
{scene.my.facepointer == 1} ? {scene.my.facepointerdirection = 1} : {};
{scene.my.facepointer == 1} ? {scene.my.face1on} : {};
{scene.my.facepointer == 2} ? {scene.my.face2on} : {};
{scene.my.facepointer == 3} ? {scene.my.face3on} : {};
{scene.my.facepointer == 4} ? {scene.my.face4on} : {}
} : {scene.my.mouthtimer = scene.my.mouthtimer - 1}
And here is the script that DOES work:
{scene.my.mouthtimer == 0} ? {
scene.my.mouthtimer = scene.my.mouthtimerseed;
scene.my.facepointer = scene.my.facepointer + scene.my.facepointerdirection;
{scene.my.facepointer == 4} ? {scene.my.facepointerdirection = (-1)} : {};
{scene.my.facepointer == 1} ? {scene.my.facepointerdirection = 1} : {};
{scene.my.facepointer == 1} ? {scene.my.face1on} : {};
{scene.my.facepointer == 2} ? {scene.my.face2on} : {};
{scene.my.facepointer == 3} ? {scene.my.face3on} : {};
{scene.my.facepointer == 4} ? {scene.my.face4on} : {}
} : {scene.my.mouthtimer = scene.my.mouthtimer - 1}
I don't know if this is a bug, or if I simply wasn't using those curly brackets correctly in my original script. I uploaded the actual scene for you to take a look at.
Comments from the experts?
{scene.my.mouthtimer == 0} ? {
{scene.my.mouthtimer = scene.my.mouthtimerseed};
{scene.my.facepointer = scene.my.facepointer + scene.my.facepointerdirection};
{scene.my.facepointer == 4} ? {scene.my.facepointerdirection = (-1)} : {};
{scene.my.facepointer == 1} ? {scene.my.facepointerdirection = 1} : {};
{scene.my.facepointer == 1} ? {scene.my.face1on} : {};
{scene.my.facepointer == 2} ? {scene.my.face2on} : {};
{scene.my.facepointer == 3} ? {scene.my.face3on} : {};
{scene.my.facepointer == 4} ? {scene.my.face4on} : {}
} : {scene.my.mouthtimer = scene.my.mouthtimer - 1}
And here is the script that DOES work:
{scene.my.mouthtimer == 0} ? {
scene.my.mouthtimer = scene.my.mouthtimerseed;
scene.my.facepointer = scene.my.facepointer + scene.my.facepointerdirection;
{scene.my.facepointer == 4} ? {scene.my.facepointerdirection = (-1)} : {};
{scene.my.facepointer == 1} ? {scene.my.facepointerdirection = 1} : {};
{scene.my.facepointer == 1} ? {scene.my.face1on} : {};
{scene.my.facepointer == 2} ? {scene.my.face2on} : {};
{scene.my.facepointer == 3} ? {scene.my.face3on} : {};
{scene.my.facepointer == 4} ? {scene.my.face4on} : {}
} : {scene.my.mouthtimer = scene.my.mouthtimer - 1}
I don't know if this is a bug, or if I simply wasn't using those curly brackets correctly in my original script. I uploaded the actual scene for you to take a look at.
Comments from the experts?
- Attachments
-
PACMAN FACE TEST.phz- (12.55 KiB) Downloaded 46 times
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Possible bug in Thyme script
Interesting scene and interesting question.
I don't know it is intentional or not, but {} is not evaluate, in this case.
Example:
Try to consider what the code above does.
When you'd like to use local scope, use {}(); instead of {};.
By the way, I'd like you to try to post more simple case, when you post a question, if possible.
(It took me several minutes to read your question.)
Regards,
Tatt - not a developer but a Japanese translator.
I don't know it is intentional or not, but {} is not evaluate, in this case.
Example:
- Code: Select all
print ("1");
{
print ("2");
};
print ("3");
Try to consider what the code above does.
When you'd like to use local scope, use {}(); instead of {};.
- Code: Select all
print ("1");
{
temp = 2;
print (temp);
}();
print ("3");
By the way, I'd like you to try to post more simple case, when you post a question, if possible.
(It took me several minutes to read your question.)
Regards,
Tatt - not a developer but a Japanese translator.
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
-

tatt61880 - [Most Helpful Person 2010]
- Posts: 1150
- Joined: Mon Aug 31, 2009 5:45 pm
- Location: Tokyo, Japan
Re: Possible bug in Thyme script
tatt61880 wrote:Interesting scene and interesting question.
I don't know it is intentional or not, but {} is not evaluate, in this case.
Tatt - Thanks for your reply. I do not understand what you mean by "{} is not evaluated, in this case". Please explain in more detail.
Example:
- Code: Select all
print ("1");
{
print ("2");
};
print ("3");
Try to consider what the code above does.
That's very simple. It will either print "123", or it will
1
2
3
....depending on whether the compiler adds a "Linefeed/Return" after it prints each character.
When you'd like to use local scope, use {}(); instead of {};.
I do not understand what "local scope" means. Please explain.
- Code: Select all
print ("1");
{
temp = 2;
print (temp);
}();
print ("3");
I understand the simple pseudocode that you gave as an example, but I do not understand how it relates to my specific problem. I want to know why placing curly brackets around those two statements in my original code prevented those statements from executing. When I posted this problem in another thread in this forum, other people told me that it should work, and they do not see anything wrong with it. But, as I've said, it does not work, and no one, so far, has been able to explain why.
By the way, I'd like you to try to post more simple case, when you post a question, if possible.
(It took me several minutes to read your question.)
I wanted to explain what I was attempting to do when I wrote the script, and that required a detailed explanation. I apologize if my writing is verbose, but I feel that it is someimes necessary.
Regards,
Tatt - not a developer but a Japanese translator.
Regards to you also.
Xray
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Possible bug in Thyme script
Xray wrote:That's very simple. It will either print "123", or it will
1
2
3
Wrong.
You can try my code for getting true answer.
( "print" is intrinsic function so that my code isn't pseudo-code. )
If you tried my code, you'll understand why your code didn't work.
Local scope is used in various kind of programming language. (So you can google it, if you want to know.)
Xray wrote:I do not understand how it relates to my specific problem.
Never mind. I just wrote detailed explanation for whom understand local-scope. You may not need the info.
Xray wrote:By the way, I'd like you to try to post more simple case, when you post a question, if possible.
(It took me several minutes to read your question.)
I wanted to explain what I was attempting to do when I wrote the script, and that required a detailed explanation. I apologize if my writing is verbose, but I feel that it is someimes necessary.
OK, never mind.
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
-

tatt61880 - [Most Helpful Person 2010]
- Posts: 1150
- Joined: Mon Aug 31, 2009 5:45 pm
- Location: Tokyo, Japan
Re: Possible bug in Thyme script
In essense, you shouldn't use {} Unless it is really needed!
(e.g, in the IF function to seperate the TRUE and FALSE statements.)
When you was writing your IF script, The extra {} must have confused the Thyme engine, as they shouldn't really be used.
That is just the way thyme works.
(e.g, in the IF function to seperate the TRUE and FALSE statements.)
When you was writing your IF script, The extra {} must have confused the Thyme engine, as they shouldn't really be used.
That is just the way thyme works.
When asking for help, READ THE STICKIES!
- electronicboy
- Posts: 1694
- Joined: Mon Aug 31, 2009 6:18 pm
Re: Possible bug in Thyme script
tatt61880 wrote:Xray wrote:That's very simple. It will either print "123", or it will
1
2
3
Wrong.
You can try my code for getting true answer.
( "print" is intrinsic function so that my code isn't pseudo-code. )
If you tried my code, you'll understand why your code didn't work.![]()
Okay, I entered your code into the Algodoo console, and it printed:
1
3
So, it appears that the statement with the curly brackets {print "2"} was not executed.
Local scope is used in various kind of programming language. (So you can google it, if you want to know.)
Okay, I now know that local scope is the same as local variables. When I learned programming many years ago, I learned about local and global variables. I did not know that they were also called "scope". Thanks!
Okay, now that I'm beginning to understand why some of those statements get evaluated and some do not, how can I be sure next time I write Thyme script, which statements should have curly brackets around them and which ones should not have them? Is it simply a matter of how I declare my variables?
Thanks again for your help!
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Possible bug in Thyme script
Xray wrote:Okay, now that I'm beginning to understand why some of those statements get evaluated and some do not, how can I be sure next time I write Thyme script, which statements should have curly brackets around them and which ones should not have them? Is it simply a matter of how I declare my variables?
Don't use {} when {} isn't needed.
Algodoo evaluates inside of {}, only when Algodoo judged that it is needed to be evaluated.
A ? {B} : {C}
The {} is needed because when you wrote "A ? B : C", B and C will be evaluated.
As you wrote, {A} ? {B} : {C} also works because Algodoo judges that {A} is needed to be evaluated.
By the way, "scope" and "variable" isn't same term.
{ <- beginning of scope
temp1 = 1; <- variable
temp2 = 2; <- variable
} <- end of scope
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
-

tatt61880 - [Most Helpful Person 2010]
- Posts: 1150
- Joined: Mon Aug 31, 2009 5:45 pm
- Location: Tokyo, Japan
Re: Possible bug in Thyme script
tatt61880 wrote:Don't use {} when {} isn't needed.
That's the part that I'm having trouble with. Up to now, I did not know how to judge when {} are needed and when they are not needed. I think that you are saying that the {} are needed if the statement must be evaluated by Algodoo. And if that's true, then I will need to determine that at the time I write each statement.
Algodoo evaluates inside of {}, only when Algodoo judged that it is needed to be evaluated.
So, if I place {} around a statement that Algodoo judges they are not needed, then Algodoo will ignore the statement and it will not be executed. Is this true? It's too bad that Algodoo doesn't show an error message when it sees {} that are not needed. That would have saved me a lot of wasted time if it did that!
A ? {B} : {C}
The {} is needed because when you wrote "A ? B : C", B and C will be evaluated.
As you wrote, {A} ? {B} : {C} also works because Algodoo judges that {A} is needed to be evaluated.
Okay, I'm starting to understand it now.
By the way, "scope" and "variable" isn't same term.
{ <- beginning of scope
temp2 = 1; <- variable
temp2 = 2; <- variable
} <- end of scope
Okay, that makes sense. THANKS very much for all your help! So, it appears that Algodoo does not have the bug that I was concerned about, and the only bug was ME!
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Possible bug in Thyme script
Xray wrote: I think that you are saying that the {} are needed if the statement must be evaluated by Algodoo.
Nope.
Inside of {} won't be evaluated until they are needed to be evaluated.
Case. 1
A ? {B} : {C};
B will needed to be evaluated when A is true.
C will needed to be evaluated when A is false.
Case. 2
{A} ? {B} : {C};
A will always be evaluated. Because {A} is needed to be evaluated as a condition of "(condition) ? {true-case} : {false-case}".
Case. 3
{2 ^ 3}(); // returns 8
(x)=>{x ^ 3}(2);
(x, y)=>{x ^ y}(2,3);
etc.
They are evaluated as (nameless) function.
Case.4
4 * {x = 1; x + 2}
etc. etc.
Please consider why and how {x = 1; x + 2} is evaluated.
I think Algodoo has "Lazy evaluation" system.
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
-

tatt61880 - [Most Helpful Person 2010]
- Posts: 1150
- Joined: Mon Aug 31, 2009 5:45 pm
- Location: Tokyo, Japan
Re: Possible bug in Thyme script
tatt61880 wrote:Xray wrote: I think that you are saying that the {} are needed if the statement must be evaluated by Algodoo.
Nope.
Inside of {} won't be evaluated until they are needed to be evaluated.
Case. 1
A ? {B} : {C};
B will needed to be evaluated when A is true.
C will needed to be evaluated when A is false.
Case. 2
{A} ? {B} : {C};
A will always be evaluated. Because {A} is needed to be evaluated as a condition of "(condition) ? {true-case} : {false-case}".
Case. 3
{2 ^ 3}(); // returns 8
(x)=>{x ^ 3}(2);
(x, y)=>{x ^ y}(2,3);
etc.
They are evaluated as (nameless) function.
Case.4
4 * {x = 1; x + 2}
etc. etc.
Please consider why and how {x = 1; x + 2} is evaluated.
I think Algodoo has "Lazy evaluation" system.
Okay, you've given me many examples of how Algodoo evaluates different types of expressions, and I appreciate that. I also read that article about Lazy Evaluation, and that also helped me to understand how Algodoo evaluates expressions. But I was hoping that you could give me a simple list of questions that I need to ask myself concerning the use of {} whenever I enter Thyme script into a scene. For example, after I figure out the algorythm that I need for a specific operation, and I am ready to enter the code into my Algodoo scene, what questions should I ask myself when trying to determine whether or not to place {} around the various expressions? (Am I asking a valid question?
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Possible bug in Thyme script
You usally only need to place {} to for the TRUE and FALSE section of IF scripts, and when making object variables to read from scene.my codes.
Hope that small explanation is helps.
Hope that small explanation is helps.
When asking for help, READ THE STICKIES!
- electronicboy
- Posts: 1694
- Joined: Mon Aug 31, 2009 6:18 pm
Re: Possible bug in Thyme script
electronicboy wrote:You usally only need to place {} to for the TRUE and FALSE section of IF scripts, and when making object variables to read from scene.my codes.
Hope that small explanation is helps.
Yes, it helps, and I now understand the need for {} in IF scripts, but could you give me a couple of examples of the second part of your post: "....and when making object variables to read from scene.my codes."
THANKS!
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Possible bug in Thyme script
Here you go, I tried to do it using a more intresting method, but I'm too tired to think about it.
I hope this helps!
I hope this helps!
- Attachments
-
For Xray.phz- (45.61 KiB) Downloaded 39 times
When asking for help, READ THE STICKIES!
- electronicboy
- Posts: 1694
- Joined: Mon Aug 31, 2009 6:18 pm
Re: Possible bug in Thyme script
When you wrote airFrictionMult = Scene.my.x;
The Scene.my.x will be evaluated immediately. And airFrictionMult becomes constant value (for example, airFrictionMult = 1;)
After that, if Scene.my.x becomes 2, airFrictionMult won't be changed.
When you write code, airFrictionMult = {Scene.my.x};
Latest version of Algodoo evaluates the {Scene.my.x} once par step.
So I wrote that "Algodoo evaluates inside of {}, only when Algodoo judged that it is needed to be evaluated."
The Scene.my.x will be evaluated immediately. And airFrictionMult becomes constant value (for example, airFrictionMult = 1;)
After that, if Scene.my.x becomes 2, airFrictionMult won't be changed.
When you write code, airFrictionMult = {Scene.my.x};
Latest version of Algodoo evaluates the {Scene.my.x} once par step.
So I wrote that "Algodoo evaluates inside of {}, only when Algodoo judged that it is needed to be evaluated."
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
-

tatt61880 - [Most Helpful Person 2010]
- Posts: 1150
- Joined: Mon Aug 31, 2009 5:45 pm
- Location: Tokyo, Japan
Re: Possible bug in Thyme script
electronicboy and tatt -- I played with both examples with and without {}, and I see that without {}, in each case the expression gets evaluated only once, and the parameter (either AirFrictionMult or Text) ends up with a fixed value. But if I place {} around the expression, then the parameter (either AirFrictionMult or Text) gets updated continuously as the scene is running. So, it seems in those cases, the decision to use or not use {} is based on whether I want Algodoo to evaluate the expression only once or continuously. I'm sure there are more criteria than just that when determining whether to use {}. Would it be too much trouble for someone to make a list of examples that show when to use {} and when not to use {}?
Thanks to both of you!!!
EDIT: Actually, guys, I think you've given me enough examples already, and I now have a much better understanding of how Algodoo evaluates certain expressions. You need not devote any more of your valuable time to this unless you feel that you have more to contribute that would help me better understand this subject.
I'm sure that many other people reading this thread will learn from it too.
THANKS VERY MUCH FOR ALL OF YOUR HELP!

Thanks to both of you!!!
EDIT: Actually, guys, I think you've given me enough examples already, and I now have a much better understanding of how Algodoo evaluates certain expressions. You need not devote any more of your valuable time to this unless you feel that you have more to contribute that would help me better understand this subject.
I'm sure that many other people reading this thread will learn from it too.
THANKS VERY MUCH FOR ALL OF YOUR HELP!
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
15 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 5 guests



