printf: number of line wraps

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
McMalloc
Prole
Posts: 5
Joined: Thu Jun 28, 2012 9:14 am

printf: number of line wraps

Post by McMalloc »

Hai people!

I try to imitate those oldschool scrolling dialogue windows (with the glyphs appearing one after another quickly). I only want two lines of text being visible at once, after that an user input is necessary to continue to the next two lines.

I use printf for line wrapping. How can I stop outputting the string after one line feed?

Many thanks in advance!
Robert
User avatar
Ubermann
Party member
Posts: 146
Joined: Mon Nov 05, 2012 4:00 pm

Re: printf: number of line wraps

Post by Ubermann »

McMalloc wrote:Hai people!

I try to imitate those oldschool scrolling dialogue windows (with the glyphs appearing one after another quickly). I only want two lines of text being visible at once, after that an user input is necessary to continue to the next two lines.

I use printf for line wrapping. How can I stop outputting the string after one line feed?

Many thanks in advance!
Robert
I would suggest you to use love functions for printing text.

As for your question, you will need to play with string.sub, string.len and probably with font:getWidth() and also having some variable where you save the maximum number of characters per line and the maximun width of the line. And maybe with love.timer.sleep() too.
User avatar
McMalloc
Prole
Posts: 5
Joined: Thu Jun 28, 2012 9:14 am

Re: printf: number of line wraps

Post by McMalloc »

Ubermann wrote: I would suggest you to use love functions for printing text.

As for your question, you will need to play with string.sub, string.len and probably with font:getWidth() and also having some variable where you save the maximum number of characters per line and the maximun width of the line. And maybe with love.timer.sleep() too.
I forgot to state that I indeed use love.graphics.printf() to display text with line wrapping :)

Font.getWidth() seems to look useful for this purpose, thank you! But why would I need sleep()? I don't want the dialogue display to freeze the whole program...

Regards,
Robert
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 2 guests