View Full Version : Chat System Word Wrapping

01-07-2007, 10:08 PM
I recently scripted a new chat system for Syn, and it works fine except for one thing -- how can I get the text to word wrap? Here's an example:

|---text text te| ( text text text is what it needs to show ) ( | is the border )
|--------o-----| ( o is the player )

It centers over the player, but I don't want it to go over where players cannot see it (screenwidth).
Someone said use textwidth, but I couldn't get that to work, it seems like it wasn't translated to GS2 properly.
Is there any way, still using a show text (not a gui) to do this? I don't think I'd be able to do it with a GUI either, so ... yah.

Any help is greatly appreciated.
Chris Zakuto
NAT of Syn

01-07-2007, 11:04 PM
gettextwidth() is the GS2 version.

01-08-2007, 02:26 AM
That really doesn't answer my question. I was using that, but it seems it wasn't moved from GS1 to GS2 right ... for example

temp.blah = "meow";
echo( gettextwidth( "Arial", "b", temp.blah ) );

won't work. However

temp.blah = "meow";
echo( gettextwidth( "Arial", "b", meow ) );

will, even without quotes around meow ...

01-08-2007, 03:53 AM
You should proubably try checking if the texts x plus its width are greater than screenwidth.

01-08-2007, 04:22 AM
wraptext2(pixel width,zoom,delimiters,text)
This will give you an array of lines separated at the delimiters that fits in the pixel width. It's probably much more useful to you than textwidth in this case.

01-08-2007, 04:27 AM
uhh ... I really don't get that. lol

01-08-2007, 06:38 AM
That, and gettextwidth takes a fourth parameter.

01-09-2007, 02:14 AM
I managed to get wraptext2 to work, now I just need to figure out how to use gettextwidth ... anyone care to tell me the paramaters?

01-09-2007, 03:56 AM
Returns the width of a specified text in a certain font. Format:
gettextwidth(zoom, font, style, text)
Copied directly from http://wiki.graal.net/index.php/Creation/Dev/Script/Client