Getting the Speed of an object

The place to discuss scripting and game modifications for X²: The Threat.

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

holo_doctor
Posts: 860
Joined: Fri, 26. Mar 04, 12:20
x3tc

Getting the Speed of an object

Post by holo_doctor » Mon, 20. Sep 04, 13:54

Ive looked and LOOKED and LOOKED :!: some more though all the commands an can not find a set object or get object speed so im trying to write a little libary file. I can get it pritty acurate but it can be out by 3m/s to 15m/s. 2 or 3 i can tolerate but more than that and the script im trying to right is not going to work well.

Here is what ive done so far quite simple :D :

Code: Select all

005   set script priority to 1000
006   $start = $object -> get position as array
007 @ = wait 1000 ms
008   $speed = $object -> get distance to: position array=$start
009   write to player logbook $speed
010   return $speed
I was thinking of incresing the sampling over a couple of seconds to get an average but i really need this scrip to run as quickly as posible. (even tried 1/2 to 1/10 of a sec sampling but the results just grew in inacuracy) If the script would tick to its timming corectly it be good but its looks liek its not alwasy 1 sec. going 1009 in peg comming up a 998 or 1050.

Anyone sugest a way to increase the acuracy or if there is a command to get a ship current speed and I've just missed it :roll:
i7-930 2.8Ghz quad core
6gig DDR3-1600 3 channel Ram
Nvida GTX470
64gig SSD / 1TB Hitachi

User avatar
moggy2
Posts: 5505
Joined: Wed, 6. Nov 02, 20:31
x3ap

Post by moggy2 » Mon, 20. Sep 04, 15:07

The only speed command is this

Code: Select all

<RetVar/IF> <RefObj> get max speed
It returns the max speed of the ship, but in internal units so you need to divide by 222 to get m/s

Could you not use this? The only time it's moving slower than max speed is if it's following or being followed by a slower ship. At this time you could check the speed of the ships in it's group to find the likely speed.

akm
Posts: 17
Joined: Sun, 19. Sep 04, 10:33
x2

Post by akm » Mon, 20. Sep 04, 18:14

moggy2 wrote:The only speed command is this

Code: Select all

<RetVar/IF> <RefObj> get max speed
It returns the max speed of the ship, but in internal units so you need to divide by 222 to get m/s

Could you not use this? The only time it's moving slower than max speed is if it's following or being followed by a slower ship. At this time you could check the speed of the ships in it's group to find the likely speed.
Good advice! You will never have delay exactly 1sec from the command "wait 1000 ms". And the error can be pretty huge when you fly with SETA 10x and the time speeds up in the game (your 1 sec will become likely 2 sec)

Just want to warn that

Code: Select all

<RetVar/IF> <RefObj> get max speed
doesn't actually return the max speed of the ship :P
There is a bug in it. It actually returns the max speed of same ship but with 0 engine tuning upgrades installed. Thus in order to find out the real max speed of the ship you will need this:

Code: Select all

$speed = $object -> get max speed
$engine.upgrades = $object -> get amount of ware Engine Tuning in cargo bay
$speed = $speed * ( 10 + $engine.upgrades ) / 10
And that would be max speed in internal units.

holo_doctor
Posts: 860
Joined: Fri, 26. Mar 04, 12:20
x3tc

Post by holo_doctor » Mon, 20. Sep 04, 23:09

thanks i aware of the but that 1000ms not always as such but for this script im tryign to make i really need the current speed of the ship.

Damint egosoft you leave out the most simple of commands at time.

for future refrence I needed thes commands

REFOBJ -> get current Speed

and

REFOBJ -> get throttle Speed

Yet again another script idea thrown out the window cuse of lack of commands. Ow well back to drawing board
i7-930 2.8Ghz quad core
6gig DDR3-1600 3 channel Ram
Nvida GTX470
64gig SSD / 1TB Hitachi

Return to “X²: The Threat - Scripts and Modding”