Module Utils
This module contains derived utilities taken from the MIST framework, which are excellent tools to be reused in an OO environment!.
Authors:
- Grimes : Design & Programming of the MIST framework.
Contributions:
- FlightControl : Rework to OO framework
Global(s)
Global BIGSMOKEPRESET |
Global FLARECOLOR |
Global SMOKECOLOR |
Global UTILS |
Global lookup_table |
Type(s)
| Fields and Methods inherited from BIGSMOKEPRESET | Description |
|---|---|
| Fields and Methods inherited from FLARECOLOR | Description |
|---|---|
| Fields and Methods inherited from SMOKECOLOR | Description |
|---|---|
| Fields and Methods inherited from UTILS | Description |
|---|---|
|
Convert clock time from hours, minutes and seconds to seconds. |
|
|
Display clock and mission time on screen as a message to all. |
|
|
Function to infer instance of an object Examples:
|
|
|
Generate a Gaussian pseudo-random number. |
|
|
Randomize a value by a certain amount. |
|
|
From http://lua-users.org/wiki/SimpleRound use negative idp for rounding ahead of decimal place, positive for rounding after decimal place |
|
|
Convert time in seconds to hours, minutes and seconds. |
|
|
Split string at seperators. |
|
|
Calculate the cross product of two 3D vectors. |
|
|
Calculate the dot product of two vectors. |
|
|
Calculate the euclidean norm (length) of a 3D vector. |
|
Big smoke preset enum.
Field(s)
Function(s)
Field(s)
Function(s)
Field(s)
Function(s)
Utilities static class.
Field(s)
Function(s)
porting in Slmod's "safestring" basic serialize
Defined in:
UTILS
Parameter:
s
Beaufort scale: returns Beaufort number and wind description as a function of wind speed in m/s.
Defined in:
UTILS
Parameter:
speed
Defined in:
UTILS
Parameter:
Celcius
Convert clock time from hours, minutes and seconds to seconds.
Defined in:
UTILS
Parameters:
#string clock
String of clock time. E.g., "06:12:35" or "5:1:30+1". Format is (H)H:(M)M:((S)S)(+D) H=Hours, M=Minutes, S=Seconds, D=Days.
#number Seconds
Corresponds to what you cet from timer.getAbsTime() function.
Display clock and mission time on screen as a message to all.
Defined in:
UTILS
Parameter:
#number duration
Duration in seconds how long the time is displayed. Default is 5 seconds.
Defined in:
UTILS
Parameter:
feet
Test if a Vec2 is in a radius of another Vec2
Defined in:
UTILS
Parameters:
InVec2
Vec2
Radius
Test if a Vec3 is in the sphere of another Vec3
Defined in:
UTILS
Parameters:
InVec3
Vec3
Radius
Function to infer instance of an object
Examples:
UTILS.IsInstanceOf( 'some text', 'string' ) will return true
UTILS.IsInstanceOf( some_function, 'function' ) will return true
UTILS.IsInstanceOf( 10, 'number' ) will return true
UTILS.IsInstanceOf( false, 'boolean' ) will return true
UTILS.IsInstanceOf( nil, 'nil' ) will return true
UTILS.IsInstanceOf( ZONE:New( 'some zone', ZONE ) will return true
UTILS.IsInstanceOf( ZONE:New( 'some zone', 'ZONE' ) will return true
UTILS.IsInstanceOf( ZONE:New( 'some zone', 'zone' ) will return true
UTILS.IsInstanceOf( ZONE:New( 'some zone', 'BASE' ) will return true
UTILS.IsInstanceOf( ZONE:New( 'some zone', 'GROUP' ) will return false
Defined in:
UTILS
Parameters:
object
is the object to be evaluated
className
is the name of the class to evaluate (can be either a string or a Moose class)
Return value:
#boolean:
Defined in:
UTILS
Parameter:
kmph
Defined in:
UTILS
Parameter:
knots
Defined in:
UTILS
Parameter:
knots
Defined in:
UTILS
Parameter:
meters
Defined in:
UTILS
Parameter:
meters
Defined in:
UTILS
Parameter:
miph
Defined in:
UTILS
Parameter:
mps
Defined in:
UTILS
Parameter:
mps
Defined in:
UTILS
Parameter:
mps
Defined in:
UTILS
Parameter:
NM
Generate a Gaussian pseudo-random number.
Defined in:
UTILS
Parameters:
#number x0
Expectation value of distribution.
#number sigma
(Optional) Standard deviation. Default 10.
#number xmin
(Optional) Lower cut-off value.
#number xmax
(Optional) Upper cut-off value.
#number imax
(Optional) Max number of tries to get a value between xmin and xmax (if specified). Default 100.
Return value:
#number:
Gaussian random number.
Randomize a value by a certain amount.
Defined in:
UTILS
Parameters:
#number value
The value which should be randomized
#number fac
Randomization factor.
#number lower
(Optional) Lower limit of the returned value.
#number upper
(Optional) Upper limit of the returned value.
Return value:
#number:
Randomized value.
Usages:
UTILS.Randomize(100, 0.1) returns a value between 90 and 110, i.e. a plus/minus ten percent variation.UTILS.Randomize(100, 0.5, nil, 120) returns a value between 50 and 120, i.e. a plus/minus fivty percent variation with upper bound 120.
From http://lua-users.org/wiki/SimpleRound use negative idp for rounding ahead of decimal place, positive for rounding after decimal place
Defined in:
UTILS
Parameters:
num
idp
Convert time in seconds to hours, minutes and seconds.
Defined in:
UTILS
Parameter:
#number seconds
Time in seconds, e.g. from timer.getAbsTime() function.
Return value:
#string:
Time in format Hours:Minutes:Seconds+Days (HH:MM:SS+D).
Split string at seperators.
C.f. http://stackoverflow.com/questions/1426954/split-string-in-lua
Defined in:
UTILS
Parameters:
#string str
Sting to split.
#string sep
Speparator for split.
Return value:
#table:
Split text.
Defined in:
UTILS
Parameter:
angle
Defined in:
UTILS
Parameter:
angle
Calculate the cross product of two 3D vectors.
The result is a 3D vector.
Calculate the dot product of two vectors.
The result is a number.
Calculate the euclidean norm (length) of a 3D vector.
Defined in:
UTILS
Parameter:
DCS#Vec3 a
Vector in 3D with x, y, z components.
Return value:
#number:
Norm of the vector.
Here is a customized version of pairs, which I called spairs because it iterates over the table in a sorted order.
Defined in:
UTILS
Parameters:
t
order
acc: in DM: decimal point of minutes. In DMS: decimal point of seconds. position after the decimal of the least significant digit: So: 42.32 - acc of 2.
Defined in:
UTILS
Parameters:
lat
lon
acc
DMS
acc- the accuracy of each easting/northing. 0, 1, 2, 3, 4, or 5.
Defined in:
UTILS
Parameters:
MGRS
acc