Paste #137313: Unnamed Denizen Script Paste

Date: 2025/11/08 09:23:15 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


cmd_fixitem:
    type: command
    name: fixitem
    debug: false
    usage: /fixitem
    description: Debug for text centering.
    script:
        - if <player.item_in_hand> MATCHES air:
            - narrate "<&c>You need an item."
            - stop

        - inventory adjust slot:<player.held_item_slot> d:<player.inventory> lore:<proc[lore_fancy]>
        - narrate "<&a>Jobs done."

util_center_text:
    type: procedure
    debug: false
    definitions: width|text
    script:
        - define n_width <[width].sub[<[text].text_width>].round_down>
        # Spaces worth 4 width
        - define space <&sp.repeat[<[n_width].div[4].div[2]>]>
        - determine <[space]><[text]><[space]>

util_clamp_text:
    type: procedure
    debug: false
    definitions: width|text
    script:
        - define text_lines <[text].split[<&sp>]>
        - define final <list>
        - define these <list>
        # We have to do this because element.split_lines_by_width doesn't preserve color.
        - foreach <[text_lines]> as:line:
            - if <[these].include[<[line]>].separated_by[<&sp>].text_width> > <[width]>:
                - define last_clr <[these].unseparated.last_color>
                - define final:->:<[these].separated_by[<&sp>]>
                - define these <list[<[last_clr]><[line]>]>
                - foreach next
            - define these:->:<[line]>
            - if <[loop_index]> == <[text_lines].size>:
                - define final:->:<[these].separated_by[<&sp>]>
                - foreach stop
        - determine <[final].separated_by[<&nl>]>

lore_fancy:
    type: procedure
    debug: false
    data:
        center_text:
            - Central Information
            - Apex of Item Info
            - Pillar of Item Stuff
            - An Item's Horizon
            - Lanky Long Text
            - Lexicon of Information
        lore_text:
            - Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
            - Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
            - Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
            - Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    script:
        - define border <&7><strikethrough><&sp.repeat[40]>
        - define width <[border].text_width>
        - define text <&a><script.data_key[data.center_text].random>
        - define list:->:<[border]>
        - define list:->:<[border].text_width.proc[util_center_text].context[<[text]>]>
        - define list:->:<[border]>
        - define text2 <&6><script.data_key[data.lore_text].random>
        - define list:->:<[width].proc[util_clamp_text].context[<[text2]>]>
        - determine <[list]>