Skip to content

Commit b082c4b

Browse files
committed
fix pad_string_length, add shuffle_array
1 parent 857357b commit b082c4b

File tree

11 files changed

+181
-279
lines changed

11 files changed

+181
-279
lines changed

current-scripts/Demos/useful-scripts/objects/obj_control_manager_demo/obj_control_manager_demo.yy

Lines changed: 8 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

current-scripts/Demos/useful-scripts/scripts/data_structures/data_structures.gml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,25 @@ function array_is_subset(_a, _b) {
4040
return true;
4141
}
4242

43+
function shuffle_array(_array) {
44+
var _current_index = array_length(_array);
45+
var _random_index;
46+
47+
// While there remain elements to shuffle
48+
while (_current_index != 0) {
49+
// Pick a remaining element
50+
_random_index = irandom(_current_index - 1);
51+
_current_index--;
52+
53+
// And swap it with the current element
54+
var _temp = _array[_current_index];
55+
_array[_current_index] = _array[_random_index];
56+
_array[_random_index] = _temp;
57+
}
58+
59+
return _array;
60+
}
61+
4362
/// @func file_jsonc_parse(filename)
4463
/// @desc Parses a JSON with Comments from file, stripping out the comments
4564
/// @param {Array} filename

current-scripts/Demos/useful-scripts/scripts/data_structures/data_structures.yy

Lines changed: 3 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

current-scripts/Demos/useful-scripts/scripts/strings/strings.gml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function pad_string_width(_str, _char, _position, _width) {
122122
/// @arg {integer} position
123123
/// @arg {real} width
124124
function pad_string_length(_str, _char, _position, _width) {
125-
while (string_length(_str + _char) < _width) {
125+
while (string_length(_str + _char) <= _width) {
126126
_str = string_insert(_char, _str, _position);
127127
}
128128

current-scripts/Demos/useful-scripts/scripts/strings/strings.yy

Lines changed: 3 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

current-scripts/Demos/useful-scripts/sprites/spr_arrow/spr_arrow.yy

Lines changed: 10 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

current-scripts/Demos/useful-scripts/sprites/spr_donut_meter/spr_donut_meter.yy

Lines changed: 10 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

current-scripts/Demos/useful-scripts/sprites/spr_drawing_back/spr_drawing_back.yy

Lines changed: 10 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

current-scripts/Demos/useful-scripts/sprites/spr_meter/spr_meter.yy

Lines changed: 10 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)