Solved sharpness skript

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

Iroh

New Member
Apr 8, 2022
9
0
1
25
Hi!
I'm trying to see which enchantments I can recreate with skript but I feel like my current sharpness skript could be optimized. Basically, I want to know if there is a way to detect the sharpness level without checking every variation of the lore so then I can scale this to any level of sharpness. Keep in mind I do not want to use actual enchants. If this is not possible I understand.

Versions and addons:
Skript for Paper 2.6.1
SkDragon
skript-reflect
SkBee
SkriptGUI
SkRayfall


my current code:

Code:
on damage:
    if lore of attacker's tool contains "sharptest 1":
        add 1 to damage
        send damage to attacker
    else if lore of attacker's tool contains "sharptest 2":
        add 1.5 to damage
        send damage to attacker
    else if lore of attacker's tool contains "sharptest 3":
        add 2 to damage
        send damage to attacker
    else if lore of attacker's tool contains "sharptest 4":
        add 2.5 to damage
        send damage to attacker
    else if lore of attacker's tool contains "sharptest 5":
        add 3 to damage
        send damage to attacker
 
Code:
on damage:
    attacker is a player:
        victim is a player:
            if lore of attacker's tool contains "sharptest 1":
                add 1 to {damage::%victim%}
                send "%{damage::%victim%}%" to attacker
                delete {damage::%victim%}
 
I want to know if there is a way to detect the sharpness level without checking every variation of the lore so then I can scale this to any level of sharpness

I wanted to know this specifically so like whether i can make a code for sharp 1 that will also work for sharp 10 without having to account for every possible sharpness level
 
Code:
on damage:
  if lore of attacker's tool contains "sharptest ":
    set {_n} to 0
    loop size of lore of attacker's tool times:
      add 1 to {_n}
      line {_n} of lore of attacker's tool contains "sharptest "
      set {_line} to line {_n} of lore of attacker's tool
      stop loop
    set {_split::*} to {_line} split at " "
    add ("%{_split::2}%" parsed as a number) / 2 to damage
    send damage to attacker
 
Status
Not open for further replies.