Script ‘auto_cr’: automatic carriage return

I managed to find this old script, in order to post it. The script takes as arguments a text, a font and the maximum width of the text; it automatically adds the word wraps, in order that each row is not larger than the maximum width specified.

Note: Game Maker already has a function (draw_text_ext) to break the text in multiple rows. The script is beneficial if you want the text appearing char by char. With the functions for string manipulation you can get bigger and bigger parts of the text, in order to show it on screen. The problem is that, by doing so, draw_text_ext acts on a text part, not on the whole text. As a result, some words could be moved sharply in the next row, while the part to print increases. The script solves the problem: just call it only once on the whole text.