- D1 Meta Docs - Denizen Script -
Home Page / Pi to one million places / Contact mcmonkey / Donate / Paste Scripts / Denizen Help /
You are browsing as a guest.
Login | Register








The script repo is an archive of historical scripts. For modern scripts, or to post your own, please use the Scripts forum section.





Gem Repairing


By Gershon12
Created: 2017/05/08 11:49:49 UTC-07:00 (7 years and 230 days ago)
Edited: 2017/05/08 11:49:49 UTC-07:00 (7 years and 230 days ago)
Likes: 0

Denizen Version: Denizen 101
Script Version: 1
Description:

This script uses the RepairGem item defined at the top of the script to repair items.

If a player has this RepairGem in their inventory,the next time they use an anvil it will ask them if they want to do a repair with a gem.
Repairing with a gem will repair an item to its full durability.

Note: This does not come with a way to distribute these gems, it's up to you to sell them, make them mob drops, quest rewards etc.

Disclaimer: the 'take' command in Denizen1 does not work properly, if the gem is not in the hotbar it will not be removed.


Download script | View raw script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
5900

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:!
          }





View History