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?
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