/* * Author: commy2 * Read laser distance measurement from engine. * * Argument: * 0: Measurement Accuracy (default: 1) * 1: Maximum measure distance (default: 5000) * 2: Minimum measure distance (default: 0) * 3: Blank display on range error (default: false) * * Return value: * Measured distance * * Public: No */ #include "script_component.hpp" params [["_accuracy",1], ["_maxDistance",5000], ["_minDistance",0], ["_blank",false]]; disableSerialization; private _dlgRangefinder = uiNamespace getVariable ["ACE_dlgRangefinder", displayNull]; private _distance = parseNumber ctrlText (_dlgRangefinder displayCtrl 151); if (_distance == 0) then { _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; }; // Change the display if the range is out of bounds if (_distance >= _maxDistance || _distance <= _minDistance) then { if (_blank) then { (_dlgRangefinder displayCtrl 1713151) ctrlSetText "----"; } else { (_dlgRangefinder displayCtrl 1713151) ctrlSetText ([_distance, 4, 0] call CBA_fnc_formatNumber) + "*"; }; } else { (_dlgRangefinder displayCtrl 1713151) ctrlSetText ([_distance, 4, 0] call CBA_fnc_formatNumber); }; _distance