2015-01-11 16:42:31 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
*
|
|
|
|
* Transforms a number to an array of the correspondending digits.
|
|
|
|
*
|
|
|
|
* Argument:
|
|
|
|
* 0: Number to 'digitize' (Number)
|
|
|
|
* 1: Set the minimal length of the returned array. Useful for getting left hand zeroes. (Number, optional)
|
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
* Digits. The maximum count is six digits. (Array)
|
|
|
|
*/
|
2015-01-13 19:56:02 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-03-26 02:20:17 +00:00
|
|
|
private ["_number", "_minLength", "_length", "_digits"];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
_number = _this select 0;
|
|
|
|
_minLength = _this select 1;
|
|
|
|
|
|
|
|
_number = _number min 999999;
|
|
|
|
|
2015-03-26 02:20:17 +00:00
|
|
|
_number = str _number;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-03-26 02:20:17 +00:00
|
|
|
_length = count _number;
|
|
|
|
|
|
|
|
if (isNil "_minLength") then {_minLength = _length};
|
|
|
|
|
|
|
|
_minLength = _minLength min 6;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-03-26 02:20:17 +00:00
|
|
|
while {_length < _minLength} do {
|
|
|
|
_number = "0" + _number;
|
|
|
|
_length = _length + 1;
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
2015-03-26 02:20:17 +00:00
|
|
|
_digits = [];
|
|
|
|
for "_x" from 0 to (_length - 1) do {
|
|
|
|
_digits pushBack parseNumber (_number select [_x, 1]);
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
2015-03-26 02:20:17 +00:00
|
|
|
|
2015-01-11 16:42:31 +00:00
|
|
|
_digits
|