Anyone who can help with a drag and drop enchantment skript?

  • 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 community!

    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!

Tris

Member
Oct 18, 2024
2
0
1
Hi I'm trying to make a drag and drop skript in 1.8.9


on inventory click:
set {_tool} to clicked item
event-item is any pickaxe:
player's cursor slot is a enchanted book:
send "test2"
player's cursor slot is a enchanted book of fortune 4:
cancel event
enchant {_tool} with fortune 4
set cursor slot of player to air
send "&aSuccess!"
wait 2 ticks
set cursor slot of player to air



I can get everything to work except for enchanting. I tried using "player's tool" but then it only enchant if the player is holdning the pickaxe.


I hope someone can help
 
Hi I'm trying to make a drag and drop skript in 1.8.9


on inventory click:
set {_tool} to clicked item
event-item is any pickaxe:
player's cursor slot is a enchanted book:
send "test2"
player's cursor slot is a enchanted book of fortune 4:
cancel event
enchant {_tool} with fortune 4
set cursor slot of player to air
send "&aSuccess!"
wait 2 ticks
set cursor slot of player to air



I can get everything to work except for enchanting. I tried using "player's tool" but then it only enchant if the player is holdning the pickaxe.


I hope someone can help
Can you give a description of exactly what you're trying to do?
 
Can you give a description of exactly what you're trying to do?

Example

If you have a fortune 4 book you can open you're inventory drag it over you're pickaxe, then the pickaxe get enchanted with fortune 4
 
Code:
# I ADDED SOME OF THE THINGS YOU NEED TO SEND TO THE PLAYER. IF YOU WANT TO ADD THE REST, YOU CAN DO IT ON YOUR OWN TIME.

command /toolenchant:
    aliases: /toolench
    trigger:
        # We're seeing if the variable is not set (or false).
        # That way, we know if the player is just trying to access their inventory normally, or if they're trying to enchant an item.
        if {opened::%player's uuid%} != true:
            send "&aClick the item that you want to enchant!"
            set {opened::%player's uuid%} to true # literally what I was just talking about.
            wait 0.5 seconds # this is to give the player a bit of time to read the message.
            open player's inventory to player



on inventory click:
    if {opened::%player's uuid%} is true: # we talked about this a bit ago.
        event-inventory is player's inventory # making sure the inventory the click happened was the player's.
        if {clicked::%player's uuid%::1} is not set: # seeing if we already have the item we need to enchant.
            if event-item is any pickaxe:
                cancel event # making sure the player doesn't pick up the item.
                set {clicked::%player's uuid%::1} to event-item # setting the item we need to enchant.
                set {clicked::%player's uuid%::2} to event-slot
                set {fc::%player's uuid%} to true # letting us know that we closed the inventory and not the player
                close event-inventory
                send "&aNow click the book that you want to enchant the item with!&r" # it might produce an error here since we already closed the inventory, but idk
                wait 0.5 seconds
                open player's inventory to player
        else:
            if event-item is any enchanted book:
                cancel event
                set {_ench} to event-item's enchantment # getting the enchantment of the book
                if {_ench} is set:
                    enchant {clicked::%player's uuid%::1} with {_ench} # enchanting the item
                    set slot {clicked::%player's uuid%::2} to {clicked::%player's uuid%::1} # replacing the previous item with the enchanted one
                    delete {clicked::%player's uuid%::*}
                    delete {opened::%player's uuid%} # instead of setting it to false, we delete it so that excess storage doesn't get taken up.
                    close event-inventory


on inventory open:
    if {fc::%player's uuid%} is true: # if we closed the inventory
        delete {fc::%player's uuid%} # we opened it back up so we don't need this var anymore

on inventory close:
    if {opened::%player's uuid%} is true: # if we opened the inventory
        if {fc::%player's uuid%} is true: # if we closed the inventory
            stop # ignores the rest of the code
        # deletes variables (if the player closed the inventory)
        delete {clicked::%player's uuid%::*}
        delete {opened::%player's uuid%}

This should be what you're looking for.

I attached a version with no comments if you want that, although I recommend looking through the one with comments to see how the skript works.
 

Attachments

  • fix5-v1.0.sk
    1.8 KB · Views: 131