Solved Lore stats

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

    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.

EnZi

Supporter
Feb 7, 2020
8
1
0
Skript Version: Skript 2.4.1
Minecraft Version: 1.12.2

Hello.. Today I did some kind of lore checking for custom stats.. Everything works except removing stats when you switch from item with stats to any other item without stats they do not remove.. I tried many ways to fix this but without success :/

Full Code:
Code:
on hotbar switch:
    wait 1 tick
    set {_l} to "%lore of player's held item%"
    set {_lore::*} to {_l} split by "||"
    loop {_lore::*}:
        set {_health::*} to uncolored loop-value parsed as "Life +%num%"
        if {_health::1} is not set:
            set {_health::1} to 0
        if {_health::1} is set:
            set {_health} to {_health::1}
    if {hslot} isn't set:
        if lore of player's held item contains "%{_health::1}%":
            send "1"
            set {hslot} to current hotbar slot of player
            add {_health} to {life::%player%}
            add {_health} to {maxlife::%player%}
    else if {hslot} is set:
        if lore of player's held item contains "%{_health::1}%":
            clear {hslot}
            set {hslot} to current hotbar slot of player
            if new hotbar slot is {hslot}: #fix for bug when you switch on item with same bonus to prevent double stats
                send "3"
        else:
            send "4" #it send a message but this remove under it wont work
            remove {_health} from {life::%player%} #this doesnt work
            remove {_health} from {maxlife::%player%} #this doesnt work
            clear {hslot}

Addons using:
skRayFall+v1.9.19
SkQuery-4.1.2
Sk-NBeeT
Skellett
Ersatz
skript-yaml
skript-mirror

Have you tried searching the docs? Yes
Have you tried searching the forums? Yes

FIX: set {hpstat} to "%{_health}%" parsed as integer
then remove {hpstat} from {life::%player%}
 
Last edited:
Status
Not open for further replies.