Date: 2024/12/27 09:03:56 UTC-08:00
Type: Denizen Script
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 <player> show_book:split_by_pages_book[book_pages=<[book].proc[split_by_width]>]
- playsound <player> sound:ITEM_BOOK_PAGE_TURN pitch:1
split_by_pages_book:
type: book
title: test
author: test
signed: true
text:
- <empty>
split_by_width:
type: procedure
debug: false
definitions: book
script:
- define pages <[book].split_lines_by_width[1596].split[<n>]>
- define lastColors <[pages].parse[last_color]>
- foreach <[lastColors]> as:color:
- define nextPage <[loop_index].add[1]>
- if <[pages].size> < <[nextPage]>:
- foreach stop
- define pages[<[nextPage]>]:<[color]><[pages].get[<[nextPage]>]>
- determine <[pages]>