Paste #41739: Repo Script Gem Repairing

Date: 2017/05/08 11:49:49 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


RepairGem:
    type: item
    material: i@emerald
    display name: "<&a>Repair Gem"
    no_id: true
    lore:
    - "<&6>Used to repair your items."
ItemRepair:
    type: world
    events:
        on player right clicks anvil:
        - if <player.has_flag[repairing]> { 
          - determine cancelled
          }
        - if <player.has_flag[repair_status].not> && <player.inventory.contains[RepairGem]> { 
          - narrate "<&a>Do you want to use <&b>Repair Gems<&a> to fix your item?"
          - narrate "<&a>Say in chat <&b>yes <&a>or <&c>no"
          - flag repair_request:repair
          - determine cancelled
          }
        - if <player.flag[repair_status]> contains 'yes' { 
          - if <player.inventory.contains[RepairGem].not> { 
            - narrate "<&a>You do not have a <&b>Repair Gem<&a> in your inventory!"
            - narrate "<&a>Using regular repair mode instead."
            - flag repair_status:!
            } else if <player.inventory.contains[RepairGem]> {
              - flag repair_status:!
              - if <player.item_in_hand.repairable> {
                - determine cancelled passively
                - flag repairing:yes duration:4s
                - narrate "<&a>Beginnning gem repair!"
                - adjust <player.item_in_hand> "durability:0" save:item
                - displayitem <player.item_in_hand> <context.location.add[0,1,0]> duration:4s
                - take iteminhand
                - take RepairGem
                - wait 4s
                - give <entry[item].result>
                - playsound <player.location> sound:BLOCK_ANVIL_USE pitch:2
                - narrate "<&a>Repair complete!"
                } else {
                  - narrate "<&a>You need to hold a repairable item in your hand..."
                  }
              }
          } 
        on player chats:
        - if <player.has_flag[repair_request]> && <context.message.contains[no]> { 
          - flag repair_status:no duration:10s
          - narrate "<&a>Gem repair mode disabled, right-click anvil again to repair normally."
          - determine cancelled
          }
        - if <player.has_flag[repair_request]> && <context.message.contains[yes]> { 
          - flag repair_status:yes duration:10s
          - narrate "<&a>Gem repair mode enabled, right-click anvil again."
          - determine cancelled
          }
        - if <player.has_flag[repair_request]> { 
          - flag repair_status:!
          }