1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

No loop that matches loop-value

Discussion in 'Skript' started by pokw, Sep 5, 2022.

Thread Status:
Not open for further replies.
  1. pokw

    pokw Active Member

    Joined:
    Jun 3, 2019
    Messages:
    52
    Likes Received:
    1
    Not sure why it says there's no loop here, any ideas?

    Code (Text):
    1. function removeEnch(i: item, e: enchantment):
    2.  
    3.     loop enchantments of {_i}:
    4.         add "%loop-value% %level of loop-value of {_i}%" parsed as an enchantment type to {_e::*}
    5.     disenchant {_i}
    6.     loop {_e::*}:
    7.         if "%loop-value%" does not contain "%{_e}%":
     

    Attached Files:

  2. lotzy

    lotzy Active Member

    Joined:
    Mar 15, 2022
    Messages:
    179
    Likes Received:
    26
    Enchantment type from item contains level of enchantment.
    Parse give you error because you try making something like this:
    add "sharpness 1 %level of sharpness 1 of itemtype%" parsed as an enchantment type to {_e::*}
    if you wanna get level of enchantment use:
    %enchantment level of loop-value%
    Code (Text):
    1. function removeEnch(i: item, e: enchantment):
    2.     loop enchantments of {_i}:
    3.         set {_ench} to "%loop-value%"
    4.         add "%(length of {_ench}-2) first characters of {_ench}% %enchantment level of loop-value%" parsed as enchantment type to {_e::*}
    5.     disenchant {_i}
    6.     loop {_e::*}:
    7.         if "%loop-value%" does not contain "%{_e}%":
    Don't use 'add' with arrays, its so long, because on every 'add' you iterate list, make it like this:
    Code (Text):
    1. some loop:
    2.   add 1 to {_i}
    3.   set {_list::%{_i}%} to object
     
  3. pokw

    pokw Active Member

    Joined:
    Jun 3, 2019
    Messages:
    52
    Likes Received:
    1
     
  4. lotzy

    lotzy Active Member

    Joined:
    Mar 15, 2022
    Messages:
    179
    Likes Received:
    26
    What version of skript are you using?
    On 2.6.3 my code works fine, but if you have lower version I think you need put loop-value to variable before get level of enchantment, its old bug with parser, also with code like:

    Code (Text):
    1. loop 10 times:
    2.   set {_list::%loop-value+1%} to loop-value
    {_list::%loop-value+1%} except parse error, but in 2.6.3 this bug fixed anyway

    In situations like this thread I prefer to use reflection code with Skript-reflect, its faster than spend some hours to solve problems with parser.
     
    #4 lotzy, Sep 5, 2022
    Last edited: Sep 5, 2022
  5. pokw

    pokw Active Member

    Joined:
    Jun 3, 2019
    Messages:
    52
    Likes Received:
    1
    Currently using this code now, I guess:
    {_i} with ({_ench} parsed as enchantment type)
    isn't enchanting it?
    Code (Text):
    1. function removeEnch(i: item, e: enchantment type) :: item:
    2.  
    3.     loop enchantments of {_i}:
    4.         set {_e} to "%loop-value%" parsed as enchantment type
    5.         set {_l} to level of {_e} of {_i}
    6.         add "%loop-value% %{_e}%" to {_e::*}
    7.         disenchant {_i}
    8.         broadcast "1"
    9.     loop {_e::*}:
    10.         broadcast "2"
    11.         set {_ench} to loop-value
    12.         enchant {_i} with ({_ench} parsed as enchantment type)
    13.     return {_i}
    Tried "%loop-value%", loop-value, {_ench}, "%{_ench}%", etc. for that line btw
     
  6. lotzy

    lotzy Active Member

    Joined:
    Mar 15, 2022
    Messages:
    179
    Likes Received:
    26
    You dont answered about version of Skript?
    If you need simply function to remove enchantments you can use:
    Code (Text):
    1. remove %enchantments% from enchantments of %itemtype%
     
  7. pokw

    pokw Active Member

    Joined:
    Jun 3, 2019
    Messages:
    52
    Likes Received:
    1
    I'm using Minehut and I don't know what version of skript it uses.
    When I said that line wasn't enchanting it, I meant it now disenchants but doesn't reenchant at all. It broadcasts "1" and "2" but doesn't actually enchant it.
     
Thread Status:
Not open for further replies.

Share This Page

Loading...