Paste #76029: Untitled Paste

Date: 2020/09/27 12:54:34 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


npc_assignment:
    type: assignment
    debug: true
    actions:
        on assignment:
        - trigger name:click state:true
    interact scripts:
        - npc_interact
npc_format:
    type: format
    format: "<&b><npc.name> <&f>to you<&co> <&2><text>"
npc_interact:
    type: interact
    debug: true
    steps:
        1:
            click trigger:
                script:
                - yaml load:/Shops/npc_shop.yml id:npc_buy
                - wait 1t
                - define shop d:npc_shop
                - inventory open <[shop]>
                - yaml unload id:npc_buy
npc_shop:
  type: inventory
  inventory: CHEST
  title: Loja
  size: 45
  slots:
  - [] [] [] [] [] [] [] [] []
  - [] [] [] [] [] [] [] [] []
  - [] [] [] [] [] [] [] [] []
  - [] [] [] [] [] [] [] [] []
  - [] [] [] [] [] [] [] [] []
  Procedural Items:
  - determine <yaml[npc_shop].read[npc_buy]>
npc_shop_handler:
  type: world
  events:
    on player drags in npc_shop:
    - if <context.raw_slots.contains_any[<util.list_numbers_to[53]>]>:
      - determine cancelled
    - if <context.inventory> == <context.clicked_inventory>:
      - determine cancelled
    on player clicks in npc_shop:
    - if <context.inventory> == <context.clicked_inventory>:
        - determine passively cancelled
        - if <context.item.has_nbt[Cost]>:
            - if <player.money.is[MORE].to[<context.item.nbt[Cost]>]>:
                - if <player.inventory.empty_slots> == 0:
                    - narrate "Your inventory has no space!"
                    - stop
            - take money quantity:<context.item.nbt[Cost]>
            - define Item <context.item>
            - adjust Item remove_nbt
            - adjust def:Item Lore:<context.item.lore.remove[<context.item.lore.size>]>
            - give <[Item]>
            - narrate "$<context.item.nbt[Cost]> has been removed from your wallet."
            - flag player TotalSpent:+:<context.item.nbt[Cost]>
            - stop
            - else:
                - narrate "You don't have enough money! Cost: $<context.item.nbt[Cost]> Your Money: $<player.money>"
                - stop