Log inRegister
[LIB] ms Timer and FPS
Post new topic Reply to topic
View previous topic :: View next topic
Author Message

Joined: 13 Jan 2006
Posts: 12423 on topic
Location: Bavaria
Thank you for registering your game
PostPosted: Fri, 4. Dec 09, 15:38    Post subject: [LIB] ms Timer and FPS Reply with quote Print

Everyone knows that scripts in TC have no way to measure times < 1 sec.

I disagreed.

This script (it's just one file) automatically installs / updates and starts operating immediately.

Your scripts can now
001   $ms.Timer = get global variable: name='GZ.MST'

(of course, get global var only needs to be done once per script)

017   $Time.ms = $ms.Timer[4]
018   $Time.Carryover = $ms.Timer[5]
019   $FPS = $ms.Timer[6]

contains the regular Playtime expressed in milliseconds - with one catch.
Due to the integer precision it can only display about 23 days of continuous game time.

This fixes the precision issue by counting up whenever $Time.ms is "full".

So whenever $Time.Carryover changes,
$Time.ms is also reset to zero.

I recommend completely resetting your script's internal timing whenever $Time.Carryover changes.
For split-second timing applications it can not possibly matter if there is a little hickup roughly every 23 game days.

Current frames per second.
Note that these are script frames and scripts have a lower priority than graphics.
Script FPS = Graphics FPS in high FPS situations (maybe 35+) but when X3 has to work hard, it's load balancing lets all scripts skip frames to keep the graphics sorta smooth.

When you fire up SETA you may still have 8 graphics FPS but only 1 script FPS.

That is not a problem, though. Since you'll be using this for timing scripts it would be pointless knowing the graphics FPS that have no bearing on the timer that your script is using.
If the library reports 10 FPS then your script is getting a max of 10 FPS.

The first line of the script is a commented out debug flag.
Activate it (and restart the script) and you get a running display of FPS / Playtime as a subtitle.

Download (ZIP)

My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic Reply to topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum
Control Panel
Login Data
The time now is Wed, 26. Sep 18, 10:18

All times are GMT + 2 Hours

[ Disclaimer / Impressum ] | [ Privacy Policy / Datenschutz ]

Board Security

Copyright © EGOSOFT 1989-2018
Powered by phpBB © 2001, 2005 phpBB Group
Template created by Avatar & BurnIt!
Debug: page generation = 0.06653 seconds, sql queries = 15