Gem Repairing
By
Gershon12Created: 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 scriptRepairGem:
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