Solved Lore deleting all other lores

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

Mattllama987

Active Member
Aug 5, 2018
225
7
18
24
Hello, i have a small problem ive been stuck on for a long time now. Im making a custom enchantment plugin, and i have the enchantments working. But when i add a lore to my pickaxe, and then add earthquake, it deletes all the other lores. Im not 100% sure why its doing this and im not 100% sure how to fix it.

This is earthquake lore

Code:
command /earthexpick:
    trigger:
        if {earthquake::buy::%player%} is more than 49:
            set {earthquake::buy::%player%} to 49
            send "&c(&4!&c) &7You are at the max level!"
        if player's balance is more than or equal to 100000000:
            remove 100000000 from player's balance
            add 1 to {earthquake::buy::%player%}
            set {_lores::*} to lore of player's held item
            set {_earthquake::*} to "&eEarthquake %{earthquake::buy::%player%}%"
            loop {_earthquake::*}:
                set line {_lores}+ loop-index parsed as integer of lore of player's tool to loop-value
                enchanter(player)
        else:
            send "&c(&4!&c) &7Sorry, but you don't have enough money!"


Explosive lore

Code:
command /tntexpick:
    trigger:
        if player's balance is more than or equal to 100000000:
            remove 100000000 from player's balance
            add 1 to {explosives::buy::%player%}
            set {_lore::*} to lore of player's held item
            set {_explosive::*} to "&cExplosive %{explosives::buy::%player%}%"
            loop {_explosive::*}:
                set line {_lore}+ loop-index parsed as integer of lore of player's tool to loop-value
                add 1 to {explosive::buy::%player%}
                enchanter(player)
        else:
            send "&c(&4!&c) &7Sorry, but you don't have enough money!"
 
{_lore} does not return the size of {_lore::*}, you have to use 'size of {_lore::*}' instead.
 
Do you mind showing me how to do it? Every thing i try, it just doubles the lore lol. Its just sooo close on working, but i keep messing it up lol. :emoji_slight_smile:
 
Can you send your current code?
 
Gives no errors, try this, didn't test it though
code_language.skript:
command earthexpick:
    trigger:
        {earthquake::buy::%player%} > 49:
            set {earthquake::buy::%player%} to 49
            send "&c(&4!&c) &7You are at the max level!"
        player's balance >= 100000000:
            remove 100000000 from player's balance
            set {earthquake::buy::%player%} to {earthquake::buy::%player%} + 1
            lore of tool contains "Earthquake":
                set {_l::*} to uncolored lore of tool parsed as "Earthquake %integer%"
                replace all "&eEarthquake %{_l::1}%" in lore of tool with "&eEarthquake %{earthquake::buy::%player%}%"
            else:
                set lore of tool to "%lore of tool%||&eEarthquake %{earthquake::buy::%player%}%"
            enchanter(player)
        else:
            send "&c(&4!&c) &7Sorry, but you don't have enough money!"
 
Gives no errors, try this, didn't test it though
code_language.skript:
command earthexpick:
    trigger:
        {earthquake::buy::%player%} > 49:
            set {earthquake::buy::%player%} to 49
            send "&c(&4!&c) &7You are at the max level!"
        player's balance >= 100000000:
            remove 100000000 from player's balance
            set {earthquake::buy::%player%} to {earthquake::buy::%player%} + 1
            lore of tool contains "Earthquake":
                set {_l::*} to uncolored lore of tool parsed as "Earthquake %integer%"
                replace all "&eEarthquake %{_l::1}%" in lore of tool with "&eEarthquake %{earthquake::buy::%player%}%"
            else:
                set lore of tool to "%lore of tool%||&eEarthquake %{earthquake::buy::%player%}%"
            enchanter(player)
        else:
            send "&c(&4!&c) &7Sorry, but you don't have enough money!"
For what i can tell so far, it is working. But it wont update the lore on the players tool and set it to the new updated one. I had to make a few changes.

Code:
command /earthexpick:
    trigger:
        add 1 to {earthquake::buy::%player%}
        {earthquake::buy::%player%} > 49:
            set {earthquake::buy::%player%} to 49
            send "&c(&4!&c) &7You are at the max level!"
        player's balance >= 100000000:
            remove 100000000 from player's balance
            set {earthquake::buy::%player%} to {earthquake::buy::%player%} + 1
            lore of tool contains "Earthquake":
                set {_l::*} to uncolored lore of tool parsed as "Earthquake %integer%"
                replace all "&eEarthquake %{_l::1}%" in lore of tool with "&eEarthquake %{earthquake::buy::%player%}%"
            else:
                set lore of tool to "%lore of tool%||&eEarthquake %{earthquake::buy::%player%}%"
            enchanter(player)
        else:
            send "&c(&4!&c) &7Sorry, but you don't have enough money!"
[doublepost=1549563821,1549476366][/doublepost]bump
 
What Skript version are you using (newer Skript version handle lore differently)
 
Try
Code:
command /earthexpick:
    trigger:
        add 1 to {earthquake::buy::%player%}
        if {earthquake::buy::%player%} > 49:
            set {earthquake::buy::%player%} to 49
            send "&c(&4!&c) &7You are at the max level!"
        if player's balance >= 100000000:
            remove 100000000 from player's balance
            set {earthquake::buy::%player%} to {earthquake::buy::%player%} + 1
            lore of tool contains "Earthquake":
                set {_l::*} to split lore of tool at "||"
                loop {_l::*}:
                    set {_l2::*} to uncolored loop-value parsed as "Earthquake %integer%"
                    {_l2::*} is set
                    set {_l::%loop-index%} to "&eEarthquake %{_l2::1}+1%"
                    exit loop
                set lore of tool to join {_l::*} with "||"
            else:
                set lore of tool to "%lore of tool%||&eEarthquake %{earthquake::buy::%player%}%"
            enchanter(player)
        else:
            send "&c(&4!&c) &7Sorry, but you don't have enough money!"
 
Try
Code:
command /earthexpick:
    trigger:
        add 1 to {earthquake::buy::%player%}
        if {earthquake::buy::%player%} > 49:
            set {earthquake::buy::%player%} to 49
            send "&c(&4!&c) &7You are at the max level!"
        if player's balance >= 100000000:
            remove 100000000 from player's balance
            set {earthquake::buy::%player%} to {earthquake::buy::%player%} + 1
            lore of tool contains "Earthquake":
                set {_l::*} to split lore of tool at "||"
                loop {_l::*}:
                    set {_l2::*} to uncolored loop-value parsed as "Earthquake %integer%"
                    {_l2::*} is set
                    set {_l::%loop-index%} to "&eEarthquake %{_l2::1}+1%"
                    exit loop
                set lore of tool to join {_l::*} with "||"
            else:
                set lore of tool to "%lore of tool%||&eEarthquake %{earthquake::buy::%player%}%"
            enchanter(player)
        else:
            send "&c(&4!&c) &7Sorry, but you don't have enough money!"
That sure did it! Thank you so much and have a very nice day! :emoji_slight_smile:
 
Hi, sorry to wait your time again :emoji_slight_smile:. But how can i make it so if the lore contains 50, It will stop and wont add anymore lvls?
 
The variable {_l2::1} after line 14 has the current level, you can use that
 
Well that depends on how you want to have it. Do you want the level on the lore of the tool to be the same as {earthquake::buy::%player%}?
 
Then I think you should use this:
Code:
command /earthexpick:
    trigger:
        if {earthquake::buy::%player%} >= 50:
            set {earthquake::buy::%player%} to 50
            send "&c(&4!&c) &7You are at the max level!"
        else if player's balance >= 100000000:
            add 1 to {earthquake::buy::%player%}
            remove 100000000 from player's balance
            set {_l::*} to split lore of tool at "||"
            loop {_l::*}:
                set {_l2::*} to uncolored loop-value parsed as "Earthquake %integer%"
                {_l2::*} is set
                set {_l::%loop-index%} to "&eEarthquake %{earthquake::buy::%player%}%"
            set lore of tool to join {_l::*} with "||"
            if {_l2::*} is not set:
                set lore of tool to "%lore of tool%||&eEarthquake %{earthquake::buy::%player%}%"
            enchanter(player)
        else:
            send "&c(&4!&c) &7Sorry, but you don't have enough money!"
 
Then I think you should use this:
Code:
command /earthexpick:
    trigger:
        if {earthquake::buy::%player%} >= 50:
            set {earthquake::buy::%player%} to 50
            send "&c(&4!&c) &7You are at the max level!"
        else if player's balance >= 100000000:
            add 1 to {earthquake::buy::%player%}
            remove 100000000 from player's balance
            set {_l::*} to split lore of tool at "||"
            loop {_l::*}:
                set {_l2::*} to uncolored loop-value parsed as "Earthquake %integer%"
                {_l2::*} is set
                set {_l::%loop-index%} to "&eEarthquake %{earthquake::buy::%player%}%"
            set lore of tool to join {_l::*} with "||"
            if {_l2::*} is not set:
                set lore of tool to "%lore of tool%||&eEarthquake %{earthquake::buy::%player%}%"
            enchanter(player)
        else:
            send "&c(&4!&c) &7Sorry, but you don't have enough money!"
Thank you so much! Thats exactly what i needed. Thank you for being so nice and helping resolve this problem i was having. :emoji_slight_smile:

Have a wonderful day! :emoji_slight_smile:
 
No problem! You have a wonderful day as well :emoji_grinning:
 
Status
Not open for further replies.