Epoch/Sources/epoch_code/compile/functions/EPOCH_fnc_setVariableLimited.sqf
vbawol fc3ba3b3fb customHeader test
moved debug monitor to master loop
dropped digest idea for now
removed file check on masterloop and keydown
2017-09-26 14:31:39 -05:00

30 lines
906 B
Plaintext

/*
Author: Aaron Clark - EpochMod.com
Contributors:
Description:
Sets GVAR value within min/max limits.
Licence:
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
Github:
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/compile/functions/EPOCH_setVariableLimited.sqf
Example:
["TEST",-30,100,0] call EPOCH_fnc_setVariableLimited; // removes 30 and keeps number within 0-100 range.
Parameter(s):
_this select 0: STRING - GVar variable key
_this select 1: NUMBER - Change variable
_this select 2: NUMBER - max Value
_this select 3: NUMBER - min Value
Returns:
NUMBER
*/
params ["_key","_change","_max","_min"];
private _result = (((missionNamespace getVariable [_key, 0]) + _change) min _max) max _min;
missionNamespace setVariable [_key, _result];
_result