Occorre passare allo script 3 argomenti:
argument0: la stringa a cui aggiungere le andate a capo
argument1: la font che verrà adoperata per stampare la stringa
argument2: larghezza massima che può raggiungere ogni singola riga di testo
Lo script ritorna la stringa di testo con aggiunte le andate a capo, pronta per essere stampata sullo schermo.
Codice: Seleziona tutto
draw_set_font(argument1);
var i,word,wid,str;
i=1;wid=0;str="";
while (i<=string_length(argument0))
{
word="";
while (string_char_at(argument0,i)!=" " && i<=string_length(argument0))
{
word+=string_char_at(argument0,i);
i+=1;
}
i+=1;
if (wid+string_width(word)>argument2)
{
str+="#";
wid=0;
}
word+=" ";
str+=word;
wid+=string_width(word);
}
return (str);