Paste #76112: Untitled Paste

Date: 2020/10/01 09:36:52 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:
        - flag player npc_name:<npc.name>
        - inventory open d:npc_menu
npc_menu:
  type: inventory
  inventory: CHEST
  title: "Conversando com <player.flag[npc_name]>"
  size: 45
  slots:
  - [] [] [] [] [npc_menu_talk] [] [] [] []
  - [] [] [] [] [npc_menu_buy] [] [] [] []
  - [] [] [] [] [npc_menu_sell] [] [] [] []
  - [] [] [] [] [npc_menu_quest] [] [] [] []
  - [] [] [] [] [npc_menu_exit] [] [] [] []
npc_shop:
  type: inventory
  inventory: CHEST
  title: "           Loja (pagina <player.flag[page]>)"
  size: 45
  slots:
  - [] [] [] [] [] [] [] [] []
  - [] [] [] [] [] [] [] [] []
  - [] [] [] [] [] [] [] [] []
  - [] [] [] [] [] [] [] [] []
  - [] [] [] [] [] [] [] [] []
  Procedural Items:
  - narrate <player.flag[pages].get[1]>
  - determine <yaml[npc_shop].read[<player.flag[pages].get[<player.flag[page]>]>]>
npc_quest:
  type: inventory
  inventory: CHEST
  title: "               Missões"
  size: 54
  slots:
  - [npc_menu_back] [] [] [] [] [] [] [] []
  - [] [] [] [] [] [] [] [] []
  - [] [] [] [] [] [] [] [] []
  - [] [] [] [] [] [] [] [] []
  - [] [] [] [] [] [] [] [] []
  - [] [] [] [] [] [] [] [] []
npc_menu_talk:
  type: item
  material: player_head
  display name: Conversar
npc_menu_buy:
  type: item
  material: hopper_minecart
  display name: Comprar
npc_menu_sell:
  type: item
  material: chest_minecart
  display name: Vender
npc_menu_quest:
  type: item
  material: filled_map
  display name: Missões
npc_menu_back:
  type: item
  material: player_head
  mechanisms:
    skull_skin: b3d33981-7d91-49b9-8677-b37a32dd1069|eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDgzNDhhYTc3ZjlmYjJiOTFlZWY2NjJiNWM4MWI1Y2EzMzVkZGVlMWI5MDVmM2E4YjkyMDk1ZDBhMWYxNDEifX19
  display name: Voltar
npc_menu_next_page:
  type: item
  material: player_head
  mechanisms:
    skull_skin: 0bba93e1-2401-47c4-88d3-418d7783d2a9|eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDlkMzM0YmYzM2YyZTU2NzdmYjE3NGQ0NzJiYjc2MWQ4NzhkMWE2NTc5ZWMxZTdiMjdkOWRkNTQ1Yzk3M2MifX19
  display name: Pagina <player.flag[page].add_int[1]>
npc_menu_back_page:
  type: item
  material: player_head
  mechanisms:
    skull_skin: 0dfe5685-3a24-4184-8b30-189e737d03ac|eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTA2NTM2Y2I2ZGUwZDA4YzJkNzAxMjg1NGVmYTI4MTYyMjUxZWU2ZTlmODFmZTZjY2MyOTk4M2M4NDVkNmI1In19fQ==
  display name: Pagina <player.flag[page].sub[1]>
npc_menu_exit:
  type: item
  material: barrier
  display name: Sair
npc_talk:
  type: task
  definitions: name
  script:
    - narrate "<&b><[name]> <&f>to you<&co> <&2> hello world"
    - flag player npc_name:!
npc_menu_handler:
  type: world
  events:
    on player clicks npc_menu_next_page in npc_shop:
    - if <player.flag[pages].size> == <player.flag[page]>:
      - stop
    - flag player page:++
    - inventory open d:npc_shop
    on player clicks npc_menu_back_page in npc_shop:
    - if <player.flag[page]> == 1:
      - stop
    - flag player page:--
    - inventory open d:npc_shop
    on player clicks npc_menu_talk in npc_menu:
    - inventory close
    - run npc_talk def:<player.flag[npc_name]>
    on player clicks npc_menu_buy in npc_menu:
    - yaml load:/Shops/npc_shop.yml id:npc_shop
    - wait 1t
    - flag player page:1
    - flag player pages:!|<yaml[npc_shop].list_keys[].filter[contains[buy]]>
    - inventory open d:npc_shop
    on player clicks npc_menu_sell in npc_menu:
    - yaml load:/Shops/npc_shop.yml id:npc_shop
    - wait 1t
    - flag player page:1
    - flag player pages:!|<yaml[npc_shop].list_keys[].filter[contains[sell]]>
    - inventory open d:npc_shop
    on player clicks npc_menu_quest in npc_menu:
    - inventory open d:npc_quest
    on player clicks npc_menu_exit in npc_menu:
    - inventory close
    on player clicks npc_menu_back in npc_shop:
    - inventory open d:npc_menu
    - flag player pages:!
    on player clicks npc_menu_back in npc_quest:
    - inventory open d:npc_menu
    on player clicks in npc_menu priority:100:
    - if <context.inventory> == <context.clicked_inventory>:
      - determine cancelled
    on player drags in npc_menu priority:100:
    - if <context.raw_slots.contains_any[<util.list_numbers_to[53]>]>:
      - determine cancelled
    - if <context.inventory> == <context.clicked_inventory>:
      - determine cancelled
    - if <context.item.has_nbt[ShopMenuItem]> || <context.item.has_nbt[Cost]>:
      - determine cancelled
    on player clicks in npc_quest priority:100:
    - if <context.inventory> == <context.clicked_inventory>:
      - determine cancelled
    on player drags in npc_quest priority:100:
    - if <context.raw_slots.contains_any[<util.list_numbers_to[53]>]>:
      - determine cancelled
    - if <context.inventory> == <context.clicked_inventory>:
      - determine cancelled
    - if <context.item.has_nbt[ShopMenuItem]> || <context.item.has_nbt[Cost]>:
      - determine cancelled
npc_shop_handler:
  type: world
  events:
    on player opens npc_shop:
    - inventory set destination:<context.inventory> origin:npc_menu_back slot:1
    - if <player.flag[page]> != 1:
      - inventory set destination:<context.inventory> origin:npc_menu_back_page slot:37
    - if <player.flag[page]> < <player.flag[pages].size>:
      - inventory set destination:<context.inventory> origin:npc_menu_next_page slot:45
    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
    - if <context.item.has_nbt[ShopMenuItem]> || <context.item.has_nbt[Cost]>:
      - 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.inventory.empty_slots> == 0:
          - narrate "Your inventory has no space!"
          - stop
        - if <context.item.lore.contains_any_text[Sell]>:
          - if !<player.inventory.contains.material[<context.item.material>].quantity[<context.item.quantity>]>:
            - narrate "You don't have enough item!"
            - stop
          - else:
            - take material:<context.item.material> quantity:<context.item.quantity>
            - give money quantity:<context.item.nbt[Cost]>
            - narrate "$<context.item.nbt[Cost]> has been deposit to your wallet."
            - narrate "<green>Balance: <red>$<player.money>"
        - else:
          - if <player.money.is[MORE].to[<context.item.nbt[Cost]>]>:
            - take money quantity:<context.item.nbt[Cost]>
            - define Item <context.item>
            - adjust def: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."
            - narrate "<green>Balance: <red>$<player.money>"
            - 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