#(ikuria) book page-wrapping

31 messages · Page 1 of 1 (latest)

echo walrus
buoyant ploverBOT
#

(ikuria) book page-wrapping

buoyant ploverBOT
#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.

sweet lodge
#

!t split_lines_by_width

acoustic plumeBOT
# sweet lodge !t split_lines_by_width

Returns the element split into separate lines based on a maximum width in pixels per line.
This uses character width, so for example 20 "W"s and 20 "i"s will be treated differently.
The width used is based on the vanilla minecraft font. This will not be accurate for other fonts.
This only currently supports ASCII symbols properly. Unicode symbols will be estimated as 6 pixels.
Spaces will be preferred to become newlines, unless a line does not contain any spaces.

Group

element manipulation

Returns

ElementTag

sweet lodge
#

maybe this?

#

only issue i see this causing is it cutting words in half

#

!t element.last

acoustic plumeBOT
sweet lodge
#

!t element.last_index_of

acoustic plumeBOT
sweet lodge
#

!t element.substring

acoustic plumeBOT
sweet lodge
#

so! hear me out

element.substring[114].last_index_of[ ]
this should get up until the last word that fits

#

then you'd have to remove this line from the whole, which i must admit to not know how to

echo walrus
#

hmm, looks more complicated

fervent jetty
#

May I ask you why you are doing all of that instead of using a pre-written book script?

fervent jetty
fervent jetty
# echo walrus https://paste.denizenscript.com/View/129364 need a specialist for that, is somet...
split_by_width:
    type: task
    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."
    - 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]>]>

Wrote a small script that should do what you want to do. It also includes the last color from the recent page.

#

I've got the width by quick math from the minecraft wiki

echo walrus
#

okay, will check that - thanks alot

fervent jetty
echo walrus
#

want to get text from outside minecraft and just import it with denizen

#

doesnt work @fervent jetty width instead. I'm trying to use this to wrap my text from is lost in your script

fervent jetty
#

:(

#

Does the stuff you'd like to import contain any special symbols like color or anything?

echo walrus
#

maybe i could update that later, but at the moment i just want to split the text in a correct way into the pages 😄

#

will try another way this weekend