Browse Search Popular Register Upload Rules User list Login:
Search:
Script Timing Demo

Image:
screenshot of the scene

Author: Xray

Group: Default

Filesize: 56.9 kB

Date added: 2014-02-15

Rating: 5

Downloads: 453

Views: 364

Comments: 4

Ratings: 1

Times favored: 0

Made with: Algodoo v2.1.0

Tags:

Scene tag

This scene is only useful for those users who write Thyme script.

Ever since the two scripting properties, "postStep" and "update" were added to Algodoo, I never really understood the difference between them. So, I decided to run some benchmark tests to find out about their timing behavior. I learned that the rate at which script is executed in postStep is highly dependent on the simulation frequency (sim.frequency) value. The rate at which script is executed in update is fixed at the display frame rate of 60Hz.

Therefore, when the simulation frequency is set to 60Hz, the script in each property will execute at the same rate (within +/- 2 counts). When the simulation frequency is lower or higher than 60Hz, then the execution rate difference between the two will correspond to the difference between the simulation frequency and 60Hz.

This knowledge is important especially when writing script that is very dependent on the speed of execution.

Please comment with questions or corrections, or just tell me if you believe this is useful or not.
Last edited at 2014/02/15 06:29:09 by Xray
Please log in to rate this scene
edit
Similar scenes
Title: Porsche Spyder track
Rating: 5.625
Filesize: 464.1 kB
Downloads: 829
Comments: 0
Ratings: 2
Date added: 2013/12/18 04:54:57
Made with: Algodoo before v1.8.5
Rating: rated 5.6
download
Title: DIESEL demo v2
Rating: 6.8182
Filesize: 179.28 kB
Downloads: 8998
Comments: 13
Ratings: 5
Date added: 2018/11/19 00:01:36
Made with: Algodoo v2.1.0
Rating: rated 6.8
download
Title: I4 2stroke EconoEngine v5 - Functional
Rating: 6.0909
Filesize: 65.03 kB
Downloads: 2365
Comments: 22
Ratings: 5
Date added: 2013/06/01 00:19:15
Made with: Algodoo v2.0.2 Edu
Rating: rated 6.1
download
Title: Centrifugal Timing Advance
Rating: 5
Filesize: 41.92 kB
Downloads: 389
Comments: 2
Ratings: 1
Date added: 2014/09/20 22:11:37
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: Mouse Follow Tech Demo
Rating: 5
Filesize: 14.3 kB
Downloads: 622
Comments: 3
Ratings: 1
Date added: 2013/11/16 04:03:58
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: DriftCar DEMO
Rating: 5.625
Filesize: 15.45 kB
Downloads: 325
Comments: 10
Ratings: 2
Date added: 2017/02/12 13:37:36
Made with: Algodoo v2.1.0
Rating: rated 5.6
download
It can be more demonstrative, if calculate average values per second.
Last edited at 2014/02/15 12:44:11 by chemist
chemist - Thanks for your comment. I don't see how calculating the average would give any better results. I clearly show that sim.frequency affects postStep, and it does not affect update, which is the only result that I was concerned with. Before doing this benchmark test, I wasn't sure how the two properties differed in how they handle the timing of script, and now I do.
hey, Xray, how much experience do you have with loop scripts? I was thinking about possibilities of a "configurable-burst mechanism" for the upcoming NG-AR-3. I have not been able to think of any mechanisms that will allow the user to control how many shots are in a burst. HOWEVER, I was thinking about how the interrupter is moved by collision in a gun every time the bolt closes, and that collision could be used for OnCollide scripting a loop. that loop could be configured somehow to allow the disconnector to engage after a set number of repetitions in the loop script. the number of repetitions for the loop is configured with a box by inputting text into it. Am I making sense?

Anyways, for this scene, I am interested in seeing what examples this information could be used in. It sounds very interesting how the outcome of a script can change when using these variables:coolgrin:
ngphil -- Thanks for your comments. That's the beauty of Thyme script. It gives the user more tools to do some things in Algodoo that would be very difficult or impossible to do with only mechanics.

I think that what you described should be fairly easy to do in script. So, go ahead and post the weapon, and in your description, explain the details of what you would like it to do, and I will see if I can make it happen.

Concerning my demo scene, it's only purpose is to make users aware of the differences in script execution rates between postStep and update. That way, if they run into timing issues in their scenes, this information could possibly help them realize a resolution either by running their code in a different location, and/or adjusting the sim.frequency.