dcsex.converter

Units Converter.

Contents

  1. Description
  2. Functions
    1. _t.convert(value, fromunit, tounit)
    2. _t.register(unitstr, measure, frombase, tobase, tostr, overwrite)
    3. _t.tostring(value, unitstr, precision)
  3. Tables
    1. _t.measure

Description

Converts between common units of measure.

Functions

_t.convert(value, fromunit, tounit)

Parameters

value
value(number table) to convert
fromunit
a units string the value is currently in
tounit
unit of measure the convert value to

Returns

  • converted value or nil on error

_t.register(unitstr, measure, frombase, tobase, tostr, overwrite)

Parameters

unitstr
the string used to reference this unit, will be converted to uppercase. There cannot be collisions between units.
measure
one of the items in dcsex.converter.measure.
frombase
function assumes value is in a DCS base unit and converts to the target unit.
tobase
function assumes value is in this unit and it converts it to the DCS base unit.
tostr
(optional) converts to a human readable representation
overwrite
(optional) flag to overwrite any previous entry.

Returns

  • True if successful otherwise false, error msg

_t.tostring(value, unitstr, precision)

Parameters

value
the value to display
unitstr
unit string that was registered
precision
(optional) defines how many decimal places will be shown the default is 2.

Returns

  • string representation of value or nil

Tables

_t.measure

Parameters

[LENGTH]
[MASS]
[SPEED]
[PRESSURE]
[TEMPERATURE]
[COORDINATES]
[FREQUENCY]