pickaxe upgrader

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

kami3s

New Member
Nov 24, 2023
5
0
1
23
Could someone create a command that detects what enchant we have, e.g.:
when we have enchantment for efficiency 1, to enchant for efficiency 2 we must have 10 golden apples, if we have efficiency 2 and want to enchant for efficiency 3, we must have 15 golden apples. if we have a performance of 3 or more, the message "you have reached the maximum level" is displayed, please!!!!
 
it just example, i'll edit this later (when someones prepares a skript for me)
 
Could someone create a command that detects what enchant we have, e.g.:
when we have enchantment for efficiency 1, to enchant for efficiency 2 we must have 10 golden apples, if we have efficiency 2 and want to enchant for efficiency 3, we must have 15 golden apples. if we have a performance of 3 or more, the message "you have reached the maximum level" is displayed, please!!!!
Code:
options:
   e: "&d[Enchant]"
function enchant(p: player, cost: number, ench: text, max: number):
   if {_p} has tool:
      if {_p}'s tool is enchanted with "%{_ench}%" parsed as enchantment type:
         if {_p} has {_cost} of golden apple:
            if {_p}'s tool is enchanted with "%{_ench}% 2" parsed as enchantment type:
               add 5 to {_cost}
               enchant {_p}'s tool with "%{_ench}% %level of efficiency of the tool + 1%" parsed as enchantment type
               send "%{@e}% &aSuccess! Your tool was enchanted." to {_p}
            if {_p}'s tool isn't enchanted with "%{_ench}% %{_max}%" parsed as enchantment type:
               enchant {_p}'s tool with "%{_ench}% %level of efficiency of the tool + 1%" parsed as enchantment type
               send "%{@e}% &aSuccess! Your tool was enchanted." to {_p}
            else:
               send "%{@e}% &cSorry! You've reached the maximum %{_ench}% level!" to player
            remove {_cost} of golden apple from {_p}'s inventory
         else:
            send "%{@e}% &cSorry! You cannot afford this upgrade!"
command enchanttool:
   trigger:
      enchant(player, 10, "sharpness", 3)

Try the code I provided above. If you have any questions/concerns, lemme know!
 
I would like the number of required apples to increase more with the level, not e.g. every +5 but later every +20 or +50
 
I would like the number of required apples to increase more with the level, not e.g. every +5 but later every +20 or +50
Alright. What you can do for that then is have a set multiplier variable attached the the player’s uuid (Like: {pricemulti.%player’s uuid%}. You can then attach it to the function (make sure it’s set to one for every player at first). When you add it to the function, make sure to make it be multiplied by the cost (ie: add 5*{pricemulti.%{_u}%} to price). Then near the end of that same section in the if statement, add one to the price multi itself. This will make it so that every upgrade will cause the price to be multiplied for each individual player. Also, in the multiplier example I described, make sure the have {_u} set as the player’s uuid (In the function to {_p}‘s uuid is set to {_u}).
 
Alright. What you can do for that then is have a set multiplier variable attached the the player’s uuid (Like: {pricemulti.%player’s uuid%}. You can then attach it to the function (make sure it’s set to one for every player at first). When you add it to the function, make sure to make it be multiplied by the cost (ie: add 5*{pricemulti.%{_u}%} to price). Then near the end of that same section in the if statement, add one to the price multi itself. This will make it so that every upgrade will cause the price to be multiplied for each individual player. Also, in the multiplier example I described, make sure the have {_u} set as the player’s uuid (In the function to {_p}‘s uuid is set to {_u}).
can you send the ready code? I don't understand skripts very well..
 
can you send the ready code? I don't understand skripts very well..
Code:
options:
   e: "&d[Enchant]"
on join:
   set {_p} to player
   set {_u} to {_p}'s uuid
   if {multi::%{_u}%} isn't set:
      set {multi::%{_u}%} to 1
function enchant(p: player, cost: number, ench: text, max: number):
   set {_u} to {_p}'s uuid
   if {_p} has tool:
      if {_p}'s tool is enchanted with "%{_ench}%" parsed as enchantment type:
         if {_p} has {_cost} of golden apple:
            if {_p}'s tool isn't enchanted with "%{_ench}% %{_max}%" parsed as enchantment type:
               add 5*{multi::%{_u}%} to {_cost}
               enchant {_p}'s tool with "%{_ench}% %level of efficiency of the tool + 1%" parsed as enchantment type
               send "%{@e}% &aSuccess! Your tool was enchanted." to {_p}
               add 1 to {multi::%{_u}%}
               remove {_cost} of golden apple from {_p}'s inventory
            else:
               send "%{@e}% &cSorry! You've reached the maximum %{_ench}% level!" to {_p}
         else:
            send "%{@e}% &cSorry! You cannot afford this upgrade!" to {_p}
command enchanttool:
   trigger:
      enchant(player, 10, "sharpness", 3)
Fixed a couple minor issues I overlooked when I first wrote the code & also added the functionality you wanted (Keep in mind this code could have minor issues that cannot be detected unless you test the code in game).