[Tutorial]Thyme Tutorial - With explanations at every step

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

Re: [Tutorial]Thyme Tutorial - With explanations at every step

Postby Chronos » Mon Sep 05, 2011 9:41 pm

cocolover76 wrote:Is there a command that crashes algodoo, and only works in algodoo? (i wanna make a scene for people that like phun)

Go the fuck away. Seriously. We already dealt with that shit when Algodoo was new, we're not doing it again, understood? That's a banable offense.
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: [Tutorial]Thyme Tutorial - With explanations at every step

Postby TC42 » Mon Sep 05, 2011 10:47 pm

There is system.exit, I think, and there is also a way to tell what they are using to open the scene, but I'm not too sure on that. Or something like that. But you'll be banned anyway if you try that. Chronos already beat me to the yelling part.
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_

Re: [Tutorial]Thyme Tutorial - With explanations at every step

Postby electronicboy » Mon Sep 05, 2011 11:13 pm

Chronos wrote:
cocolover76 wrote:Is there a command that crashes algodoo, and only works in algodoo? (i wanna make a scene for people that like phun)

Go the fuck away. Seriously. We already dealt with that shit when Algodoo was new, we're not doing it again, understood? That's a banable offense.


yeah... Posting something like that on algobox WILL get you ATLEAST one weeks ban....
Ask Mr. crash about his scene....
When asking for help, READ THE STICKIES!
electronicboy
 
Posts: 1693
Joined: Mon Aug 31, 2009 6:18 pm

Re: [Tutorial]Thyme Tutorial - With explanations at every step

Postby cocolover76 » Thu Sep 08, 2011 1:14 am

electronicboy wrote:
Chronos wrote:
cocolover76 wrote:Is there a command that crashes algodoo, and only works in algodoo? (i wanna make a scene for people that like phun)

Go the fuck away. Seriously. We already dealt with that shit when Algodoo was new, we're not doing it again, understood? That's a banable offense.


yeah... Posting something like that on algobox WILL get you ATLEAST one weeks ban....
Ask Mr. crash about his scene....


Can I make it make the scene blank if its algodoo?
If not, spawn a big square?
Anything?
Make fireworks disactivate?
Move everything underground?
Anything?
Change text in a box?
FOR GODS SAKE, WHAT CAN I DO TO DISACTIVATE THE SCENE AND IT LETS ME PUT ON ALGOBOX?
IF I CANT MAKE A PHUN MEMORIAL, I WILL CLOSE ALL OF MY ACCOUNTS, AND THAT IS 1 LESS
MEMBER FOR YOU.
Image
cocolover76
 
Posts: 135
Joined: Sun May 08, 2011 10:49 pm

Re: [Tutorial]Thyme Tutorial - With explanations at every step

Postby Chronos » Thu Sep 08, 2011 1:30 am

cocolover76 wrote:IF I CANT MAKE A PHUN MEMORIAL, I WILL CLOSE ALL OF MY ACCOUNTS, AND THAT IS 1 LESS
MEMBER FOR YOU.

Bye bye! :)
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: [Tutorial]Thyme Tutorial - With explanations at every step

Postby InfinityPlayer » Fri Nov 04, 2011 7:39 pm

I haven't read all the comments, but i'd like to know if there's an updated version of this lot for the new version of Algodoo, v2.0?
I am still learning, not an expert yet. I'm just here to have some phun.
InfinityPlayer
 
Posts: 40
Joined: Thu Dec 09, 2010 7:57 pm

Re: [Tutorial]Thyme Tutorial - With explanations at every step

Postby martixy » Tue May 01, 2012 3:17 am

Hm... er... that's one of the most "unique" tutorials I've seen in a long time(and I don't mean this in a nice way either).

Is there a normal tutorial somewhere around here(you know, something more like "this is used to achieve that and works like this", not "type this, then that and you're done, moving on...")?
martixy
 
Posts: 5
Joined: Thu Aug 26, 2010 2:49 am

Re: [Tutorial]Thyme Tutorial - With explanations at every step

Postby tadietz » Fri Jun 29, 2012 11:22 pm

Newbie question here - I am building a sim where I want to gradually increase the motorSpeed of two motors in a synchronous manner on two wheels within my scene. I managed to sort of crudely do this by just selecting the two motors, bringing up the options menu on the selected motors, and gradually moving the slider to the right to increase motor speed on both selected motors at once.

This gives me roughly the capability I desire, but I would like to have the motors speed up (and also possibly slow down) more smoothly than I seem to be able to control in the above manner, so I thought a Thyme script would do the trick.

Unfortunately, though I have done a fair bit of scripting and programming in other environments, I cannot seem to find sufficient documentation to help me locate the names of the two motor objects I want to control. Also, the discussions in the tutorial regarding using scripting menus for setting values on individual objects don't seem to fit what I want to do.

Any help is appreciated. Wonderful tool, by the way. I am really glad I found Algodoo - it is helping me greatly in thinking out some concepts in an invention I want to check out some different configurations and parameters of before physically constructing it.
tadietz
 
Posts: 9
Joined: Thu Jun 21, 2012 4:00 pm

Re: [Tutorial]Thyme Tutorial - With explanations at every step

Postby Nxdt » Sat Jun 30, 2012 4:48 pm

Its quite easy;

Create a varible in the console, use ~/` key to open.
Write,
scene.my.motorspeed = 0

Press enter.

Then make two lasers, one to increase speed, one to decrease. Set them so you can activate with a key press.

In the scripting menu, onlaserhit section. This code increases or decreases the value.
For the Increasing laser
Code: Select all
(e)=>{scene.my.motorspeed = scene.my.motorspeed + 0.5}

For the Decreasing laser
Code: Select all
(e)=>{scene.my.motorspeed = scene.my.motorspeed - 0.5}


Then in the motors scripting menu, under motor speed write
Code: Select all
{scene.my.motorspeed}

This links the motors rpm to the varaible scene.my.motorspeed.

Here is an example scene.

Smoothspeed.phz
(11.39 KiB) Downloaded 97 times
User avatar
Nxdt
 
Posts: 1019
Joined: Mon Aug 31, 2009 6:32 pm
Location: Scotland!

Re: [Tutorial]Thyme Tutorial - With explanations at every step

Postby tadietz » Mon Jul 02, 2012 6:20 pm

Nxdt,

Thanks, your approach worked well for what I wanted to do.

Now, however, I may need to 'upgrade' to the educational version because I really want to chart a lot of the data coming out of my sim, and the version I bought (very reasonable for what it does) does not seem to provide for that, unless one can do charts with Thyme without having the educational version? That'd be nice...
tadietz
 
Posts: 9
Joined: Thu Jun 21, 2012 4:00 pm

Re: [Tutorial]Thyme Tutorial - With explanations at every step

Postby tadietz » Fri Jul 27, 2012 11:48 pm

Next question - is there a way to write a script to automatically increase motor speed to match the angular velocity of another object, say a circle/disk rolling down an angled ramp or something similar?

Also, can you find the angle of the tangent line on a circle/disk at a given point, say the point of contact with another object?
tadietz
 
Posts: 9
Joined: Thu Jun 21, 2012 4:00 pm

Re: [Tutorial]Thyme Tutorial - With explanations at every step

Postby TC42 » Sat Jul 28, 2012 3:07 am

tadietz wrote:Next question - is there a way to write a script to automatically increase motor speed to match the angular velocity of another object, say a circle/disk rolling down an angled ramp or something similar?

Also, can you find the angle of the tangent line on a circle/disk at a given point, say the point of contact with another object?


Yes, there is a way to write a script like that, but how you write it will be entirely dependent on how obsessive you are about it being accurate. You will _probably_ want a PID controller, but I only know how to write a PI controller, and I've never _exactly_ done that before.

And yes, you _can_ do almost any trig you wish since algodoo is based off of coord plane. You just have to have enough data to complete the calculation.
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_

Re: [Tutorial]Thyme Tutorial - With explanations at every step

Postby Nxdt » Sun Jul 29, 2012 2:00 am

What you suggested is entirely possible, you can read almost all information about an object with thyme, including normals and points of contact. You just need a big equation to work it all out.

The point of contact is e.pos and the normal of this contact is e.normal. You can read other stuff using readable, but I have forgotten how to do that.
User avatar
Nxdt
 
Posts: 1019
Joined: Mon Aug 31, 2009 6:32 pm
Location: Scotland!

Re: [Tutorial]Thyme Tutorial - With explanations at every step

Postby leroidangleterre » Fri Sep 06, 2013 5:54 pm

Hello everyone,

I'm quite new at scripting with Thyme, and I have a problem with the syntax. I am having fun with the "onCollide" function (which is cool, I also built a water source), and I would like to create sort of a "speed controller"; it would be an object (like a box, or a circle), and whatever object that would hit that box would have its speed set to a specific value.

My question is: how do you change the speed of the other object when a collision occurs?

I tried this:
Scene.addBox {
<code about the size, the color or the position of the box>
onCollide = (e)=>{e.other.vel:=[1, 0];}
};
and it doesn't work.

Obviously, I something is wrong in my code but the object is still loaded and collides with other objects (so it means the computer understands what I tell him to do, except it is not what I want it to do...)

If you know how to do that, it would be great! Thanks!
leroidangleterre
 
Posts: 12
Joined: Fri Sep 06, 2013 5:27 pm

Re: [Tutorial]Thyme Tutorial - With explanations at every step

Postby Someone Else » Mon Nov 25, 2013 6:21 am

leroidangleterre wrote:Hello everyone,

I'm quite new at scripting with Thyme, and I have a problem with the syntax. I am having fun with the "onCollide" function (which is cool, I also built a water source), and I would like to create sort of a "speed controller"; it would be an object (like a box, or a circle), and whatever object that would hit that box would have its speed set to a specific value.

My question is: how do you change the speed of the other object when a collision occurs?

I tried this:
Scene.addBox {
<code about the size, the color or the position of the box>
onCollide = (e)=>{e.other.vel:=[1, 0];}
};
and it doesn't work.

Obviously, I something is wrong in my code but the object is still loaded and collides with other objects (so it means the computer understands what I tell him to do, except it is not what I want it to do...)

If you know how to do that, it would be great! Thanks!


I think you're on the right track- try swapping the "=" and ":=".
Also, Scene.addBox is a function, so you need parentheses around its argument, which is itself surrounded by curly braces.

Thus, this untested code
Code: Select all
Scene.addBox({
    //commented code about the size, the color or the position of the box
    onCollide := (e)=>{e.other.vel = [1, 0]} //You also don't need a semicolon immediately before a right brace
})

should spawn a box that sets the velocity of anything that touches it to 1 meter per second to the right. Try increasing the values in the array- you may not even see this happen.

Thyme has two assignment operators, "=" and ":=". Generally, they work the same, but you have found one instance where they don't.

":=" is normally used for creating variables- it will always create a variable if one of the appropriate name doesn't exist in the exact location where the := exists- so, in spawning scripts, it is used to set inintial values of variables in the object being spawned.

"=" works similarly, but (to my experience- correct me if I'm wrong) seems to look around a little before creating variables. This is no problem when the variable already exists, but if you try to use "=" to set a value in an object in the process of being spawned, it will instead go to whatever's doing the spawning.

Thus, your script will not actually set any properties of the box being spawned, but instead mess with the thing spawning it.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: [Tutorial]Thyme Tutorial - With explanations at every step

Postby stephane.savanah » Thu Feb 20, 2014 5:52 am

Hi Grady,
Thanks for your hard work on the tutorial. I wonder if you add/clarify some information in it:
> How to Read and Write to files (I got some info already from Kilinich and e-boy on separate post, but it would be good to add to the Tute)
> Clarify how to save and edit code. I know how to pull down the console (~) and write code there, but I don't understand how to edit that code later. (Sorry if it's obvious and I missed it!)
Cheers...
stephane.savanah
 
Posts: 11
Joined: Tue Feb 11, 2014 8:20 am

Re: [Tutorial]Thyme Tutorial - With explanations at every step

Postby Someone Else » Wed Mar 26, 2014 5:39 am

stephane.savanah wrote:Hi Grady,
Thanks for your hard work on the tutorial. I wonder if you add/clarify some information in it:
> How to Read and Write to files (I got some info already from Kilinich and e-boy on separate post, but it would be good to add to the Tute)
> Clarify how to save and edit code. I know how to pull down the console (~) and write code there, but I don't understand how to edit that code later. (Sorry if it's obvious and I missed it!)
Cheers...

As for messing with files, I can't help you there- I didn't even know Thyme could do that! Seems that I haven't touched Algodoo in entirely too long.
As for saving code, well, that's a little easier. So long as you prefix all your global variable names (i.e. those that you type into the console) with "scene.my." (i.e. scene.my.variable, scene.my.function), they will be saved with the scene. So, in a scene where you've defined "scene.my.variable = 5", you can come back at any time and type "scene.my.variable = 6" to change it.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: [Tutorial]Thyme Tutorial - With explanations at every step

Postby mitko99 » Tue Apr 08, 2014 7:21 pm

Very useful man! Thank you!
User avatar
mitko99
 
Posts: 92
Joined: Wed Jan 27, 2010 6:24 pm
Location: Varna,Bulgaria

Previous

Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 1 guest

cron