No loop that matches loop-value

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

pokw

Active Member
Jun 3, 2019
53
1
8
Not sure why it says there's no loop here, any ideas?

Code:
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}%":
 

Attachments

  • unknown.png
    unknown.png
    45 KB · Views: 83
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:
function removeEnch(i: item, e: enchantment):
    loop enchantments of {_i}:
        set {_ench} to "%loop-value%"
        add "%(length of {_ench}-2) first characters of {_ench}% %enchantment level of loop-value%" parsed as enchantment type to {_e::*}
    disenchant {_i}
    loop {_e::*}:
        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:
some loop:
  add 1 to {_i}
  set {_list::%{_i}%} to object
 
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:
loop 10 times:
  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.
 
Last edited:
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:
loop 10 times:
  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.
Currently using this code now, I guess:
{_i} with ({_ench} parsed as enchantment type)
isn't enchanting it?
Code:
function removeEnch(i: item, e: enchantment type) :: item:

    loop enchantments of {_i}:
        set {_e} to "%loop-value%" parsed as enchantment type
        set {_l} to level of {_e} of {_i}
        add "%loop-value% %{_e}%" to {_e::*}
        disenchant {_i}
        broadcast "1"
    loop {_e::*}:
        broadcast "2"
        set {_ench} to loop-value
        enchant {_i} with ({_ench} parsed as enchantment type)
    return {_i}
Tried "%loop-value%", loop-value, {_ench}, "%{_ench}%", etc. for that line btw
 
You dont answered about version of Skript?
If you need simply function to remove enchantments you can use:
Code:
remove %enchantments% from enchantments of %itemtype%
 
You dont answered about version of Skript?
If you need simply function to remove enchantments you can use:
Code:
remove %enchantments% from enchantments of %itemtype%
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.
 
Status
Not open for further replies.