Paste #78893: Script

Date: 2020/12/17 23:32:18 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


# Monster Items #
string-item:
    type: item
    material: string
    display name: String
    lore:
    - Valued at <yaml[surplusitems].read[<[stringitem]>.sell]> a piece.

flesh-item:
    type: item
    material: rotten_flesh
    display name: Rotten Flesh
    lore:
    - Valued at  a piece.

# - Main GUI - #
initial-gui:
    type: inventory
    inventory: chest
    title: Eric's Surplus Buyback
    size: 9
    slots:
    - [voidbutton] [voidbutton] [voidbutton] [monsteritems] [blockitems] [resourceitems] [voidbutton] [voidbutton] [voidbutton]

# - Monster Shops - #
monster-shop:
    type: inventory
    inventory: chest
    title: Monster Surplus
    size: 18
    slots:
        - [flesh-item] [bone-item] [string-item] [spider-item] [blaze-item] [powder-item] [slime-item] [magma-item] [voidButton]
        - [backbutton] [voidbutton] [voidbutton] [voidbutton] [amountbutton] [voidbutton] [voidbutton] [voidbutton] [voidButton]

# - Resource Shops - #
resource1-shop:
    type: inventory
    inventory: chest
    title: Resource Surplus Page 1
    size: 27
    slots:
        - [coal-item] [iron-ingot-item] [gold-ingot-item] [lapis-item] [redstone-item] [diamond-item] [emerald-item] [netherite-ingot-item] [voidbutton]
        - [raw-pork-item] [cooked-pork-item] [raw-beef-item] [cooked-beef-item] [raw-mutton-item] [cooked-mutton-item] [raw-chicken-item] [cooked-chicken-item] [voidbutton]
        - [backbutton] [voidbutton] [voidbutton]  [voidbutton] [voidbutton] [voidbutton] [voidbutton] [voidbutton] [nextbutton]

resource2-shop:
    type: inventory
    inventory: chest
    title: Resource Surplus Page 2
    size: 27
    slots:
    - [wheat-seeds-item] [wheat-item] [carrot-item] [berry-item] [potato-item] [baked-potato-item] [poison-potato-item] [voidButton] [voidButton]
    - [cod-item] [cooked-cod-item] [salmon-item] [cooked-salmon-item] [kelp-item] [dried-kelp-item] [tropical-fish-item] [voidButton] [voidButton]
    - [backbutton] [voidbutton] [voidbutton] [voidbutton] [voidbutton] [voidbutton] [voidbutton] [voidbutton] [voidButton]

# - Block Shops - #
block-shop:
    type: inventory
    inventory: chest
    title: Block Surplus
    size: 27
    slots:
        - [] [] [] [] [] [] [] [] []
        - [] [] [] [] [] [] [] [] []
        - [backbutton] [voidbutton] [voidbutton] [voidbutton] [voidbutton] [voidbutton] [voidbutton] [voidbutton] [nextbutton]

########################### - Handlers - ###########################
eric-npc:
    type: assignment
    actions:
        on assignment:
        - trigger name:click eric:true
    interact scripts:
    - open-initial-gui

open-initial-gui:
    type: interact
    steps:
        1:
            click trigger:
                script:
                - narrate "[<&6>Collector<&f>] Eric: Hey <player.name>! What have you got for me?"
                - wait 2s
                - ~yaml load:surplusitems.yml id:surplusitems
                - inventory open d:initial-gui

cantSell_Eric:
    type: task
    script:
        - determine passively cancelled
        - playsound <player> sound:entity_player_hurt pitch:0.5
        - narrate "[<&6>Collector<&f>] Eric: Looks like you don't have enough of those."
########################### - Handlers - ###########################

# Amount Button #
        on player clicks amountbutton in *-shop priority:3:
            - determine passively cancelled
            - playsound <player> sound:block_stone_button_click_on pitch:1
            - if <player.flag[sellAmount]> >= 513:
                - flag <player> sellAmount:16
                - narrate "[<&6>Collector<&f>] Eric: Sell <player.flag[sellAmount]> items."
            - else:
                - flag <player> sellAmount:+:16
                - narrate "[<&6>Collector<&f>] Eric: Sell <player.flag[sellAmount]> items."

# - Sell Items/Monster - #
        on player clicks flesh-item in monster-shop priority:4:
        - if <player.inventory.quantity.material[rotten_flesh]> >= <player.flag[sellAmount]>:
            - determine passively cancelled
            - playsound <player> sound:block_stone_button_click_on pitch:1
            - take material:rotten_flesh quantity:<player.flag[sellAmount]> from:<player.inventory>
            - money give quantity:<player.flag[sellAmount].mul[<yaml[surplusitems].read[<[fleshitem]>.sell]>]>
        - else:
            - inject cantSell_Eric