BIS fnc convertUnits: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Generated by BIS_fnc_exportFunctionsToWiki)
 
m (Text replacement - " |s1=[" to " |s1= [")
 
(34 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{RV|type=function


{{Function|= Comments
|game1= tkoh
____________________________________________________________________________________________
|version1= 1.00


| tkoh |= Game name
|game2= arma3
|version2= 0.50


|1.00|= Game version
|gr1= Math
____________________________________________________________________________________________


| <pre>/*
|descr= Converts values to a target system of units.


Description:
|s1= [value, from, to, mode, precision] call [[BIS_fnc_convertUnits]]
Converts values to a target system of units.


Parameter(s):
|p1= value: [[Number]] - source value
_this select 0: source value (Scalar)
_this select 1: source unit (Scalar)
0: m (meters)
1: km (kilometers)
2: ms (meters per second)
3: kmh (kilometers per hour)
4: ft (feet)
5: mi (miles)
6: fts (feet per second)
7: mph (miles per hour)
8: nm (nautical miles)
9: kts (knots)
_this select 2: destination unit (Scalar) [optional - default: detected system of units]
_this select 3: destination mode (Scalar) [optional - default: 0]
0: destination value (Scalar)
1: destination text long (String) "5 meters" e.g.
2: destination text short (String) "5 m" e.g.
_this select 4: destination precision factor (Scalar) [optional - default: 1 (uses rounding)]
-1: no changes to converted value


Returns:
|p2= from: [[Number]] - source unit. Can be one of:
converted value (Scalar or String)
* 0: m (meters)
*/
* 1: km (kilometers)
* 2: ms (meters per second)
* 3: kmh (kilometers per hour)
* 4: ft (feet)
* 5: mi (miles)
* 6: fts (feet per second)
* 7: mph (miles per hour)
* 8: nm (nautical miles)
* 9: kts (knots)


</pre><small>''(Placeholder description extracted from the function header by [[BIS_fnc_exportFunctionsToWiki]])''</small> |= Description
|p3= to: [[Number]] - (Optional, default detected system of units ''via'' [[systemOfUnits]]) destination unit. See ''from''.
____________________________________________________________________________________________


| <!-- [] call [[BIS_fnc_convertUnits]]; --> |= Syntax
|p4= mode: [[Number]] - (Optional, default 0) can be one of:
* 0: destination value (Scalar)
* 1: destination text long (String) e.g "5 meters"
* 2: destination text short (String) e.g "5 m"


|p1= |= Parameter 1
|p5= precision: [[Number]] - (Optional, default 1) destination precision factor, -1 for no precision change. '''cannot be 0'''


| |= Return value
|r1= [[Number]] or [[String]] - converted value
____________________________________________________________________________________________


|x1= <code></code> |=
|x1= <sqf>private _distString = [500, 0, 5, 1, -1] call BIS_fnc_convertUnits;</sqf>
____________________________________________________________________________________________
 
| |= See also


|seealso= [[systemOfUnits]]
}}
}}
<h3 style="display:none">Notes</h3>
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section END -->
</dl>
<h3 style="display:none">Bottom Section</h3>
[[Category:Function Group: Misc|{{uc:convertUnits}}]]
[[Category:Functions|{{uc:convertUnits}}]]
[[Category:{{Name|tkoh}}: Functions|{{uc:convertUnits}}]]
[[Category:{{Name|arma3}}: Functions|{{uc:convertUnits}}]]

Latest revision as of 23:11, 12 July 2022

Hover & click on the images for description

Description

Description:
Converts values to a target system of units.
Execution:
call
Groups:
Math

Syntax

Syntax:
[value, from, to, mode, precision] call BIS_fnc_convertUnits
Parameters:
value: Number - source value
from: Number - source unit. Can be one of:
  • 0: m (meters)
  • 1: km (kilometers)
  • 2: ms (meters per second)
  • 3: kmh (kilometers per hour)
  • 4: ft (feet)
  • 5: mi (miles)
  • 6: fts (feet per second)
  • 7: mph (miles per hour)
  • 8: nm (nautical miles)
  • 9: kts (knots)
to: Number - (Optional, default detected system of units via systemOfUnits) destination unit. See from.
mode: Number - (Optional, default 0) can be one of:
  • 0: destination value (Scalar)
  • 1: destination text long (String) e.g "5 meters"
  • 2: destination text short (String) e.g "5 m"
precision: Number - (Optional, default 1) destination precision factor, -1 for no precision change. cannot be 0
Return Value:
Number or String - converted value

Examples

Example 1:
private _distString = [500, 0, 5, 1, -1] call BIS_fnc_convertUnits;

Additional Information

See also:
systemOfUnits

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note