I want to enchant slot item

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

rook1e

New Member
Apr 9, 2020
6
0
0
28
I coded enchant GUI with enchanted stone item(enchant to stone).
Others' run in my intend.
But, enchantment doesn't work.
Enchant other parts' item work well.

How can I enchant inventory's slot item?

Code:
on inventory click:
  if inventory name of player's current inventory contains "&r&b%player%&r's upgrade table'":
    if clicked slot's type is nether star:
      cancel event
      set {_target} to slot 10 of player's current inventory
      set {_stonez} to slot 13 of player's current inventory
      set {_paperz} to slot 16 of player's current inventory

      if type of {_target} is not pickaxe or fishing rod or axe or sword or cap or boots or pants or chestpiece or bow or elytra or shield or shovel:
        message "{@s} Not enchantable item." to player
        close player's inventory
        exit

      if display name of {_stonez} is not "&r&a&lupgradestone":
        message "{@s} unvalid stone"
        close player's inventory
        exit

      if {_paperz} is not air:
        message "{@s} unvalid paper"
        close player's inventory
        exit

      set {_split::*} to uncoloured line 1 of {_stonez}'s lore split at " "
      set {_et} to {_split::1}


      set {_chkenc} to {enchant_type::%{_et}%} parsed as enchantment
      send {_chkenc}
      set {_level} to enchant level of {_chkenc} of {_target}
#     message "lv : %{_level}%" to player
      if {_level} is less than {_split::2} parsed as integer:
        set {_enchant_line} to "%{enchant_type::%{_et}%}% %{_split::2}%" parsed as enchantment type
        enchant {_target} with {_enchant_line}
        send player title "&aSuccess!" for 2 seconds
        set slot 13 of player's current inventory to air
      else if {_level} is not set:
        set {_enchant_line} to "%{enchant_type::%{_et}%}% %{_split::2}%" parsed as enchantment type
        enchant {_target} with {_enchant_line}
        send player title "&aSuccess!" for 2 seconds
        set slot 13 of player's current inventory to air
      else:
        message "{@s} &c higher level item." to player
        close player's inventory
        exit
 
Status
Not open for further replies.