You are not logged in.
Originaly from flexaplex (wp), with minor changes to original draw script.
//draw_text_ext2(x, y, str, sep, w); draws text the same as draw_text_ext except splitting up long words as well
var str;
str = argument2 + " ";
if (string_width_ext(str, argument3, argument4) > argument4)
{
var i;
for (i = 1; i <= string_length(str); i += 1)
{
if (string_width_ext(string_copy(str, 1, i),argument3,argument4) > argument4)
{
str = string_insert(" ", str,max(1,i-1));
i+=1;
}
}
}
draw_text_ext(argument0, argument1, str, argument3, argument4);
//string_width_ext2(str, sep, w); width compatible with draw_text_ext2
var str;
str = argument0 + " ";
if (string_width_ext(str, argument1, argument2) > argument2)
{
var i;
for (i = 1; i <= string_length(str); i += 1)
{
if (string_width_ext(string_copy(str, 1, i),argument1,argument2) > argument2)
{
str = string_insert(" ", str,max(1,i-1));
i+=1;
}
}
}
return string_width_ext(str,argument1,argument2);
//string_height_ext2(str, sep, w); height compatible with draw_text_ext2
var str;
str = argument0 + " ";
if (string_width_ext(str, argument1, argument2) > argument2)
{
var i;
for (i = 1; i <= string_length(str); i += 1)
{
if (string_width_ext(string_copy(str, 1, i),argument1,argument2) > argument2)
{
str = string_insert(" ", str,max(1,i-1));
i+=1;
}
}
}
return string_height_ext(str,argument1,argument2);
//string_draw_text_ext2_format(str, sep, w); generates the string, so you can call only once and use the
//resulting string in the regular _ext functions (faster to format once)
var str;
str = argument0 + " ";
if (string_width_ext(str, argument1, argument2) > argument2)
{
var i;
for (i = 1; i <= string_length(str); i += 1)
{
if (string_width_ext(string_copy(str, 1, i),argument1,argument2) > argument2)
{
str = string_insert(" ", str,max(1,i-1));
i+=1;
}
}
}
return str;
Last edited by icuurd12b42 (2010-06-19 19:37:59)
Offline
Regarding the last script, is it functionally different than either of these existing scripts?
http://www.gmlscripts.com/script/string_width_wrap
http://www.gmlscripts.com/script/string_width_limit
I'm also not happy with the name because it doesn't extend built-in function string_format()
, it does something completely different.
Abusing forum power since 1986.
Offline
Yes it's different. It reformats the string so you are able to use it with draw_text_ext correctly. Here is the gmc topic on it:
http://gmc.yoyogames.com/index.php?showtopic=401419
I'm not sure which (if any) scripts would fit well with gmlscripts though.
Last edited by flexaplex (2010-06-17 14:50:12)
Offline
name it string_draw_text_ext2_format
Offline