Paste #38888: NPC Shops

Date: 2017/01/10 09:12:06 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


Events:
  type: world
  debug: true
  events:
    on player right clicks npc:
    - choose <npc.id>:
      - case "166":  
        - inventory open d:in@Farmer
    on player clicks in Farmer:
    - determine passively cancelled
    - flag player GUIItem:<context.item.material.name>
    - if <player.flag[GUIItem]> != black_stained_glass_pane {
      - inventory open d:in@Money
      }
    on player clicks in Money:
    - determine passively cancelled
    - choose <context.item.display>:
      - case "<&c>Sell 1":
        - if !<player.inventory.contains[<player.flag[GUIItem]>]> {
          - narrate "<&c>You do not have enough of this item."
          - queue clear
          }
        - take <player.flag[GUIItem]> from:<player.inventory>
        - define itemvalue <yaml[worth].read[worth.<player.flag[GUIItem]>]>
        - give money quantity:<def[itemvalue]>
        - narrate "<&e><def[itemvalue]> <&A>has been added to your account."

ClickedItem:
  type: item
  material: <player.flag[GUIItem].as_item>
  display name: <&9><&l><player.flag[GUIItem].as_item.material.name.replace[_].with[ ].replace[stalk].with[wart]>

Farmer:
  type: inventory
  title: <&9><&l>Available Items
  size: 45
  slots:
    - "[Filler] [Filler] [Filler] [Filler] [Filler] [Filler] [Filler] [Filler] [Filler]"
    - "[Filler] [WheatSeeds] [PumpkinSeeds] [MelonSeeds] [BeetrootSeeds] [Filler] [PotatoITEM] [CarrotITEM] [Filler]"
    - "[Filler] [Filler] [Filler] [Filler] [Filler] [Filler] [Filler] [Filler] [Filler]"
    - "[Filler] [EggITEM] [Filler] [RedMush] [BrownMush] [NethWart] [Filler] [ReedsITEM] [Filler]"
    - "[Filler] [Filler] [Filler] [Filler] [Filler] [Filler] [Filler] [Filler] [Filler]"

Money:
  type: inventory
  title: <&9><&l>Buy/Sell Goods
  size: 27
  slots:
    - "[Filler] [Filler] [Buy1] [Buy4] [Buy8] [Buy32] [Buy64] [Filler] [Filler]"
    - "[Filler] [Filler] [Filler] [Filler] [ClickedItem] [Filler] [Filler] [Filler] [Filler]"
    - "[Filler] [Filler] [Sell1] [Sell4] [Sell8] [Sell32] [Sell64] [Filler] [Filler]"