Paste #48557: Untitled Paste

Date: 2018/07/11 02:06:19 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


script:
    - if <context.server||false> {
        - announce to_console "only for players"
        - queue clear 
    } 
    - if "<server.list_notables.contains[in@ChatTitle_<player.name>].not>" {
        - note in@ChatTitle_inv "as:ChatTitle_<player.name>"
    }
    #
    # GENERATING GUI BUTTONS
    #
    - define list li@
    - define items_per_page <script[core].yaml_key[config.titles.items_per_page]||40>
    - if <def[items_per_page].is[MORE].to[40]> {
        - define items_per_page 40
    }
    - foreach <script.list_keys[title_groups]||none>:
        - if %value% == none {
            - foreach stop
        }
        - define group <def[value]>
        - define color <script.yaml_key[title_groups.%group%.title_color]||f>
        - foreach <script.list_keys[title_groups.%group%.titles].alphanumeric||false>:
            - define title <def[value]>
            - if <player.has_permission[nomblox.title.%title%].not> {
                - foreach next
            }
            - define item "<script.yaml_key[title_groups.%group%.gui_item]||white_stained_glass_pane>[display_name=<&%color%><def[title].to_titlecase>;lore=<parse:<script.yaml_key[title_groups.%group%.titles.%value%]||<&sp>>>]"
            # add the item with all the info displayed to the list
            - define list <def[list].include[<def[item]>]>
    - define pages <def[list].size.div[%items_per_page%].round_up||1>
    - if <player.has_flag[titles_page].not||false> {
        - flag player titles_page:1/%pages%
    } else {
        - define player_page <player.flag[titles_page].split[/].get[1]||1>
        - flag player titles_page:%player_page%/%pages%
    }
    - foreach <def[list]>:
        # if LOOP INDEX is smaller than the first item that should appear on that page, skip the loop
        - if <def[loop_index].is[OR_LESS].to[<player.flag[titles_page].split[/].get[1].sub[1].mul[%items_per_page%]>]||0> {
            - foreach next
        }
        # if LOOP INDEX is greater than the number of items that can be displayed on page, stop the loop
        - if <def[loop_index].is[MORE].to[<player.flag[titles_page].split[/].get[1].mul[%items_per_page%]>]> {
            - foreach stop
        }
        - inventory set "d:in@ChatTitle_<player.name>" o:<def[value]> "slot:<in@ChatTitle_<player.name>.first_empty>"
    - inventory open "d:in@ChatTitle_<player.name>"