Skip to content

Commit 92d270e

Browse files
committed
changed pad_string to pad_string_width, added pad_string_length
1 parent 27b4c68 commit 92d270e

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,20 +101,34 @@ function split_string(_str, _delimiter) {
101101
return _substrings;
102102
}
103103

104-
/// @func pad_string(str, char, position, width)
105-
/// @desc Pads a string with char until it is a certain width
104+
/// @func pad_string_width(str, char, position, width)
105+
/// @desc Pads a string with char until it is a certain width (in pixels)
106106
/// @arg {string} str
107107
/// @arg {string} char
108108
/// @arg {integer} position
109109
/// @arg {real} width
110-
function pad_string(_str, _char, _position, _width) {
110+
function pad_string_width(_str, _char, _position, _width) {
111111
while (string_width(_str + _char) < _width) {
112112
_str = string_insert(_char, _str, _position);
113113
}
114114

115115
return _str;
116116
}
117117

118+
/// @func pad_string_width(str, char, position, width)
119+
/// @desc Pads a string with char until it is a certain length (in characters)
120+
/// @arg {string} str
121+
/// @arg {string} char
122+
/// @arg {integer} position
123+
/// @arg {real} width
124+
function pad_string_length(_str, _char, _position, _width) {
125+
while (string_length(_str + _char) < _width) {
126+
_str = string_insert(_char, _str, _position);
127+
}
128+
129+
return _str;
130+
}
131+
118132
/// @func hide_overflow(string, suffix, font, max_width)
119133
/// @desc Hides overflowing text
120134
/// @arg {string} string

current-scripts/Demos/useful-scripts/useful-scripts.yyp

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)