Oolite always gives the number in meters, so its just one line in script to convert that to any units eg:-
if (missionVariables.random_station_names_units == "Kilometres") var unitBase = 1000;
So I just need to know how many meters there are in your units to add that as a line.
I'd rather like to convert my relevant oxp's to display distances in La Serenissima's (old Venetian) Cavezzi
(Telescope, Market Inquirer (F4 In-system distances screen), Compass on the Vimana HUD, etc.).
(1 cavezzo = 6 piedi = 2.08641 French metric units)
1) What do I need to insert into the oxp's?
2) Does it matter where in the .js file I bung it? Speculative - just yes/no wanted at this stage of the game:
3) Is it possible to create an override .oxp doing it for everything? And maybe include LittleBear's full range of units (Miles, OU's, Torans etc.)
4) Is it possible to forcibly change units for a player to miles in the Digebiti system and to cavezzi at Tibecea?
The game's code always returns distances in game meters. So you just need to know how many meters are in the unit you want to convert the number returned in meters into. There are 2.08641 meters in 1 Cavezzi, 1609.34 meters in a mile and (obviously) 1,000 meters in a KM.
As the Almanac uses user-selectable units, the denominator number used is stored as a variable (depending on which units are selected).
var distranceinUnits = (player.ship.position.distanceTo(target) - target.collisionRadius)/missionVariables.random_station_names_mfd_unitBase;
If you look at Telescope's code and search for a /1000 and change that to /2.08641 then it will convert to Cavezzi instead of KM. You'd probabley also need to search for a " km" and replace that text with a " CV" so the CV appears after the number instead of a km.
Last edited by LittleBear on Fri May 13, 2022 5:25 pm, edited 1 time in total.
OXPS : The Assassins Guild, Asteroid Storm, The Bank of the Black Monks, Random Hits, The Galactic Almanac, Renegade Pirates can be downloaded from the Elite Wiki here.
The game's code always returns distances in game meters. So you just need to know how many meters are in the unit you want to convert the number returned in meters into. There are 2.08641 meters in 1 Cavezzi, 1609.34 meters in a mile and (obviously) 1,000 meters in a KM.
As the Almanac uses user-selectable units, the denominator used is stored as a variable (depending on which units are selected).
var distranceinUnits = (player.ship.position.distanceTo(target) - target.collisionRadius)/missionVariables.random_station_names_mfd_unitBase;
If you look at Telescope's code and search for a /1000 and change that to /2.08641 then it will convert to Cavezzi instead of KM. You'd probabley also need to search for a " km" and replace that text with a " CV" so the CV appears after the number instead of a km.
Unfortunately, the Galactic Banks refuse to deal with fiddling small change.
OXPS : The Assassins Guild, Asteroid Storm, The Bank of the Black Monks, Random Hits, The Galactic Almanac, Renegade Pirates can be downloaded from the Elite Wiki here.
So I've faffed about with the ideas above. As usual, dismal failure! All I've managed so far is to transmogrify my altitude on the Vimana HUD altimeter.
I'd rather like to convert my relevant oxp's to display distances in La Serenissima's (old Venetian) Cavezzi
(Telescope, Market Inquirer (F4 In-system distances screen), Compass on the Vimana HUD, etc.).
(1 cavezzo = 6 piedi = 2.08641 French metric units)
Why would you ever want to leave the metric system?
Only those who exited a brexit can think along such lines.