Solved Help how to detect lore level numbers

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

Tonipop

Member
Aug 15, 2021
12
0
1
22
Help i having 2 problems here .
the First is when the Sword have a example:
If i apply the book with Extra Sharp 1 in a diamond sword which already has that mod "Extra Sharp 2"
it still applying to the sword. i dont know how to solve that .

The second trouble is if there is any way to simplify the code, because its kinda long and with many repetitive conditions

Code:
on inventory click:
    player's cursor slot is book:
        if event-slot is any sword:
            if name of cursor slot of player is "&cWeapon Mod":
                set {_name} to "%lore of cursor slot of player%"
                if lore of event-slot contains "%{_name}%":
                    send "&cYou already have This mod"
                    stop
                cancel event
#Detect if the player doesnt have any "Mod-Slot" the first 2 lines.
                if line 1 of lore of event-slot is not set:
                    set line 1 of lore of event-slot to {_name}
                    send "&fEnchantment &d%{_name}% &fapplied"
                    remove 1 of player's cursor slot from player's cursor slot
                    stop
                if line 2 of lore of event-slot is not set:
                    set line 2 of lore of event-slot to {_name}
                    send "&fEnchantment &d%{_name}% &fapplied"
                    remove 1 of player's cursor slot from player's cursor slot
                    stop
                remove 1 of player's cursor slot from player's cursor slot
#Detect If the player had in their lore line "Mod-Slot" .
                if line 2 of lore of event-slot contains "Mod-Slot":
                    set line 2 of lore of event-slot to {_name}
                    send "&fEnchantment &d%{_name}% &fapplied"
                    stop
                if line 3 of lore of event-slot contains "Mod-Slot":
                    set line 3 of lore of event-slot to {_name}
                    send "&fEnchantment &d%{_name}% &fapplied"
                    stop
                if line 4 of lore of event-slot contains "Mod-Slot":
                    set line 4 of lore of event-slot to {_name}
                    send "&fEnchantment &d%{_name}% &fapplied"
                    stop
 
Help i having 2 problems here .
the First is when the Sword have a example:
If i apply the book with Extra Sharp 1 in a diamond sword which already has that mod "Extra Sharp 2"
it still applying to the sword. i dont know how to solve that .

The second trouble is if there is any way to simplify the code, because its kinda long and with many repetitive conditions

Code:
on inventory click:
    player's cursor slot is book:
        if event-slot is any sword:
            if name of cursor slot of player is "&cWeapon Mod":
                set {_name} to "%lore of cursor slot of player%"
                if lore of event-slot contains "%{_name}%":
                    send "&cYou already have This mod"
                    stop
                cancel event
#Detect if the player doesnt have any "Mod-Slot" the first 2 lines.
                if line 1 of lore of event-slot is not set:
                    set line 1 of lore of event-slot to {_name}
                    send "&fEnchantment &d%{_name}% &fapplied"
                    remove 1 of player's cursor slot from player's cursor slot
                    stop
                if line 2 of lore of event-slot is not set:
                    set line 2 of lore of event-slot to {_name}
                    send "&fEnchantment &d%{_name}% &fapplied"
                    remove 1 of player's cursor slot from player's cursor slot
                    stop
                remove 1 of player's cursor slot from player's cursor slot
#Detect If the player had in their lore line "Mod-Slot" .
                if line 2 of lore of event-slot contains "Mod-Slot":
                    set line 2 of lore of event-slot to {_name}
                    send "&fEnchantment &d%{_name}% &fapplied"
                    stop
                if line 3 of lore of event-slot contains "Mod-Slot":
                    set line 3 of lore of event-slot to {_name}
                    send "&fEnchantment &d%{_name}% &fapplied"
                    stop
                if line 4 of lore of event-slot contains "Mod-Slot":
                    set line 4 of lore of event-slot to {_name}
                    send "&fEnchantment &d%{_name}% &fapplied"
                    stop
im not 100% sure, but making a loop should suffice, now in plugins you could just get the size of the lore, and loop idk if its the same from skript, but it might be worth a shot.

Basically, make a variable, and set it to the size of the lore would look something like this
Code:
on inventory click:
    player's cursor slot is book:
        if event-slot is any sword:
            if name of cursor slot of player is "&cWeapon Mod":
                set {_name} to "%lore of cursor slot of player%"
                if lore of event-slot contains "%{_name}%":
                    send "&cYou already have This mod"
                    stop
                    cancel event
                set {_loresize} to size of event-slot's lore
                set {_int} to 0
                loop {_loresize} times:
                  
                    if line {_int} of lore of event-slot is not set:
                        set line {_int} of lore of event-slot to {_name}
                        send "&fEnchantment &d%{_name}% &fapplied"
                        remove 1 of player's cursor slot from player's cursor slot
                        stop
                    else:
                        add 1 to {_int}
im not sure if this is what you want, if it is test it out and lmk
 
im not 100% sure, but making a loop should suffice, now in plugins you could just get the size of the lore, and loop idk if its the same from skript, but it might be worth a shot.

Basically, make a variable, and set it to the size of the lore would look something like this
Code:
on inventory click:
    player's cursor slot is book:
        if event-slot is any sword:
            if name of cursor slot of player is "&cWeapon Mod":
                set {_name} to "%lore of cursor slot of player%"
                if lore of event-slot contains "%{_name}%":
                    send "&cYou already have This mod"
                    stop
                    cancel event
                set {_loresize} to size of event-slot's lore
                set {_int} to 0
                loop {_loresize} times:
                
                    if line {_int} of lore of event-slot is not set:
                        set line {_int} of lore of event-slot to {_name}
                        send "&fEnchantment &d%{_name}% &fapplied"
                        remove 1 of player's cursor slot from player's cursor slot
                        stop
                    else:
                        add 1 to {_int}
im not sure if this is what you want, if it is test it out and lmk
Yes it is , thank you. now it will be less messy
 
Status
Not open for further replies.