Solved Removing specific enchantment

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

archiebaker

New Member
Jun 5, 2017
8
0
0
26
Hey skripters :emoji_grinning:


How would I go about removing a specific enchantment from an item?

I.e. I have a sword with sharpness 3 and looting 3 but only want to remove the sharpness.

Thankyou
 
Here's a function I made to do this a bit ago
code_language.skript:
function removeEnch(i: item, e: enchantment):
  loop enchantments of {_i}:
    add "%loop-value% %level of loop-value of {_i}%" parsed as an enchantment type to {_e::*}
  disenchant {_i}
  loop {_e::*}:
    if "%loop-value%" does not contain "%{_e}%":
      enchant {_i} with loop-value
 
Here's a function I made to do this a bit ago
code_language.skript:
function removeEnch(i: item, e: enchantment):
  loop enchantments of {_i}:
    add "%loop-value% %level of loop-value of {_i}%" parsed as an enchantment type to {_e::*}
  disenchant {_i}
  loop {_e::*}:
    if "%loop-value%" does not contain "%{_e}%":
      enchant {_i} with loop-value
I don't know from which addon you got the enchantments of %itemstack% expression but it's not of vanilla Skript, you should tell him which addon haha.
 
this should work.
code_language.skript:
remove sharpness from player's tool
'sharpness' can't be removed from a slot because the former is neither an item type nor an item stack

:/
[doublepost=1497020525,1497019061][/doublepost]
Here's a function I made to do this a bit ago
code_language.skript:
function removeEnch(i: item, e: enchantment):
  loop enchantments of {_i}:
    add "%loop-value% %level of loop-value of {_i}%" parsed as an enchantment type to {_e::*}
  disenchant {_i}
  loop {_e::*}:
    if "%loop-value%" does not contain "%{_e}%":
      enchant {_i} with loop-value


Tried using this yet it seems to remove enchantments other than the one specified in the function. It also seems too not give the right levels back of other enchantments :/


Perhaps i'm using it wrong though

EDIT: I didn't indent the code in the right places, silly me
 
Last edited by a moderator:
Status
Not open for further replies.