Enchants Help

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

Status
Not open for further replies.
Oct 18, 2017
11
0
0
code_language.skript:
on inventory click:
    set {pickaxe.%player%} to clicked item

    #==================#
    # Pickaxe Enchants #
    #==================#

    if {pickaxe.%player%} is any pickaxe:
        set {enchant.%player%} to cursor item of player
        if name of {enchant.%player%} contains "Enchant Particle":
            if line 1 of lore of {pickaxe.%player%} is not set:
                cancel event
                set {lore.%player%} to lore of {enchant.%player%}
                set lore of {pickaxe.%player%} to "%{lore.%player%}%"
                set cursor of player to air
                message "1"
                stop
            else if line 3 of lore of {pickaxe.%player%} is set:
                cancel event
                message "&cYou can only have 3 enchants per item!"
                stop
            else if line 2 of lore of {pickaxe.%player%} is set:
                if line 1 of lore of {pickaxe.%player%} is not line 1 of lore of {enchant.%player%}:
                    if line 2 of lore of {pickaxe.%player%} is not line 2 of lore of {enchant.%player%}:
                        cancel event
                        set {lore.%player%} to lore of {enchant.%player%}
                        set {line1.%player%} to line 1 of lore of {pickaxe.%player%}
                        set {line2.%player%} to line 2 of lore of {pickaxe.%player%}
                        set lore of {pickaxe.%player%} to "%{line1.%player%}%||%{line2.%player%}%||%{lore.%player%}%"
                        set cursor of player to air
                        message "3"
                        stop
                    else:
                        cancel event
                        message "&cYou already have this enchant on your item!"
                        stop
                else:
                    cancel event
                    message "&cYou already have this enchant on your item!"
                    stop
            else if line 1 of lore of {pickaxe.%player%} is set:
                if line 1 of lore of {pickaxe.%player%} is not line 1 of lore of {enchant.%player%}:
                    cancel event
                    set {lore.%player%} to lore of {enchant.%player%}
                    set {line1.%player%} to line 1 of lore of {pickaxe.%player%}
                    set lore of {pickaxe.%player%} to "%{line1.%player%}%||%{lore.%player%}%"
                    set cursor of player to air
                    message "2"
                    stop
                else:
                    cancel event
                    message "&cYou already have this enchant on your item!"
                    stop

So this code works, but I don't know how to check if an enchant is already on the item, in which if it is, I would want to upgrade it from level 1 to level 2. I have started some code but not sure where to go. Pretty sure you would have to check if it contains part of the enchant, e.g. if I had Smelt I on a pickaxe, and tried to put smelt II on it would check if Smelt I is there and delete Smelt I and add Smelt II. If you have any questions don't hesitate to ask :emoji_slight_smile: Thanks!

code_language.skript:
    if lore of {pickaxe.%player%} contains {enchant.lore.::*}
    add line 1 of lore of {enchant.%player%} seperated by " " to {enchant.lore.::*}

Secondly, if there is any way to condense the first skript please let me know :emoji_slight_smile:
 
Status
Not open for further replies.