[Array Range] Step sign now defines by start - end values. (You can now use positive step value when end is less than start.)

This commit is contained in:
Tanasart 2024-10-01 10:49:57 +07:00
parent 2714540e4a
commit 7e8c6758e9

View file

@ -17,16 +17,17 @@ function Node_Array_Range(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
var st = _data[0]; var st = _data[0];
var ed = _data[1]; var ed = _data[1];
var stp = _data[2]; var stp = _data[2];
var arr = [];
if(st == ed) { if(st == ed)
arr = array_create(stp, st); return array_create(abs(stp), st);
} else if(sign(stp) == sign(ed - st)) {
var _amo = floor(abs((ed - st) / stp)); stp = abs(stp) * sign(ed - st);
for( var i = 0; i < _amo; i++ ) var _amo = floor(abs((ed - st) / stp));
array_push(arr, st + i * stp); var arr = array_create(_amo);
}
for( var i = 0; i < _amo; i++ )
arr[i] = st + i * stp;
return arr; return arr;
} }