Checking 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 comminuty!

    Now, what are you waiting for? Join the community now!

Scornn

Member
Feb 11, 2017
13
1
0
Category: Lore

Suggested name: DamageCheck

What I want:
Hey there guys, recently I've been trying to make a script where when a player attacks a mob it finds the lore of the item and finds where it mentions "Damage: %number%", for my first attempt, I did this:

http://pastebin.com/jr6kBr0E

The last line is to see if the variable was actually set, as you've probably already guessed this was not the case, but there were no errors, I did see another possible way of using loops and splitting the lore but I'm so inexperienced with this side of skript, that I have no idea what I'm doing.

So, what I am asking for is, a script that can read the lore and find a line where it mentions damage and then a value i.e

"Damage: 6"

It must be during a damage event and the attacker is a player and it is finding the lore of the tool the player has used.

Thank you!


When I'd like it by: No time limit
 
Last edited:
Is this correct?
TQworc9.png


Code:
on damage:
    if attacker is a player:
        message "&c%attacker% did &7%damage% damage with %attacker's held item% &cto %victim%" to attacker

EDIT: You can change the message if you want. :emoji_slight_smile:
 
Is this correct?
TQworc9.png


Code:
on damage:
    if attacker is a player:
        message "&c%attacker% did &7%damage% damage with %attacker's held item% &cto %victim%" to attacker

EDIT: You can change the message if you want. :emoji_slight_smile:
He wants a script that get the value of the key "Damage" on the lore when a mob is attacked.

Try this:
code_language.skript:
on damage:
    attacker is a player
    victim isn't a player
    loop split lore of attacker's tool by "||":
        set {_damage} to uncolored loop-text parsed as "Damage: %num%"
        if {_damage}  is set:
            exit loop
    #Now the variable {_damage} contains the number that you want.
 
  • Like
Reactions: Scornn
He wants a script that get the value of the key "Damage" on the lore when a mob is attacked.

Try this:
code_language.skript:
on damage:
    attacker is a player
    victim isn't a player
    loop split lore of attacker's tool by "||":
        set {_damage} to uncolored loop-text parsed as "Damage: %num%"
        if {_damage}  is set:
            exit loop
    #Now the variable {_damage} contains the number that you want.


Thank you very much for the help, I seem to be getting an error at the minute.

Capture.JPG
 
Thank you very much for the help, I seem to be getting an error at the minute.

View attachment 315
Strange, such as the lore is only one text it's weird, anyways, try this:
code_language.skript:
on damage:
    attacker is a player
    victim isn't a player
    set {_lore::*} to lore of attacker's tool split by "||"
    loop {_lore::*}:
        set {_damage::*} to uncolored loop-text parsed as "Damage: %num%" #Just for be sure I changed it to a list.
        if {_damage::1}  is set:
            set {_damage} to {_damage::1}
            exit loop
 
  • Like
Reactions: Scornn
Strange, such as the lore is only one text it's weird, anyways, try this:
code_language.skript:
on damage:
    attacker is a player
    victim isn't a player
    set {_lore::*} to lore of attacker's tool split by "||"
    loop {_lore::*}:
        set {_damage::*} to uncolored loop-text parsed as "Damage: %num%" #Just for be sure I changed it to a list.
        if {_damage::1}  is set:
            set {_damage} to {_damage::1}
            exit loop

Okay I tried it but still getting the same thing, but also with a new error:

Capture.JPG


EDIT: I'll leave a picture of the item this goes for all the items that need this.

Capture2.JPG
 
Last edited by a moderator: