split_by_pages_output: type: task debug: false script: - define book "<&8>I am trying to write a method that will automatically wrap text from one page onto the next without any problems. Book pages used to be capped at 256 characters each, but since some characters are smaller than others they changed it to use character width instead. I'm trying to use this to wrap my text from page 1 to page 2 to page 3 etc. perfectly without cutting off words or anything like that." - adjust show_book:split_by_pages_book[book_pages=<[book].proc[split_by_pages]>] - playsound sound:ITEM_BOOK_PAGE_TURN pitch:1 split_by_pages: type: procedure debug: false definitions: book script: - define wordbyword - define pages - define splitted <[book].trim.split[ ]> - define rows - foreach <[splitted]> as:word: - if <[wordbyword].length> > 0 && <[word]>].text_width> > 114: - define row:->:<&8><[wordbyword].space_separated> - define wordbyword - define wordbyword:->:<[word]> - define rows:->:<[row]> - else: - define wordbyword:->:<[word]> - define row:->:<[wordbyword].space_separated> - define lines 0 - define page - foreach <[row]> as:line: - define page "<[page]><[line]> " - define lines:++ - if <[lines]> == 14: - define page <[page]> - define lines 1 - define pages:->:<[page]> - define page - define pages:->:<&8><[page]> - determine <[pages]> split_by_pages_book: type: book title: test author: test signed: true text: -