Checking if text is in lore

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

Le4ft

Member
Jun 26, 2023
20
0
1
Hi,
I'm trying to make checks for enchantments/lores. I have this code and I need to check if the lore ({_ttench}) is already in the lore, I tried to loop, but it only checks the first line of the items lore. Does anyone know how to do that?
code_language.skript:
function enchantTierII(p: player):
    if name of {_p}'s held item contains "Tier I Sword":

        set {_ttench} to a random element out of {swordench::*}
        set {_ttier} to a random integer between 1 and 3

        if {_ttier} = 1:
            set {_roman} to "I"
        if {_ttier} = 2:
            set {_roman} to "II"
        if {_ttier} = 3:
            set {_roman} to "III"

        loop lore of {_p}'s tool:
            if loop-value contains "%{_ttench}%":
                set {_ttench} to a random element out of {swordench::*}
            else:
                set {_tfinal} to "%{_ttench}% %{_roman}%"
                set name of {_p}'s tool to "&cTier II Sword"

                addLoreSword({_p}, {_tfinal}, {_tfinal})
                msgEnch({_p}, "Tier II Sword", {_ttench})
                send "%loop-value%" to {_p}
                stop loop
 
You should NOT use lore to store data, use NBT to store data and lore to display it.