Quantcast

[Squeakland News] How to do timing in Etoys?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Squeakland News] How to do timing in Etoys?

Rita
I just got this question from my students and I thought there might be others with similar interests. So how can I control sequences of actions over time? Say, I want to use speech bubbles to tell a story. I have a number of sentences to show, one after another, and I want to let some time pass between them to give the reader time to read. How can I do that?

Well, I can build a timer and check the time to trigger actions when a certain time is reached. How can I build a timer?

First of all, you need a variable to count time steps. Open the viewer for your object. Create a variable by clicking the "v" - symbol in the top row of the viewer and give your variable a name. I choose "seconds". The default type is "Number", which is fine and 0 decimals places are perfect as well.


Now open a new empty script and drag the tiles to assign a new value to your variable into the script. Change the operation to "increase by" and the number to "1". Make sure the value of your variable is "0" at the start! Name the script "timer".


You do know already that the script, once started, will be executed repeatedly until it is being stopped, right? Do you also know how fast or how slowly this happens? You can see this when you click on the watch in the top row of the scriptor and hold the mouse button down. And you can also change it there! By default, it will be executed 8 times per second. Change this into once per second!



When you now start the script, each second it will increase the value of your variable "seconds" by 1! Now you can use the value of the variable in other scripts:


Use a all-scripts-tile from the supplies to start both, your script and the timer, at the same time and watch :)

Please note: It depends on your computer and what other programs are running on it at the same time, if a second in the Etoys project will be the same as a second at a real clock. It may not be exactly the same, but probably close. It is definitely good enough to control the flow of a story, but for scientific experiments, you should use a real timer!

You can also find a tutorial to build a timer in project 6 of the book "Powerful Ideas in the classroom" by Kim Rose and B.J. Allen-Conn.



--
Von Rita am 9/04/2014 06:32:00 vorm. unter Squeakland News eingestellt
_______________________________________________
squeakland mailing list
[hidden email]
http://lists.squeakland.org/mailman/listinfo/squeakland
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Squeakland News] How to do timing in Etoys?

Ricardo Moran
Hi Rita,

I wrote about this same subject a couple of weeks ago: http://tecnodacta.com.ar/gira/2014/08/physical-etoys-tips-time-handling-part-1/. My approach is a little different, though. I like Etoys ability to represent concepts visually, and I think time is one of those concepts :)

The example I chose is about Physical Etoys because I see this question come up very often when programming robots (and also because I 
had an old video of a simple traffic light built with leds that I wanted to use), but of course it applies to any Etoys project.

I'm planning to write a follow up to that article but using the Playfield's timer instead. I think each approach has its own merits so if you don't mind I'll post a link to your blog.

Cheers,
Richo

On Thu, Sep 4, 2014 at 10:32 AM, Rita <[hidden email]> wrote:
I just got this question from my students and I thought there might be others with similar interests. So how can I control sequences of actions over time? Say, I want to use speech bubbles to tell a story. I have a number of sentences to show, one after another, and I want to let some time pass between them to give the reader time to read. How can I do that?

Well, I can build a timer and check the time to trigger actions when a certain time is reached. How can I build a timer?

First of all, you need a variable to count time steps. Open the viewer for your object. Create a variable by clicking the "v" - symbol in the top row of the viewer and give your variable a name. I choose "seconds". The default type is "Number", which is fine and 0 decimals places are perfect as well.


Now open a new empty script and drag the tiles to assign a new value to your variable into the script. Change the operation to "increase by" and the number to "1". Make sure the value of your variable is "0" at the start! Name the script "timer".


You do know already that the script, once started, will be executed repeatedly until it is being stopped, right? Do you also know how fast or how slowly this happens? You can see this when you click on the watch in the top row of the scriptor and hold the mouse button down. And you can also change it there! By default, it will be executed 8 times per second. Change this into once per second!



When you now start the script, each second it will increase the value of your variable "seconds" by 1! Now you can use the value of the variable in other scripts:


Use a all-scripts-tile from the supplies to start both, your script and the timer, at the same time and watch :)

Please note: It depends on your computer and what other programs are running on it at the same time, if a second in the Etoys project will be the same as a second at a real clock. It may not be exactly the same, but probably close. It is definitely good enough to control the flow of a story, but for scientific experiments, you should use a real timer!

You can also find a tutorial to build a timer in project 6 of the book "Powerful Ideas in the classroom" by Kim Rose and B.J. Allen-Conn.



--
Von Rita am 9/04/2014 06:32:00 vorm. unter Squeakland News eingestellt
_______________________________________________
squeakland mailing list
[hidden email]
http://lists.squeakland.org/mailman/listinfo/squeakland



_______________________________________________
squeakland mailing list
[hidden email]
http://lists.squeakland.org/mailman/listinfo/squeakland
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Squeakland News] How to do timing in Etoys?

Bert Freudenberg
On 10.09.2014, at 22:51, Ricardo Moran <[hidden email]> wrote:

> I'm planning to write a follow up to that article but using the Playfield's timer instead.

... which reminds me that we might want to expose the timer for all objects, not just playfields.

(you can already do it by replacing any timer tile's receiver)

- Bert -




_______________________________________________
squeakland mailing list
[hidden email]
http://lists.squeakland.org/mailman/listinfo/squeakland

smime.p7s (5K) Download Attachment
Loading...