2015-01-11 16:42:31 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
2015-12-10 15:00:14 +00:00
|
|
|
* Read laser distance measurement from engine.
|
2015-01-12 10:02:44 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Arguments:
|
2016-01-19 23:10:27 +00:00
|
|
|
* 0: Measurement Accuracy (default: 1) <NUMBER>
|
|
|
|
* 1: Maximum measure distance (default: 5000) <NUMBER>
|
|
|
|
* 2: Minimum measure distance (default: 0) <NUMBER>
|
2016-01-21 13:44:23 +00:00
|
|
|
* 3: Blank display on range error (default: false) <BOOL>
|
2015-01-12 10:02:44 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Return Value:
|
2015-12-10 15:00:14 +00:00
|
|
|
* Measured distance <NUMBER>
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* [5, 6, 7, true] call ace_fcs_fnc_getRange
|
|
|
|
*
|
2015-12-10 15:00:14 +00:00
|
|
|
* Public: No
|
2015-01-11 16:42:31 +00:00
|
|
|
*/
|
2015-01-12 10:02:44 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2016-01-21 13:44:23 +00:00
|
|
|
params [["_accuracy",1], ["_maxDistance",5000], ["_minDistance",0], ["_blank",false]];
|
2016-01-19 23:10:27 +00:00
|
|
|
|
2015-01-11 16:42:31 +00:00
|
|
|
disableSerialization;
|
2015-12-10 15:00:14 +00:00
|
|
|
private _dlgRangefinder = uiNamespace getVariable ["ACE_dlgRangefinder", displayNull];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2016-01-19 23:10:27 +00:00
|
|
|
private _distance = parseNumber ctrlText (_dlgRangefinder displayCtrl 151);
|
|
|
|
|
2016-01-20 14:51:07 +00:00
|
|
|
if (_distance == 0) then {
|
2016-01-19 23:10:27 +00:00
|
|
|
_distance = _this call EFUNC(common,getTargetDistance);
|
|
|
|
} else {
|
2016-01-21 14:01:41 +00:00
|
|
|
// Is distance out of bound?
|
|
|
|
_distance = _distance min _maxDistance;
|
|
|
|
_distance = _distance max _minDistance;
|
2016-01-19 23:10:27 +00:00
|
|
|
|
2016-01-21 14:01:41 +00:00
|
|
|
// If don't let accuracy be less than 1
|
|
|
|
_accuracy = _accuracy max 1;
|
2016-01-19 23:10:27 +00:00
|
|
|
_distance = (round (_distance/_accuracy)) * _accuracy;
|
|
|
|
};
|
|
|
|
|
2016-01-21 13:44:23 +00:00
|
|
|
// Change the display if the range is out of bounds
|
|
|
|
if (_distance >= _maxDistance || _distance <= _minDistance) then {
|
|
|
|
if (_blank) then {
|
|
|
|
(_dlgRangefinder displayCtrl 1713151) ctrlSetText "----";
|
2016-01-20 23:20:21 +00:00
|
|
|
} else {
|
2016-01-21 13:44:23 +00:00
|
|
|
(_dlgRangefinder displayCtrl 1713151) ctrlSetText ([_distance, 4, 0] call CBA_fnc_formatNumber) + "*";
|
2016-01-20 23:20:21 +00:00
|
|
|
};
|
2016-01-21 13:44:23 +00:00
|
|
|
} else {
|
|
|
|
(_dlgRangefinder displayCtrl 1713151) ctrlSetText ([_distance, 4, 0] call CBA_fnc_formatNumber);
|
2016-01-20 23:20:21 +00:00
|
|
|
};
|
|
|
|
|
2016-01-19 23:10:27 +00:00
|
|
|
_distance
|