Solved Read the level of the enchant.

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

couger44

Supporter
Feb 19, 2017
713
31
28
Chile
Hi everyone,
A while ago I was thinking about doing a skript about directly adding the mined items to the inventory, for my server. I did it but then I started to think and I said what happened if the player had fortune how could it be done so that the number of items would double depending on the level of the enchantment?
Would anyone know how that would be possible?
 
create a variable to record the enchant level:
Code:
variables:
    {fortune.%player%} = 0

command /debug:
    trigger:
        set {fortune.%player%} to 2

on break:
    if {fortune.%player%} is not 0:
        set {_x} to {fortune.%player%} * 2 - 1 #Remove the - 1 if you cancel the event
        drop {_x} of event-block #or give {_x} of event-block
 
create a variable to record the enchant level:
Code:
variables:
    {fortune.%player%} = 0

command /debug:
    trigger:
        set {fortune.%player%} to 2

on break:
    if {fortune.%player%} is not 0:
        set {_x} to {fortune.%player%} * 2 - 1 #Remove the - 1 if you cancel the event
        drop {_x} of event-block #or give {_x} of event-block

I know make that, but what I'm looking for is something like this:
code_language.skript:
on break:
    player's gamemode is not creative:
        cancel event
        if event-block is diamond ore:
            if lore of player's held item contains "&7Fortune I": #Here what I want is for you to read the enchantment number.
 
This maybe?

Code:
variables:
    {fortune.%player%} = 0
    {fortunemax} = 5

command /debug:
    trigger:
        set {fortune.%player%} to 5

command /upgrade: #Assuming you had a similar command
    trigger:
        if player's held item is a pickaxe:
            set {_x} to 0
            loop {fortunemax} times: # Amount of levels
                if {fortune.%player%} is {_x}:
                    add 100 to {_fortunecost.%{_x}%}
                    if {money.%player%} is greater than {_fortunecost.%{_x}%}:
                        add 1 to {fortune.%player%}
                        set lore of player's tool to "&7Fortune %{fortune.%player%}%"
            add 1 to {_x}

on break:
    if player's gamemode is not creative:
        cancel event
        if event-block is diamond ore:
            set {_x} to 0
            loop {fortunemax} times:
                if lore of player's held item contains "Fortune %{_x}%":
                    set {_v} to {fortune.%player%} * 2
                    give {_v} of diamond to player
                    add 1 to {_x}
 
This maybe?

Code:
variables:
    {fortune.%player%} = 0
    {fortunemax} = 5

command /debug:
    trigger:
        set {fortune.%player%} to 5

command /upgrade: #Assuming you had a similar command
    trigger:
        if player's held item is a pickaxe:
            set {_x} to 0
            loop {fortunemax} times: # Amount of levels
                if {fortune.%player%} is {_x}:
                    add 100 to {_fortunecost.%{_x}%}
                    if {money.%player%} is greater than {_fortunecost.%{_x}%}:
                        add 1 to {fortune.%player%}
                        set lore of player's tool to "&7Fortune %{fortune.%player%}%"
            add 1 to {_x}

on break:
    if player's gamemode is not creative:
        cancel event
        if event-block is diamond ore:
            set {_x} to 0
            loop {fortunemax} times:
                if lore of player's held item contains "Fortune %{_x}%":
                    set {_v} to {fortune.%player%} * 2
                    give {_v} of diamond to player
                    add 1 to {_x}
I do not need a command to upgrade the level of fortune, I just want it to come out that way, by reading the "lore" of the tool.
 
It doesn’t need to “read” the lore because of the variable {fortune.%player%}
 
It doesn’t need to “read” the lore because of the variable {fortune.%player%}
Is not that. In my skript, I created a code that when placing the command: / kit <name of the kit>, add to your inventory items, among those there would be an enchanted peak with fortune x.
I do not want a command that raises the level of enchantment of fortune.
 
code_language.skript:
set {_} to level of fortune of player' tool
parse succesfull, don't know what it outputs tho. Can be "FORTUNE 1" or whatever. If so, just split and parse as integer. Maybe it will output <none>? Who knows. I don't
 
code_language.skript:
set {_} to level of fortune of player' tool
parse succesfull, don't know what it outputs tho. Can be "FORTUNE 1" or whatever. If so, just split and parse as integer. Maybe it will output <none>? Who knows. I don't
Thanks! this work!
 
Status
Not open for further replies.