Search all lines of lore instead of just one.

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

redditist

Member
May 23, 2024
2
0
1
19
Code:
on block break:
    if "%region at event-block%" contains "mine":
        set {_power::*} to line 1 of lore of player's tool split at "Explosive "
        set {_power::2} to {_power::2} parsed as an integer
        if player is holding unbreakable pickaxe with lore "&7Explosive %{_power::2}%":
            chance of {_power::2}/100:
                create fake explosion at event-location
                loop all blocks in radius 1+({_power::2}/10) around event-location:
                    if "%region at loop-block%" contains "mine":
                        break loop-value naturally
                        set loop-block to air
Code above shows an explosive enchant. The problem is that if the line "Explosive {number}" is on any line except 1, it will not work.
I tried:
* removing the "line 1 of" in line 3 of the code to "to" thus saying: "set {_power::*} to the lore of player's tool split at "Explosive "". Didn't work.
* Trying a number range. Didn't work.

Any help would be appreciated.
 
I would reccomend storing enchantments in the nbt of the tool because it eill be a lot easier to check if the tool has a certain enchant an what level it would be. To set an enchantment you can do set int tag "explosion" of nbt of player's tool to 1 and then to check if it has explosion you would do if nbt of player's tool has tag "explosion":. If you wanted to get the level you could do set {_level} to int tag "explosion" of nbt of player's tool. All of this requires skbee
 
I would reccomend storing enchantments in the nbt of the tool because it eill be a lot easier to check if the tool has a certain enchant an what level it would be. To set an enchantment you can do set int tag "explosion" of nbt of player's tool to 1 and then to check if it has explosion you would do if nbt of player's tool has tag "explosion":. If you wanted to get the level you could do set {_level} to int tag "explosion" of nbt of player's tool. All of this requires skbee
Hi, thanks for the reply. The code worked, however I have another problem:

Code:
command /explosive <integer>:
    trigger:
        set int tag "explosive" of nbt of player's tool to %arg-1%
        add "&7Explosive %arg-1%" to lore of player's tool

I don't know the exact types you can put into the <> but it doesn't seem integer is one of them. Tried checking the docs but that came out inconclusive.

The error reads:
int tag "explosive" of nbt from tool of the play can't be set to "%arg-1%' because the latter is not an integer
 
Hi, thanks for the reply. The code worked, however I have another problem:

Code:
command /explosive <integer>:
    trigger:
        set int tag "explosive" of nbt of player's tool to %arg-1%
        add "&7Explosive %arg-1%" to lore of player's tool

I don't know the exact types you can put into the <> but it doesn't seem integer is one of them. Tried checking the docs but that came out inconclusive.

The error reads:
int tag "explosive" of nbt from tool of the play can't be set to "%arg-1%' because the latter is not an integer
Dont put % around arg-1
integer should be alright for the <>