1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT??:

    You can always check our our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Read the level of the enchant.

Discussion in 'Skript' started by couger44, Mar 18, 2019.

Thread Status:
Not open for further replies.
  1. couger44

    Supporter

    Joined:
    Feb 19, 2017
    Messages:
    406
    Likes Received:
    14
    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?

     
  2. Best Answer:
    Post #8 by Runakai1, Mar 18, 2019
  3. SkRATZ

    SkRATZ Member

    Joined:
    Nov 16, 2018
    Messages:
    11
    Likes Received:
    0
    create a variable to record the enchant level:
    Code (Text):
    1.  
    2. variables:
    3.     {fortune.%player%} = 0
    4.  
    5. command /debug:
    6.     trigger:
    7.         set {fortune.%player%} to 2
    8.  
    9. on break:
    10.     if {fortune.%player%} is not 0:
    11.         set {_x} to {fortune.%player%} * 2 - 1 #Remove the - 1 if you cancel the event
    12.         drop {_x} of event-block #or give {_x} of event-block
     
  4. couger44

    Supporter

    Joined:
    Feb 19, 2017
    Messages:
    406
    Likes Received:
    14
    I know make that, but what I'm looking for is something like this:
    Code (Skript):
    1.  
    2. on break:
    3.     player's gamemode is not creative:
    4.         cancel event
    5.         if event-block is diamond ore:
    6.             if lore of player's held item contains "&7Fortune I": #Here what I want is for you to read the enchantment number.
    7.  
    8.  
    9.  
     
  5. SkRATZ

    SkRATZ Member

    Joined:
    Nov 16, 2018
    Messages:
    11
    Likes Received:
    0
    This maybe?

    Code (Text):
    1.  
    2. variables:
    3.     {fortune.%player%} = 0
    4.     {fortunemax} = 5
    5.  
    6. command /debug:
    7.     trigger:
    8.         set {fortune.%player%} to 5
    9.  
    10. command /upgrade: #Assuming you had a similar command
    11.     trigger:
    12.         if player's held item is a pickaxe:
    13.             set {_x} to 0
    14.             loop {fortunemax} times: # Amount of levels
    15.                 if {fortune.%player%} is {_x}:
    16.                     add 100 to {_fortunecost.%{_x}%}
    17.                     if {money.%player%} is greater than {_fortunecost.%{_x}%}:
    18.                         add 1 to {fortune.%player%}
    19.                         set lore of player's tool to "&7Fortune %{fortune.%player%}%"
    20.             add 1 to {_x}
    21.  
    22. on break:
    23.     if player's gamemode is not creative:
    24.         cancel event
    25.         if event-block is diamond ore:
    26.             set {_x} to 0
    27.             loop {fortunemax} times:
    28.                 if lore of player's held item contains "Fortune %{_x}%":
    29.                     set {_v} to {fortune.%player%} * 2
    30.                     give {_v} of diamond to player
    31.                     add 1 to {_x}
    32.  
     
  6. couger44

    Supporter

    Joined:
    Feb 19, 2017
    Messages:
    406
    Likes Received:
    14
    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.
     
  7. SkRATZ

    SkRATZ Member

    Joined:
    Nov 16, 2018
    Messages:
    11
    Likes Received:
    0
    It doesn’t need to “read” the lore because of the variable {fortune.%player%}
     
  8. couger44

    Supporter

    Joined:
    Feb 19, 2017
    Messages:
    406
    Likes Received:
    14
    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.
     
  9. Runakai1

    Runakai1 Well-Known Member

    Joined:
    Apr 27, 2018
    Messages:
    398
    Likes Received:
    22
    Code (Skript):
    1. 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
     
  10. couger44

    Supporter

    Joined:
    Feb 19, 2017
    Messages:
    406
    Likes Received:
    14
    Thanks! this work!
     
Thread Status:
Not open for further replies.
Loading...