Solved Make this code shorter

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

Time4Games

Active Member
Jul 25, 2020
203
4
18
Is there a way to make this code shorter?
i use 2 spaces and not a tab

Code:
command /buywoodenpickaxe1 [<player>]:
  permission:sk.developer
  trigger:
    if arg-1 has a wooden pickaxe named "&bWooden Pickaxe &aLevel 1" with lore "&9Unbreakable":
      if {glass::%arg-1%} is bigger than 9:
        if {fortune::%arg-1%} is 0:
          wait 5 tick
          remove wooden pickaxe named "&bWooden Pickaxe &aLevel 1" from arg-1's inventory
          remove 10 from {glass::%arg-1%}
          wait 5 tick
          add 1 wooden pickaxe of efficiency 1 named "&bWooden Pickaxe &aLevel 2" with lore "&9Unbreakable" to arg-1
          wait 5 tick
          send "&bUpgrade Successful" to arg-1
        else if {fortune::%arg-1%} is 1:
          wait 5 tick
          remove wooden pickaxe named "&bWooden Pickaxe &aLevel 1" from arg-1's inventory
          remove 10 from {glass::%arg-1%}
          wait 5 tick
          add 1 wooden pickaxe of efficiency 1 named "&bWooden Pickaxe &aLevel 2" with lore "&9Fortune I" and "&9Unbreakable" to arg-1
          wait 5 tick
          send "&bUpgrade Successful" to arg-1
      else:
        send "&cYou don't have enough glass to buy it" to arg-1
    else if arg-1 has a wooden pickaxe named "&bWooden Pickaxe &aLevel 1" with lore "&9Fortune I" and "&9Unbreakable":
      if {glass::%arg-1%} is bigger than 9:
        if {fortune::%arg-1%} is 0:
          wait 5 tick
          remove wooden pickaxe named "&bWooden Pickaxe &aLevel 1" from arg-1's inventory
          remove 10 from {glass::%arg-1%}
          wait 5 tick
          add 1 wooden pickaxe of efficiency 1 named "&bWooden Pickaxe &aLevel 2" with lore "&9Unbreakable" to arg-1
          wait 5 tick
          send "&bUpgrade Successful" to arg-1
        else if {fortune::%arg-1%} is 1:
          wait 5 tick
          remove wooden pickaxe named "&bWooden Pickaxe &aLevel 1" from arg-1's inventory
          remove 10 from {glass::%arg-1%}
          wait 5 tick
          add 1 wooden pickaxe of efficiency 1 named "&bWooden Pickaxe &aLevel 2" with lore "&9Fortune I" and "&9Unbreakable" to arg-1
          wait 5 tick
          send "&bUpgrade Successful" to arg-1
    else:
      send "&cYou need a &bWooden Pickaxe &aLevel 1" to arg-1
 
I mean why are there so many "wait 5 ticks", seems pretty useless in this skript.
 
code_language.skript:
command /buywoodenpickaxe1 [<player>]:
  permission:sk.developer
  trigger:
    if arg-1 has a wooden pickaxe named "&bWooden Pickaxe &aLevel 1":
      if {glass::%arg-1%} is bigger than 9:
        add "&9Unbreakable" to {_lore::*}
        if {fortune::%arg-1%} is 1:
          add "&9Fortune I" to {_lore::*}
        wait 5 tick
        remove wooden pickaxe named "&bWooden Pickaxe &aLevel 1" from arg-1's inventory
        remove 10 from {glass::%arg-1%}
        wait 5 tick
        add 1 wooden pickaxe of efficiency 1 named "&bWooden Pickaxe &aLevel 2" with lore {_lore::*} to arg-1
        wait 5 tick
        send "&bUpgrade Successful" to arg-1
      else:
        send "&cYou don't have enough glass to buy it" to arg-1
    else:
      send "&cYou need a &bWooden Pickaxe &aLevel 1" to arg-1
 
Status
Not open for further replies.