Lua version of the pulp "say" (or a textbox library)

I was building my own textbox system when I realized the Pulp "say" function was doing something very similar to what I was planning to achieve.
Is there a lua version of this code (or a way to reuse the algo/logic) so that we don't start from scratch porting this to lua?

Thanks!

2 Likes

I haven't used it myself, but maybe this code from Neven (which types out text boxes letter-by-letter) is a head start:

Thanks! I actually looked into and started to adapt it but there is quite a bit of work in calculating the number of words to be displayed per "page" and making it look right.
It seems like this work was already done for the "say" function that's why I was asking.

I assume we need something like:

  • getTextSizeForMaxWidth but adjust it for the set width of the textbox
  • calculate the number of pages with the set height (maxHeight / setHeight), which will give us the number of chars per page
  • Rework the number of pages and their content to not cut words

Now, that I write it, this seems overly complicated!! :smiley:

How about something like:

  • Until (drawTextInRect returns textWasTruncated to true - or end of text) add one more word to the string to display
  • Then use the typewriter
  • If textWasTruncated, display a next page icon and update the source text to the remaining text
  • When the action button is pressed, start again
  • Repeat all the steps until the text is fully displayed

Thoughts?