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
|
|
|
*
|
2015-01-11 16:42:31 +00:00
|
|
|
* Argument:
|
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-20 23:20:21 +00:00
|
|
|
* 3: Update display (default: true) <BOOL>
|
2015-01-12 10:02:44 +00:00
|
|
|
*
|
2015-01-11 16:42:31 +00:00
|
|
|
* Return value:
|
2015-12-10 15:00:14 +00:00
|
|
|
* Measured distance <NUMBER>
|
|
|
|
*
|
|
|
|
* Public: No
|
2015-01-11 16:42:31 +00:00
|
|
|
*/
|
2015-01-12 10:02:44 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2016-01-20 23:20:21 +00:00
|
|
|
params [["_accuracy",1], ["_maxDistance",5000], ["_minDistance",0],["_update",true]];
|
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 {
|
|
|
|
if (_distance > _maxDistance) then {
|
|
|
|
_distance = _maxDistance;
|
|
|
|
};
|
|
|
|
|
|
|
|
if (_distance < _minDistance) then {
|
|
|
|
_distance = _minDistance;
|
|
|
|
};
|
|
|
|
|
|
|
|
_accuracy = if(_accuracy < 1) then {1} else {_accuracy};
|
|
|
|
_distance = (round (_distance/_accuracy)) * _accuracy;
|
|
|
|
};
|
|
|
|
|
2016-01-20 23:20:21 +00:00
|
|
|
if (_update) then {
|
|
|
|
// Display the minimum or maximum distance with an * if out of bounds
|
|
|
|
if (_distance >= _maxDistance || _distance <= _minDistance) then {
|
|
|
|
(_dlgRangefinder displayCtrl 1713151) ctrlSetText ([_distance, 4, 0] call CBA_fnc_formatNumber) + "*";
|
|
|
|
} else {
|
|
|
|
(_dlgRangefinder displayCtrl 1713151) ctrlSetText ([_distance, 4, 0] call CBA_fnc_formatNumber);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-01-19 23:10:27 +00:00
|
|
|
_distance
|