Code:
command /enchanter:
permission: enchanter.use
permission message: &cSomething broke...
trigger:
set {_gui} to a new chest inventory with 1 row with name " &e&k&lAA&r &7&lENCHANTER &e&k&lAA&r"
set {_item} to nether star named "&eRandom Custom Enchantment"
set line 1 of lore of {_item} to "&7Costs &e1x Diamond Block&7!"
set slot 4 of {_gui} to {_item}
open {_gui} to player
on inventory click:
if name of event-inventory is " &e&k&lAA&r &7&lENCHANTER &e&k&lAA&r":
if index of event-slot = 4:
cancel event
if player has diamond block:
set {custom.enchant} to random integer between 1 and 5
if {custom.enchant} is 1:
remove diamond block from player
set {_book} to enchanted book named "&7Blindness"
set line 1 of lore of {_book} to "&7Chance to apply &eblindness effect &7on the enemy!"
set line 2 of lore of {_book} to "&eSword Enchantment"
give player {_book}
send "&7Received the &eBlindness&7 Enchantment" to player
if {custom.enchant} is 2:
remove diamond block from player
set {_book} to enchanted book named "&7Speed"
set line 1 of lore of {_book} to "&7Applies &espeed effect &7to the user!"
set line 2 of lore of {_book} to "&eBoots Enchantment"
give player {_book}
send "&7Received the &eSpeed&7 Enchantment" to player
if {custom.enchant} is 3:
remove diamond block from player
set {_book} to enchanted book named "&7Shock"
set line 1 of lore of {_book} to "&7Chance to &estrike lightning &7 on the enemy!"
set line 2 of lore of {_book} to "&eChestplate Enchantment"
give player {_book}
send "&7Received the &eShock&7 Enchantment" to player
if {custom.enchant} is 4:
remove diamond block from player
set {_book} to enchanted book named "&7Afterlife"
set line 1 of lore of {_book} to "&7Restores one heart and applies &einvisibility effect &7to the user on death!"
set line 2 of lore of {_book} to "&eHelmet Enchantment"
give player {_book}
send "&7Received the &eAfterlife&7 Enchantment" to player
if {custom.enchant} is 5:
remove diamond block from player
set {_book} to enchanted book named "&7PLACEHOLDER"
set line 1 of lore of {_book} to "PLACEHOLDER"
set line 2 of lore of {_book} to "PLACEHOLDER"
give player {_book}
send "&7Received the &e?&7 Enchantment" to player
close player's inventory
on inventory click:
if cursor slot of player is enchanted book:
if name of cursor slot of player is "&7Blindness":
if event-item is any swords:
if lore of event-item doesn't contain "&7Blindness":
cancel the event
set lore of event-item to "%lore of event-item%||&7Blindess"
send "&eBlindess&7 successfully applied!" to the player
set cursor slot of player to air
#I tried to make a work around here but obviously still cannot set event-item
#to anything. Also tried it as set {_enchantee} to event-item but still no luck.
if name of cursor slot of player is "&7Speed":
if event-item is any boots:
if lore of event-item doesn't contain "&7Speed":
cancel the event
set event-item to {_enchantee}
remove event-item from player
add "%lore of event-item%||&7Speed" to lore of {_enchantee}
give player {_enchantee}
send "&eSpeed&7 successfully applied!" to the player
set cursor slot of player to air
if name of cursor slot of player is "&7Shock":
if event-item is any chestplate:
if lore of event-item doesn't contain "&7Shock":
cancel the event
set event-item to {_enchantee}
remove event-item from player
add "%lore of event-item%||&7Shock" to lore of {_enchantee}
give player {_enchantee}
send "&eShock&7 successfully applied!" to the player
set cursor slot of player to air
if name of cursor slot of player is "&7Afterlife":
if event-item is any helmet:
if lore of event-item doesn't contain "&7Afterlife":
cancel the event
set event-item to {_enchantee}
remove event-item from player
add "%lore of event-item%||&7Afterlife" to lore of {_enchantee}
give player {_enchantee}
send "&eAfterlife&7 successfully applied!" to the player
set cursor slot of player to air
Errors on reload shown in the attached image
Skript Version: 2.5.3
Minecraft Version: 1.17.1
Addons (possibly unneccesary): TuSKe, SkriptGUI
I am trying to make it so that the player is able to apply a custom enchantment by clicking an allowed item with an enchanted book with set names, and applying this name to the lore of the allowed item.
The book generates fine however it does not apply to an item.
For example, the Blindness book will not apply to a sword.
Attachments
Last edited: