mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-17 09:10:27 +03:00
Use BIS_fnc_numberText for SC number displays
See: https://github.com/EpochModTeam/DayZ-Epoch/issues/1712#issuecomment-239647854 That should be all of them @ndavalos let me know if I missed any.
This commit is contained in:
53
SQF/dayz_code/compile/fn_numberDigits.sqf
Normal file
53
SQF/dayz_code/compile/fn_numberDigits.sqf
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
|
||||
Description:
|
||||
Break number into array of digits
|
||||
|
||||
Example:
|
||||
123456 > [1,2,3,4,5,6]
|
||||
|
||||
Parameter(s):
|
||||
_this: NUMBER
|
||||
|
||||
Returns:
|
||||
ARRAY
|
||||
*/
|
||||
|
||||
private ["_number","_step","_stepLocal","_result","_numberLocal","_add"];
|
||||
|
||||
_number = [_this,0,0,[0]] call bis_fnc_param;
|
||||
|
||||
if (_number < 10) then {
|
||||
|
||||
[_number]
|
||||
|
||||
} else {
|
||||
|
||||
_step = 10;
|
||||
_stepLocal = _step;
|
||||
_result = [0];
|
||||
_add = false;
|
||||
|
||||
while {_stepLocal < (_number * _step)} do {
|
||||
|
||||
_numberLocal = _number % (_stepLocal);
|
||||
|
||||
{
|
||||
_numberLocal = _numberLocal - _x;
|
||||
} foreach _result;
|
||||
|
||||
_numberLocal = floor (_numberLocal / _stepLocal * _step);
|
||||
|
||||
if (_numberLocal < 0) then {_numberLocal = 9};
|
||||
|
||||
_result = [_numberLocal] + _result;
|
||||
_stepLocal = _stepLocal * (_step);
|
||||
|
||||
};
|
||||
|
||||
if ((_result select 0) == 0) then {_result = [1] + _result;};
|
||||
|
||||
_result resize (count _result - 1);
|
||||
_result
|
||||
|
||||
};
|
||||
35
SQF/dayz_code/compile/fn_numberText.sqf
Normal file
35
SQF/dayz_code/compile/fn_numberText.sqf
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
|
||||
Description:
|
||||
Convert a number into string (avoiding scientific notation)
|
||||
|
||||
Parameter(s):
|
||||
_this: ARRAY containing single NUMBER
|
||||
|
||||
Returns:
|
||||
STRING
|
||||
|
||||
Example:
|
||||
[scalarNumber] call BIS_fnc_numberText
|
||||
*/
|
||||
|
||||
private ["_number","_mod","_digots","_digitsCount","_modBase","_numberText"];
|
||||
|
||||
_number = [_this,0,0,[0, ""]] call bis_fnc_param;
|
||||
_mod = [_this,1,3,[0]] call bis_fnc_param;
|
||||
|
||||
if (typeName _number == "STRING") then {
|
||||
_number = parseNumber _number;
|
||||
};
|
||||
|
||||
_digits = _number call BIS_fnc_numberDigits;
|
||||
_digitsCount = count _digits - 1;
|
||||
_modBase = _digitsCount % _mod;
|
||||
_numberText = "";
|
||||
|
||||
{
|
||||
_numberText = _numberText + str _x;
|
||||
if ((_foreachindex - _modBase) % (_mod) == 0 && _foreachindex != _digitsCount) then {_numberText = _numberText + ",";};
|
||||
} foreach _digits;
|
||||
|
||||
_numberText
|
||||
Reference in New Issue
Block a user