Issues using variables to check level of 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 community!

    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!

Oct 28, 2019
26
0
1
I'm working on a way to override the floor function on anvil enchantment combination: if a item has a enchantment greater than the max when combining it, the level will remain instead of being reset to the max level.
Code:
on inventory open:
    wait 1 tick #required to get correct inventory check
    if type of event-inventory is anvil inventory:
        while type of player's current inventory is anvil inventory:
            wait 1 tick
            if item in slot 2 of player's current inventory is set:
                loop slot 2 of player's current inventory's enchantments:
                    set {_L} to "%enchantment level of loop-value%" #gets level of enchantment
                    set {_enchantment} to "%loop-value%"
                    replace {_L} with "" in {_enchantment} #removes level of enchantment
                    replace " " with "" in {_enchantment}
                    set {_enchantment} to {_enchantment} parsed as enchantment type
                    set {_S1} to item in slot 1 of player's current inventory
                    set {_L1} to level of {_enchantment} of {_S1} #always gets set to null. doesn't recognize variables as enchantment
I think the code cannot recogize enchantments properly inside variables does anyone know a work-around?