Solved Drag and Drop enchants does not work!

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Brodzy

New Member
Sep 4, 2021
8
0
1
20
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

  • 0.png
    0.png
    87.5 KB · Views: 108
Last edited:
You could use "on inventory click" to get the same effect but not as much struggle.
 
You could use "on inventory click" to get the same effect but not as much struggle.

Sorry ShyDoge, forgot to close the thread. I managed to get it working just fine, thank you for trying to help though :emoji_slight_smile:
 
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}
                set {_item} to enchanted book named "&eAvailable enchantments:"
                set line 1 of lore of {_item} to "&e&lSword &7Crippling"
                set line 2 of lore of {_item} to "&e&lBoots &7Speed"
                set line 3 of lore of {_item} to "&e&lChest &7Shockwave"
                set line 4 of lore of {_item} to "&e&lHelmet &7Escapist"
                set line 5 of lore of {_item} to "&e&lLegs &7Bounce"
                set slot 0 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 "&7Crippling"
                                set line 1 of lore of {_book} to "&7Chance to apply &eblindess &7and &e slowness effects"
                                set line 2 of lore of {_book} to "&7on the enemy!"
                                set line 3 of lore of {_book} to "&eSword Enchantment"
                                give player {_book}
                                send "&7Received the &eCrippling&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 "&7Shockwave"
                                set line 1 of lore of {_book} to "&7Chance to apply &enausea effect&7 and"
                                set line 2 of lore of {_book} to "&estrike lightning &7on the enemy!"
                                set line 3 of lore of {_book} to "&eChestplate Enchantment"
                                give player {_book}
                                send "&7Received the &eShockwave&7 Enchantment" to player
                        if {custom.enchant} is 4:
                                remove diamond block from player
                                set {_book} to enchanted book named "&7Escapist"
                                set line 1 of lore of {_book} to "&7Applies &einvisibility &7and &espeed effects"
                                set line 2 of lore of {_book} to "&7to the user when health reaches three hearts or lower!"
                                set line 3 of lore of {_book} to "&eHelmet Enchantment"
                                give player {_book}
                                send "&7Received the &eEscapist&7 Enchantment" to player
                        if {custom.enchant} is 5:
                                remove diamond block from player
                                set {_book} to enchanted book named "&7Bounce"
                                set line 1 of lore of {_book} to "&7Applies &ejump boost effect &7to the user!"
                                set line 2 of lore of {_book} to "&eLeggings Enchantment"
                                give player {_book}
                                send "&7Received the &eBounce&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 "&7Crippling":
                        if event-item is any swords:
                                if lore of event-item doesn't contain "&7Crippling":
                                        cancel the event
                                        set {_item} to event-item
                                        remove {_item} from player
                                        add "&7Crippling" to lore of {_item}
                                        give player {_item}
                                        send "&7[&e&lENCHANTER&7] &eCrippling&7 successfully applied!" to the player
                                        set cursor slot of player to air
                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 {_item} to event-item
                                        remove {_item} from player
                                        add "&7Speed" to lore of {_item}
                                        give player {_item}
                                        send "&7[&e&lENCHANTER&7] &eSpeed&7 successfully applied!" to the player
                                        set cursor slot of player to air
                if name of cursor slot of player is "&7Shockwave":
                        if event-item is any chestplate:
                                if lore of event-item doesn't contain "&7Shockwave":
                                        cancel the event
                                        set {_item} to event-item
                                        remove {_item} from player
                                        add "&7Shockwave" to lore of {_item}
                                        give player {_item}
                                        send "&7[&e&lENCHANTER&7] &eShockwave&7 successfully applied!" to the player
                                        set cursor slot of player to air
                if name of cursor slot of player is "&7Escapist":
                        if event-item is any helmet:
                                if lore of event-item doesn't contain "&7Escapist":
                                        cancel the event
                                        set {_item} to event-item
                                        remove {_item} from player
                                        add "&7Escapist" to lore of {_item}
                                        give player {_item}
                                        send "&7[&e&lENCHANTER&7] &eEscapist&7 successfully applied!" to the player
                                        set cursor slot of player to air
                if name of cursor slot of player is "&7Bounce":
                        if event-item is any leggings:
                                if lore of event-item doesn't contain "&7Bounce":
                                        cancel the event
                                        set {_item} to event-item
                                        remove {_item} from player
                                        add "&7Bounce" to lore of {_item}
                                        give player {_item}
                                        send "&7[&e&lENCHANTER&7] &eBounce&7 successfully applied!" to the player
                                        set cursor slot of player to air
                                        
on damage:
        if lore of attacker's weapon contains "&7Crippling":
                chance of 10%:
                        apply blindness 1 to victim for 3 seconds
                        apply slowness 2 to victim for 3 seconds

on damage:
        if lore of victim's chestplate contains "&7Shockwave":
                chance of 12%:
                        apply nausea 2 to attacker for 2 seconds
                        strike lightning effect at the attacker
                        damage attacker by 1 heart
                        
on damage:
        if victim's health <= 3:
                if lore of victim's helmet contains "&7Escapist":
                        apply swiftness 2 to victim for 5 seconds
                        apply invisibility to victim for 5 seconds
                        wait 5 seconds
                        remove swiftness from victim
                
every 2 seconds:
        loop all players:
                if lore of loop-player's boots contains "&7Speed":
                        apply swiftness 1 to loop-player for 2.01 seconds

every 2 seconds:
        loop all players:
                if lore of loop-player's leggings contains "&7Bounce":
                        apply jump boost 2 to loop-player for 2.01 seconds

Here's the working Skript if anyone wants to use it
 
Status
Not open for further replies.