Stuff by David
All my stuff in one place!
Home/News
Videos
Applications
Games
Resources
About me
Minecraft Note Block Studio tutorials
The Poptart Tragedy
Building songs in Minecraft
Redstone Display Maker tutorial
Auto closing wooden door!
View all...
Minecraft Note Block Studio
Redstone Display Maker
Minecraft Redstone Simulator
The ultimate D&D to GML converter
Image to RTF converter
View all...
Chaos
Die
View all...
Game Maker examples
Labyrinth generator and solver
Tetris
Text editor
Inventory and item engine
View all...
Game Maker scripts
GML syntax coloring in-game
Change colors of certain words in a text
Center the text in the built-in dialogues
Upgrade of keyboard_string
View all...
<
Previous
|
All scripts
|
Next
>
Center the text in the built-in dialogues
Please enable javascript to view this.
/* CALL: get_message_align_str(str,align,messagewidth,font) INFO: This script will return a modified string, which when used in the built-in message functions, will show an aligned text. Spaces will be added to simulate an alignment. ARGUMENTS: str = The string to show. align = The alignment. Use any of these: fa_left fa_center fa_right messagewidth = The width of the messages, set using message_size(w,h) (Not sure what the default width is.) font = The font which is used in the messages, set using message_text_font(). The default is Microsoft Sans Serif, with a size of 8. Note that this must be a Game Maker resource, not the name of a built-in font. WRITTEN BY: Davve http://www.stuffbydavid.com No credit needed if used. */ var str, nstr, msgw, a, pos, addstr, fnt, space, align; str = argument0; align = argument1 if (align != fa_center && align != fa_right) return str; msgw = argument2 - 48; fnt = argument3; length = string_length(str); nstr = ''; pos = 1; draw_set_font(fnt); space = string_width(' ') for (a = 1; a <= length; a += 1) { if (string_char_at(str, a) == '#' || a == length) { addstr = string_copy(str, pos, a - pos + 1); nstr += (msgw - string_width(addstr)) / (2 - (align == fa_right)) / space * " " + addstr; pos = a + 1; } } return nstr;
Comments
Constructive criticism is always welcome!
Please enable JavaScript to view comments.