Paste #47966: dBank - WIP

Date: 2018/06/22 19:22:16 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


#==================#
#      DEBUG       #=======================================================#
#==================#

dBank_Command:
    type: command
    name: dBank
    description: Open a dBank window.
    usage: /dBank [<&lt>clear<&gt>]
    allowed help: determine <player.is_op>
    script:
        - if <context.args.size> == 0 {
            - run dBank_Core instantly def:<player>
        } else if <context.raw_args> == clear {
            - run dBank_Reset instantly
        } else {
            - narrate "<&4>Unknown usage."
        }

dBank_Reset:
    type: task
    script:
        - foreach <server.list_players.filter[has_flag[dBank]]> {
            - define player <def[value]>
            - flag <def[player]> dBank:!
            - note remove as:<def[player].UUID>_dBank_inventory
            - repeat 9 {
                - flag <def[player]> dBank_<def[value]>:!
                - note remove as:<def[player].UUID>_dBank_inventory_bag_<def[value]>
            }
        }
        - narrate "<&2>Data cleared."

#==================#
#     CONFIG       #=======================================================#
#==================#

dBank_config:
    type: yaml data

dBank_Default:
    type: inventory
    inventory type: chest
    title: Bank
    size: 9
    slots:
    - "[i@bank_bag[display_name=Bag 1]] [i@bank_buy_restricted] [i@bank_blank] [i@bank_blank] [i@bank_blank] [i@bank_blank] [i@bank_blank] [i@bank_blank] [i@bank_blank]"

dBank_Bag_Default:
    type: inventory
    inventory type: chest
    title: Bag [SLOTNUMBER]
    size: 54
    slots:
    - "[i@bank_back] [] [] [] [] [] [] [] []"
    - "[] [] [] [] [] [] [] [] []"
    - "[] [] [] [] [] [] [] [] []"
    - "[i@bank_buy] [i@bank_blank] [i@bank_blank] [i@bank_blank] [i@bank_blank] [i@bank_blank] [i@bank_blank] [i@bank_blank] [i@bank_blank]"
    - "[i@bank_blank] [i@bank_blank] [i@bank_blank] [i@bank_blank] [i@bank_blank] [i@bank_blank] [i@bank_blank] [i@bank_blank] [i@bank_blank]"
    - "[i@bank_blank] [i@bank_blank] [i@bank_blank] [i@bank_blank] [i@bank_blank] [i@bank_blank] [i@bank_blank] [i@bank_blank] [i@bank_blank]"

#==================#
#    OPERATIONS    #=======================================================#
#==================#   

dBank_Core:
    type: task
    script:
        - if <def[1].has_flag[dBank].not> {
            - flag <def[1]> dBank
            - note in@dBank_Default as:<def[1].UUID>_dBank_inventory
        }
        - inventory close
        - inventory open d:in@<def[1].UUID>_dBank_inventory

dBank_Bag:
    type: task
    script:
        - if <def[1].has_flag[dBank_<def[2]>].not> {
            - flag <def[1]> dBank_<def[2]>
            - note in@dBank_Bag_Default as:<def[1].UUID>_dBank_inventory_bag_<def[2]>
            - adjust in@<def[1].UUID>_dBank_inventory_bag_<def[2]> title:TEST
        }
        - inventory close
        - inventory open d:in@<def[1].UUID>_dBank_inventory_bag_<def[2]>

dBank_Functions:
    type: world
    debug: false
    custom_items:
    - i@bank_blank
    - i@bank_buy
    - i@bank_bag
    - i@bank_back
    - i@bank_buy_restricted
    - i@bank_bag_buy
    events:
        on player clicks in inventory:
            - narrate <context.inventory.notable_name>
            - if <context.inventory.notable_name.starts_with[<player.UUID>_dBank]||false> {
                - if <script.yaml_key[custom_items].contains[<context.item.simple>]> {
                    - determine passively cancelled
                    - if <context.item.simple> == i@bank_back {
                        - run dBank_Core instantly def:<player>
                    } else if <context.item.simple> == i@bank_buy {
                        - narrate pass
                        - if <CONDITIONS.MET||true> == true {
#                           - remove funds
                            - inventory set d:<context.inventory> o:i@air slot:<context.raw_slot>
                            - if <context.raw_slot> <= 53 {
                                - inventory set d:<context.inventory> o:i@bank_buy slot:<context.raw_slot.add[1]>
                            } else if <context.raw_slot> == 54 {
                                - define unlock <context.inventory.title.after[<&sp>].add[1]>
                                - if <def[unlock]> <= 8 {
                                    - inventory set d:in@<player.UUID>_dBank_inventory o:i@bank_bag_buy slot:<def[unlock]>
                                }
                                - if <def[unlock]> <= 7 {
                                    - inventory set d:in@<player.UUID>_dBank_inventory o:i@bank_buy_restricted slot:<def[unlock].add[1]>
                                } else if <def[unlock]> == 9 {
                                    - narrate "Congrats. You unlocked all the bags. Woo."
                                }
                            }
                        }
                    } else if <context.item.simple> == i@bank_bag_buy {
#                       - remove funds
                        - inventory set d:<context.inventory> o:i@bank_bag[display_name=Bag<&sp><context.raw_slot>] slot:<context.raw_slot>
                    } else if <context.item.simple> == i@bank_blank {
                        - queue clear
                    } else if <context.item.simple> == i@bank_bag {
                        - run dBank_Bag instantly def:<player>|<context.raw_slot>
                    }
                }
            }


#==================#
#      ITEMS       #=======================================================#
#==================#

bank_blank:
    type: item
    material: i@black_stained_glass_pane
    display name: <&4>Unavailable

bank_buy:
    type: item
    material: i@green_stained_glass_pane
    display name: <&a>Click to purchase
    lore:
    - $100

bank_bag:
    type: item
    material: i@chest
    display name: Bag [SLOTNUMBER]

bank_back:
    type: item
    material: i@barrier
    display name: <&8>Go Back

bank_buy_restricted:
    type: item
    material: i@red_stained_glass_pane
    display name: <&c>Not Available Yet

bank_bag_buy:
    type: item
    material: i@green_stained_glass_pane
    display name: <&a>Click to purchase
    lore:
    - $1000