[LIB] ms Timer and FPS

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

Post Reply
User avatar
Posts: 12437
Joined: Fri, 13. Jan 06, 17:39

[LIB] ms Timer and FPS

Post by Gazz » Fri, 4. Dec 09, 15:38

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

Code: Select all

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.

Image 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.

Post Reply

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”