Solved Custom Enchant Problem

  • 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.
Hi, I'm having an issue with this script I'm trying to make, sorry for the large and messy chunk of code. (If there is any tips on shortening it to reduce lag please leave your suggestions, thank you!)

Also, apologies if this is considered a messy thread post, I'm new to using forums, never really used forums on any website, I hope it's not too bad.

Anyway, the issue I'm having is when killing a blaze it always gives me:

- 55 xp with a sword that has both the "Blessed" and the "Angelic Blessing" enchant on it, no matter what level
- 15 xp with a sword that has just "Blessed" on it, no matter what level
- And 10 xp (base xp) with no enchant on it (works as intended)

As you see in the code, I'm trying to escalate the xp progressively based on level, but it seems like it's refusing to work the way I intended it to.

My guess is, "lore of attacker's tool contains "&7* (either enchant) (level)" does not fully read the roman numerals at the end of the lore, also known as "(level)" in my little example above.
If that's the case I don't have a clue on how to fix that.

Any ideas?

-------------------------------------------------

Addons

SkQuery
Skillet
TuSKe
skDragon
SkMorkaz

Skript Version

2.2-dev37c (Skript 2.2 bensku-dev37c)

code_language.skript:
on death of blaze:
    lore of attacker's tool contains "&7* &9Blessed I":
        lore of attacker's tool does not contain "&7* &dAngelic Blessing":
            remove all xp from drops
            give 15 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing I":
            remove all xp from drops
            give 20 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing II":
            remove all xp from drops
            give 25 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing III":
            remove all xp from drops
            give 30 experience to the attacker
            stop
    lore of attacker's tool contains "&7* &9Blessed II":
        lore of player's tool does not contain "&7* &dAngelic Blessing":
            remove all xp from drops
            give 20 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing I":
            remove all xp from drops
            give 25 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing II":
            remove all xp from drops
            give 30 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing III":
            remove all xp from drops
            give 35 experience to the attacker
            stop
    lore of attacker's tool contains "&7* &9Blessed III":
        lore of attacker's tool does not contain "&7* &dAngelic Blessing":
            remove all xp from drops
            give 30 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing I":
            remove all xp from drops
            give 35 experience to the attacker
            stop
        if lore of attacker's tool contains "&7* &dAngelic Blessing II":
            remove all xp from drops
            give 40 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing III":
            remove all xp from drops
            give 45 experience to the attacker
            stop
    lore of attacker's tool contains "&7* &9Blessed IV":
        lore of attacker's tool does not contain "&7* &dAngelic Blessing":
            remove all xp from drops
            give 40 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing I":
            remove all xp from drops
            give 45 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing II":
            remove all xp from drops
            give 50 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing III":
            remove all xp from drops
            give 55 experience to the attacker
            stop
    lore of attacker's tool contains "&7* &9Blessed V":
        lore of attacker's tool does not contain "&7* &dAngelic Blessing":
            remove all xp from drops
            give 50 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing I":
            remove all xp from drops
            give 55 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing II":
            remove all xp from drops
            give 60 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing III":
            remove all xp from drops
            give 65 experience to the attacker
            stop
    else:
        remove all xp from drops
        give 10 experience to the attacker
        stop
 
Hi, I'm having an issue with this script I'm trying to make, sorry for the large and messy chunk of code. (If there is any tips on shortening it to reduce lag please leave your suggestions, thank you!)

Also, apologies if this is considered a messy thread post, I'm new to using forums, never really used forums on any website, I hope it's not too bad.

Anyway, the issue I'm having is when killing a blaze it always gives me:

- 55 xp with a sword that has both the "Blessed" and the "Angelic Blessing" enchant on it, no matter what level
- 15 xp with a sword that has just "Blessed" on it, no matter what level
- And 10 xp (base xp) with no enchant on it (works as intended)

As you see in the code, I'm trying to escalate the xp progressively based on level, but it seems like it's refusing to work the way I intended it to.

My guess is, "lore of attacker's tool contains "&7* (either enchant) (level)" does not fully read the roman numerals at the end of the lore, also known as "(level)" in my little example above.
If that's the case I don't have a clue on how to fix that.

Any ideas?

-------------------------------------------------

Addons

SkQuery
Skillet
TuSKe
skDragon
SkMorkaz

Skript Version

2.2-dev37c (Skript 2.2 bensku-dev37c)

code_language.skript:
on death of blaze:
    lore of attacker's tool contains "&7* &9Blessed I":
        lore of attacker's tool does not contain "&7* &dAngelic Blessing":
            remove all xp from drops
            give 15 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing I":
            remove all xp from drops
            give 20 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing II":
            remove all xp from drops
            give 25 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing III":
            remove all xp from drops
            give 30 experience to the attacker
            stop
    lore of attacker's tool contains "&7* &9Blessed II":
        lore of player's tool does not contain "&7* &dAngelic Blessing":
            remove all xp from drops
            give 20 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing I":
            remove all xp from drops
            give 25 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing II":
            remove all xp from drops
            give 30 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing III":
            remove all xp from drops
            give 35 experience to the attacker
            stop
    lore of attacker's tool contains "&7* &9Blessed III":
        lore of attacker's tool does not contain "&7* &dAngelic Blessing":
            remove all xp from drops
            give 30 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing I":
            remove all xp from drops
            give 35 experience to the attacker
            stop
        if lore of attacker's tool contains "&7* &dAngelic Blessing II":
            remove all xp from drops
            give 40 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing III":
            remove all xp from drops
            give 45 experience to the attacker
            stop
    lore of attacker's tool contains "&7* &9Blessed IV":
        lore of attacker's tool does not contain "&7* &dAngelic Blessing":
            remove all xp from drops
            give 40 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing I":
            remove all xp from drops
            give 45 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing II":
            remove all xp from drops
            give 50 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing III":
            remove all xp from drops
            give 55 experience to the attacker
            stop
    lore of attacker's tool contains "&7* &9Blessed V":
        lore of attacker's tool does not contain "&7* &dAngelic Blessing":
            remove all xp from drops
            give 50 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing I":
            remove all xp from drops
            give 55 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing II":
            remove all xp from drops
            give 60 experience to the attacker
            stop
        lore of attacker's tool contains "&7* &dAngelic Blessing III":
            remove all xp from drops
            give 65 experience to the attacker
            stop
    else:
        remove all xp from drops
        give 10 experience to the attacker
        stop
It's probably because you're using the contains condition, which will also be true for something like "test1||hi" contains "test" (|| being the lore seperator).
Tested with (return true):
code_language.skript:
command /lore:
    trigger:
        set {_t} to stone
        set line 1 of lore of {_t} to "test1"
        set line 2 of lore of {_t} to "hi"
        if lore of {_t} contains "test":
            message "true"
        else:
            message "false"
you can use something like this:
true:
code_language.skript:
command /lore:
    trigger:
        set {_t} to stone
        set line 1 of lore of {_t} to "test"
        set line 2 of lore of {_t} to "hi"
        set {_t::*} to split lore of {_t} at "||"
        if {_t::*} contains "test":
            message "true"
        else:
            message "false"
false:
code_language.skript:
command /lore:
    trigger:
        set {_t} to stone
        set line 1 of lore of {_t} to "tes1t"
        set line 2 of lore of {_t} to "hi"
        set {_t::*} to split lore of {_t} at "||"
        if {_t::*} contains "test":
            message "true"
        else:
            message "false"
 
Setting the lore to a specific line won't work because it's a enchant based script, meaning when applying said enchant it isn't specified to a specific lore line. Also what does separating the lore have to do with changing how the function of the enchant works? Apologies if I'm missing something.

Also this code isn't supposed to be run from a command, it's just detecting if player's sword has specific lore (enchants) with certain levels and modifying the XP on death (of blaze)

The issue I'm having is that

code_language.skript:
    lore of attacker's tool contains "&7* &9Blessed I":
        lore of attacker's tool does not contain "&7* &dAngelic Blessing":
            remove all xp from drops
            give 15 experience to the attacker
            stop

Is working the same way as

code_language.skript:
    lore of attacker's tool contains "&7* &9Blessed II":
        lore of attacker's tool does not contain "&7* &dAngelic Blessing":
            remove all xp from drops
            give 20 experience to the attacker
            stop

Despite there being a completely different roman numeral at the end of the lore. (Blessed II gives 15 xp even though it's supposed to give 20)
Is it because it's not mixed together with the "Blessed"? (ex: "BlessedII" rather than "Blessed II")

Again, sorry if I'm not quite understanding what you're trying to say here.
[doublepost=1538522557,1538519744][/doublepost]Upon further testing, it seems that skript does not read the other half of the lore, which is strange.
I tried using this:

code_language.skript:
on death of blaze:
    lore of attacker's tool contains "&9Blessed 1":
        lore of attacker's tool does not contain "&7* &dAngelic Blessing":
            remove all xp from drops
            give 15 experience to the attacker
            stop
    lore of attacker's tool contains "&9Blessed 2":
        lore of player's tool does not contain "&7* &dAngelic Blessing":
            remove all xp from drops
            give 20 experience to the attacker
            stop

And instead of giving me 15 xp despite the difference in numbers it's giving me 15 xp for a sword with Blessed 1 and not using the code for Blessed 2 and just doing what it would normally do for a blaze death. (Dropping an XP orb of 10 and 'X' amount of blaze rod(s))

If someone can help figure out why this is the case and potentially fix this script (with the roman numerals preferably, not the numbers) then I will give you a hug <3

Seriously though, I'm completely stumped on why this isn't working.
 
Setting the lore to a specific line won't work because it's a enchant based script, meaning when applying said enchant it isn't specified to a specific lore line. Also what does separating the lore have to do with changing how the function of the enchant works? Apologies if I'm missing something.

Also this code isn't supposed to be run from a command, it's just detecting if player's sword has specific lore (enchants) with certain levels and modifying the XP on death (of blaze)

The issue I'm having is that

code_language.skript:
    lore of attacker's tool contains "&7* &9Blessed I":
        lore of attacker's tool does not contain "&7* &dAngelic Blessing":
            remove all xp from drops
            give 15 experience to the attacker
            stop

Is working the same way as

code_language.skript:
    lore of attacker's tool contains "&7* &9Blessed II":
        lore of attacker's tool does not contain "&7* &dAngelic Blessing":
            remove all xp from drops
            give 20 experience to the attacker
            stop

Despite there being a completely different roman numeral at the end of the lore. (Blessed II gives 15 xp even though it's supposed to give 20)
Is it because it's not mixed together with the "Blessed"? (ex: "BlessedII" rather than "Blessed II")

Again, sorry if I'm not quite understanding what you're trying to say here.
[doublepost=1538522557,1538519744][/doublepost]Upon further testing, it seems that skript does not read the other half of the lore, which is strange.
I tried using this:

code_language.skript:
on death of blaze:
    lore of attacker's tool contains "&9Blessed 1":
        lore of attacker's tool does not contain "&7* &dAngelic Blessing":
            remove all xp from drops
            give 15 experience to the attacker
            stop
    lore of attacker's tool contains "&9Blessed 2":
        lore of player's tool does not contain "&7* &dAngelic Blessing":
            remove all xp from drops
            give 20 experience to the attacker
            stop

And instead of giving me 15 xp despite the difference in numbers it's giving me 15 xp for a sword with Blessed 1 and not using the code for Blessed 2 and just doing what it would normally do for a blaze death. (Dropping an XP orb of 10 and 'X' amount of blaze rod(s))

If someone can help figure out why this is the case and potentially fix this script (with the roman numerals preferably, not the numbers) then I will give you a hug <3

Seriously though, I'm completely stumped on why this isn't working.
The splitting is because of the way lore is stored. A item with lore "test" and "hello" (2 lines) will be saved as "test||hello". When using contains on text (not a list, and because of the reason I just explained lore is a single text) it will check if the string has the other string somewhere in itself. When using a list, it will check if the element is somewhere in that list. For example, "hello" contains "el" is true. "hello" and "bye" contains "el" is false. Since lore is a single text, it will check using the first method. So when you have a item with the lore "Blessed III", and check for if lore of tool of player contains "Blessed", it returns true and with yout code that will mean it thinks it's level 1 where in reality it's 3.
 
The splitting is because of the way lore is stored. A item with lore "test" and "hello" (2 lines) will be saved as "test||hello". When using contains on text (not a list, and because of the reason I just explained lore is a single text) it will check if the string has the other string somewhere in itself. When using a list, it will check if the element is somewhere in that list. For example, "hello" contains "el" is true. "hello" and "bye" contains "el" is false. Since lore is a single text, it will check using the first method. So when you have a item with the lore "Blessed III", and check for if lore of tool of player contains "Blessed", it returns true and with yout code that will mean it thinks it's level 1 where in reality it's 3.

I understand, but using 2 lines isn't going to be a viable option, so using "Blessed||III" to fix it isn't something I want to do.
Is there a way to fix it without separating it into different lines of lore?

So it works as "Blessed III" instead of "Blessed||III?"

It has to look like this:
2018-10-09_04.07.15.png


Not like this:
2018-10-09_04.07.16.png


I appreciate it if you can find a solution, thanks.
[doublepost=1539073255,1539072753][/doublepost]Also, one more thing, it also needs to be able to do stuff like this:
2018-10-09_04.17.34.png


or

2018-10-09_04.17.35.png


So stuff like "if the 1st line of tool is / contains" won't be viable

Anyway, thanks for the help
 
I understand, but using 2 lines isn't going to be a viable option, so using "Blessed||III" to fix it isn't something I want to do.
Is there a way to fix it without separating it into different lines of lore?

So it works as "Blessed III" instead of "Blessed||III?"

It has to look like this:
View attachment 2803

Not like this:
View attachment 2804

I appreciate it if you can find a solution, thanks.
[doublepost=1539073255,1539072753][/doublepost]Also, one more thing, it also needs to be able to do stuff like this:
View attachment 2805

or

View attachment 2806

So stuff like "if the 1st line of tool is / contains" won't be viable

Anyway, thanks for the help
That's not what I meant. Not at all. Can you at least try with the splitting (DONT change anything about the item) so that I can see if it works. Okay so I'll try to explain it one more time:
Statement 1: lore is stored as a single text with || seperating the lines.
Statement 2: the contains condition works differently with lists and non-lists (single text)
Statement 3: when using contains with lists, it basically loops the list and checks if the check value is the loop-value. If it is, it returns true
Statement 4: when using contains with a text, it check if the check string is somewhere in the text. If it is, it returns true.
When looking at statement 4, you can see that if "test" contains "s" will return true and if "* Blessed III" contains "Blessed" will also return true. This is what your code does right now, it checks if the lore (a string) contains "Blessed" (example). But the lore "* Blessed III" also contains "Blessed", which you don't want. Another solution to your problem will be to check for the highest levels of enchantment first, and the lowest (level 1, "* Blessed") last. You can also make Skript split the lore (NOT changing the item's lore) so that it will use statement 3's method instead of statement 4's method. Using statement 3, the second example (examples in bold) won't be true.
 
The problem is that if you have Angelic Blessing III your code will triger Angelic Blessing I, Angelic Blessing II and Angelic Blessing III, i fix your code, tell me if it worked for you:


code_language.skript:
on death of blaze:



#ORDER LUL ORDER :P

    if lore of attacker's tool contains "&7* &9Blessed V":
        if lore of attacker's tool contains "&7* &dAngelic Blessing III":
            remove all xp from drops
            give 20 experience to the attacker
            stop
        else if lore of attacker's tool contains "&7* &dAngelic Blessing II":
            remove all xp from drops
            give 25 experience to the attacker
            stop
        else if lore of attacker's tool contains "&7* &dAngelic Blessing I":
            remove all xp from drops
            give 30 experience to the attacker
            stop
        else:
            remove all xp from drops
            give 15 experience to the attacker
            stop
           
           
           
    else if lore of attacker's tool contains "&7* &9Blessed IV":
        if lore of attacker's tool contains "&7* &dAngelic Blessing III":
            remove all xp from drops
            give 25 experience to the attacker
            stop
        else if lore of attacker's tool contains "&7* &dAngelic Blessing II":
            remove all xp from drops
            give 30 experience to the attacker
            stop
        else if lore of attacker's tool contains "&7* &dAngelic Blessing I":
            remove all xp from drops
            give 35 experience to the attacker
            stop
        else:
            remove all xp from drops
            give 20 experience to the attacker
            stop
           
           
           
    else if lore of attacker's tool contains "&7* &9Blessed III":
        if lore of attacker's tool contains "&7* &dAngelic Blessing III":
            remove all xp from drops
            give 35 experience to the attacker
            stop
        else if lore of attacker's tool contains "&7* &dAngelic Blessing II":
            remove all xp from drops
            give 40 experience to the attacker
            stop
        else if lore of attacker's tool contains "&7* &dAngelic Blessing I":
            remove all xp from drops
            give 45 experience to the attacker
            stop
        else:
            remove all xp from drops
            give 30 experience to the attacker
            stop   
           
           
           
    else if lore of attacker's tool contains "&7* &9Blessed II":
        if lore of attacker's tool contains "&7* &dAngelic Blessing III":
            remove all xp from drops
            give 45 experience to the attacker
            stop
        else if lore of attacker's tool contains "&7* &dAngelic Blessing II":
            remove all xp from drops
            give 50 experience to the attacker
            stop
        else if lore of attacker's tool contains "&7* &dAngelic Blessing I":
            remove all xp from drops
            give 55 experience to the attacker
            stop
        else:
            remove all xp from drops
            give 40 experience to the attacker
            stop
           
           
           
           
           
    else if lore of attacker's tool contains "&7* &9Blessed I":
        if lore of attacker's tool contains "&7* &dAngelic Blessing I":
            remove all xp from drops
            give 55 experience to the attacker
            stop
        else if lore of attacker's tool contains "&7* &dAngelic Blessing II":
            remove all xp from drops
            give 60 experience to the attacker
            stop
        else if lore of attacker's tool contains "&7* &dAngelic Blessing III":
            remove all xp from drops
            give 65 experience to the attacker
            stop
       else:
            remove all xp from drops
            give 50 experience to the attacker
            stop           
           
           
    else:
        remove all xp from drops
        give 10 experience to the attacker
        stop
 
Last edited:
The problem is that if you have Angelic Blessing III your code will triger Angelic Blessing I, Angelic Blessing II and Angelic Blessing III, i fix your code, tell me if it worked for you:


code_language.skript:
on death of blaze:



#ORDER LUL ORDER :P

    if lore of attacker's tool contains "&7* &9Blessed V":
        if lore of attacker's tool contains "&7* &dAngelic Blessing III":
            remove all xp from drops
            give 20 experience to the attacker
            stop
        else if lore of attacker's tool contains "&7* &dAngelic Blessing II":
            remove all xp from drops
            give 25 experience to the attacker
            stop
        else if lore of attacker's tool contains "&7* &dAngelic Blessing I":
            remove all xp from drops
            give 30 experience to the attacker
            stop
        else:
            remove all xp from drops
            give 15 experience to the attacker
            stop
        
        
        
    else if lore of attacker's tool contains "&7* &9Blessed IV":
        if lore of attacker's tool contains "&7* &dAngelic Blessing III":
            remove all xp from drops
            give 25 experience to the attacker
            stop
        else if lore of attacker's tool contains "&7* &dAngelic Blessing II":
            remove all xp from drops
            give 30 experience to the attacker
            stop
        else if lore of attacker's tool contains "&7* &dAngelic Blessing I":
            remove all xp from drops
            give 35 experience to the attacker
            stop
        else:
            remove all xp from drops
            give 20 experience to the attacker
            stop
        
        
        
    else if lore of attacker's tool contains "&7* &9Blessed III":
        if lore of attacker's tool contains "&7* &dAngelic Blessing III":
            remove all xp from drops
            give 35 experience to the attacker
            stop
        else if lore of attacker's tool contains "&7* &dAngelic Blessing II":
            remove all xp from drops
            give 40 experience to the attacker
            stop
        else if lore of attacker's tool contains "&7* &dAngelic Blessing I":
            remove all xp from drops
            give 45 experience to the attacker
            stop
        else:
            remove all xp from drops
            give 30 experience to the attacker
            stop
        
        
        
    else if lore of attacker's tool contains "&7* &9Blessed II":
        if lore of attacker's tool contains "&7* &dAngelic Blessing III":
            remove all xp from drops
            give 45 experience to the attacker
            stop
        else if lore of attacker's tool contains "&7* &dAngelic Blessing II":
            remove all xp from drops
            give 50 experience to the attacker
            stop
        else if lore of attacker's tool contains "&7* &dAngelic Blessing I":
            remove all xp from drops
            give 55 experience to the attacker
            stop
        else:
            remove all xp from drops
            give 40 experience to the attacker
            stop
        
        
        
        
        
    else if lore of attacker's tool contains "&7* &9Blessed I":
        if lore of attacker's tool contains "&7* &dAngelic Blessing I":
            remove all xp from drops
            give 55 experience to the attacker
            stop
        else if lore of attacker's tool contains "&7* &dAngelic Blessing II":
            remove all xp from drops
            give 60 experience to the attacker
            stop
        else if lore of attacker's tool contains "&7* &dAngelic Blessing III":
            remove all xp from drops
            give 65 experience to the attacker
            stop
       else:
            remove all xp from drops
            give 50 experience to the attacker
            stop        
        
        
    else:
        remove all xp from drops
        give 10 experience to the attacker
        stop

Sorry for not responding for a while, but it works!
Thank you so much! ^-^

(PS: Funny how something as simple as re-arranging the code in the opposite way can make it go from completely messed up to perfectly fine xD

Only other thing I had to fix was line 87's "Else" needed one more space in it, the experience amounts were arranged in the wrong order and the Blessed 1 section's arrangement for angelic blessings weren't altered unlike the rest -- but otherwise, everything worked perfectly!)
 
Last edited:
Status
Not open for further replies.