How can i make my code look cleaner?

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

Haloxx

Member
May 2, 2021
20
0
1
23
i have this long annoying code and it works but it looks like a 5 year old made it

Code:
on mine of any ore:
  player is sneaking:
    if event-block is iron ore:
      cancel event
      loop blocks in radius 2 around event-block:
        if loop-blocks is iron ore:
          loop blocks in radius 2 of loop-blocks:
            if loop-block-2 is iron ore:
              break event-block using player's tool
              break loop-blocks-2 using player's tool
              loop blocks in radius 2 of loop-block-2:
                if loop-block-3 is iron ore:
                  break loop-block-3 using player's tool
                  loop blocks in radius 2 of loop-block-3:
                    if loop-block-4 is iron ore:
                      break loop-block-4 using player's tool
                      loop blocks in radius 2 of loop-block-4:
                        if loop-block-5 is iron ore:
                          break loop-block-5 using player's tool
                          loop blocks in radius 2 of loop-blocks-5:
                            if loop-blocks-6 is iron ore:
                              break loop-blocks-6 using player's tool
                            loop blocks in radius 2 of loop-blocks-6:
                              if loop-blocks-7 is iron ore:
                                break loop-blocks-7 using player's tool
                              loop blocks in radius 2 of loop-blocks-7:
                                if loop-blocks-8 is iron ore:
                                  break loop-blocks-8 using player's tool
                                  loop blocks in radius 2 of loop-blocks-8:
                                    if loop-blocks-9 is iron ore:
                                      break loop-blocks-9 using player's tool
                                      loop blocks in radius 2 of loop-blocks-9:
                                        if loop-blocks-10 is iron ore:
                                          break loop-blocks-10 using player's tool
 
I'm pretty sure this will cause many errors and might not work, but you might get what I wanted to try
Code:
on break of any ore:
  loop blocks in radius 2 around event-block:
    if loop-block is any ore:
      add location of loop-block to {_ores::*}
      set {_last} to location of loop-block
      loop 5 times:
        loop blocks in radius 2 around {_last}:
          set {_last} to location of loop-block
          if loop-block is any ore:
            add location of loop-block to {_ores::*}
  loop {_ores::*}:
    break loop-block using player's tool

but keep in mind: never change a running system
 
I'm pretty sure this will cause many errors and might not work, but you might get what I wanted to try
Code:
on break of any ore:
  loop blocks in radius 2 around event-block:
    if loop-block is any ore:
      add location of loop-block to {_ores::*}
      set {_last} to location of loop-block
      loop 5 times:
        loop blocks in radius 2 around {_last}:
          set {_last} to location of loop-block
          if loop-block is any ore:
            add location of loop-block to {_ores::*}
  loop {_ores::*}:
    break loop-block using player's tool

but keep in mind: never change a running system
Ok going to try later because it’s getting late for me
[doublepost=1624151047,1624111230][/doublepost]
I'm pretty sure this will cause many errors and might not work, but you might get what I wanted to try
Code:
on break of any ore:
  loop blocks in radius 2 around event-block:
    if loop-block is any ore:
      add location of loop-block to {_ores::*}
      set {_last} to location of loop-block
      loop 5 times:
        loop blocks in radius 2 around {_last}:
          set {_last} to location of loop-block
          if loop-block is any ore:
            add location of loop-block to {_ores::*}
  loop {_ores::*}:
    break loop-block using player's tool

but keep in mind: never change a running system
Yeah didn't work my code is 272 lines and just a repeat but with a different ore but it works

Code:
on mine of any ore:
  player is sneaking:
    if event-block is iron ore:
      cancel event
      loop blocks in radius 2 around event-block:
        if loop-blocks is iron ore:
          loop blocks in radius 2 of loop-blocks:
            if loop-block-2 is iron ore:
              break event-block using player's tool
              break loop-blocks-2 using player's tool
              loop blocks in radius 2 of loop-block-2:
                if loop-block-3 is iron ore:
                  break loop-block-3 using player's tool
                  loop blocks in radius 2 of loop-block-3:
                    if loop-block-4 is iron ore:
                      break loop-block-4 using player's tool
                      loop blocks in radius 2 of loop-block-4:
                        if loop-block-5 is iron ore:
                          break loop-block-5 using player's tool
                          loop blocks in radius 2 of loop-blocks-5:
                            if loop-blocks-6 is iron ore:
                              break loop-blocks-6 using player's tool
                            loop blocks in radius 2 of loop-blocks-6:
                              if loop-blocks-7 is iron ore:
                                break loop-blocks-7 using player's tool
                              loop blocks in radius 2 of loop-blocks-7:
                                if loop-blocks-8 is iron ore:
                                  break loop-blocks-8 using player's tool
                                  loop blocks in radius 2 of loop-blocks-8:
                                    if loop-blocks-9 is iron ore:
                                      break loop-blocks-9 using player's tool
                                      loop blocks in radius 2 of loop-blocks-9:
                                        if loop-blocks-10 is iron ore:
                                          break loop-blocks-10 using player's tool
on mine of any ore:
  player is sneaking:
    if event-block is coal ore:
      cancel event
      loop blocks in radius 2 around event-block:
        if loop-blocks is coal ore:
          loop blocks in radius 2 of loop-blocks:
            if loop-block-2 is coal ore:
              break event-block using player's tool
              break loop-blocks-2 using player's tool
              loop blocks in radius 2 of loop-block-2:
                if loop-block-3 is coal ore:
                  break loop-block-3 using player's tool
                  loop blocks in radius 2 of loop-block-3:
                    if loop-block-4 is coal ore:
                      break loop-block-4 using player's tool
                      loop blocks in radius 2 of loop-block-4:
                        if loop-block-4 is coal ore:
                          break loop-block-5 using player's tool
                          loop blocks in radius 2 of loop-blocks-5:
                            if loop-blocks-6 is coal ore:
                              break loop-blocks-6 using player's tool
                              loop blocks in radius 2 of loop-blocks-6:
                                if loop-blocks-7 is coal ore:
                                  break loop-blocks-7 using player's tool
                                  loop blocks in radius 2 of loop-blocks-7:
                                    if loop-blocks-8 is coal ore:
                                      break loop-blocks-8 using player's tool
                                      loop blocks in radius 2 of loop-blocks-8:
                                        if loop-blocks-9 is coal ore:
                                          break loop-blocks-9 using player's tool
                                          loop blocks in radius 2 of loop-blocks-9:
                                            if loop-blocks-10 is coal ore:
                                              break loop-blocks-10 using player's tool
on mine of any ore:
  player is sneaking:
    if event-block is gold ore:
      cancel event
      loop blocks in radius 2 around event-block:
        if loop-blocks is gold ore:
          loop blocks in radius 2 of loop-blocks:
            if loop-block-2 is gold ore:
              break event-block using player's tool
              break loop-blocks-2 using player's tool
              loop blocks in radius 2 of loop-block-2:
                if loop-block-3 is gold ore:
                  break loop-block-3 using player's tool
                  loop blocks in radius 2 of loop-block-3:
                    if loop-block-4 is gold ore:
                      break loop-block-4 using player's tool
                      loop blocks in radius 2 of loop-block-4:
                        if loop-block-5 is gold ore:
                          break loop-block-5 using player's tool
                          loop blocks in radius 2 of loop-blocks-5:
                            if loop-blocks-6 is gold ore:
                              break loop-blocks-6 using player's tool
                              loop blocks in radius 2 of loop-blocks-6:
                                if loop-blocks-7 is gold ore:
                                  break loop-blocks-7 using player's tool
                                  loop blocks in radius 2 of loop-blocks-7:
                                    if loop-blocks-8 is gold ore:
                                      break loop-blocks-8 using player's tool
                                      loop blocks in radius 2 of loop-blocks-8:
                                        if loop-blocks-9 is gold ore:
                                          break loop-blocks-9 using player's tool
                                          loop blocks in radius 2 of loop-blocks-9:
                                            if loop-blocks-10 is gold ore:
                                              break loop-blocks-10 using player's tool
on mine of any ore:
  player is sneaking:
    if event-block is emerald ore:
      cancel event
      loop blocks in radius 2 around event-block:
        if loop-blocks is emerald ore:
          loop blocks in radius 2 of loop-blocks:
            if loop-block-2 is emerald ore:
              break event-block using player's tool
              break loop-blocks-2 using player's tool
              loop blocks in radius 2 of loop-block-2:
                if loop-block-3 is emerald ore:
                  break loop-block-3 using player's tool
                  loop blocks in radius 2 of loop-block-3:
                    if loop-block-4 is emerald ore:
                      break loop-block-4 using player's tool
                      loop blocks in radius 2 of loop-block-4:
                        if loop-block-5 is emerald ore:
                          break loop-block-5 using player's tool
                          loop blocks in radius 2 of loop-blocks-5:
                            if loop-blocks-6 is emerald ore:
                              break loop-blocks-6 using player's tool
                              loop blocks in radius 2 of loop-blocks-6:
                                if loop-blocks-7 is emerald ore:
                                  break loop-blocks-7 using player's tool
                                  loop blocks in radius 2 of loop-blocks-7:
                                    if loop-blocks-8 is emerald ore:
                                      break loop-blocks-8 using player's tool
                                      loop blocks in radius 2 of loop-blocks-8:
                                        if loop-blocks-9 is emerald ore:
                                          break loop-blocks-9 using player's tool
                                          loop blocks in radius 2 of loop-blocks-9:
                                            if loop-blocks-10 is emerald ore:
                                              break loop-blocks-10 using player's tool
on mine of any ore:
  player is sneaking:
    if event-block is lapis ore:
      cancel event
      loop blocks in radius 2 around event-block:
        if loop-blocks is lapis ore:
          loop blocks in radius 2 of loop-blocks:
            if loop-block-2 is lapis ore:
              break event-block using player's tool
              break loop-blocks-2 using player's tool
              loop blocks in radius 2 of loop-block-2:
                if loop-block-3 is lapis ore:
                  break loop-block-3 using player's tool
                  loop blocks in radius 2 of loop-block-3:
                    if loop-block-4 is lapis ore:
                      break loop-block-4 using player's tool
                      loop blocks in radius 2 of loop-block-4:
                        if loop-block-5 is lapis ore:
                          break loop-block-5 using player's tool
                          loop blocks in radius 2 of loop-blocks-5:
                            if loop-blocks-6 is lapis ore:
                              break loop-blocks-6 using player's tool
                              loop blocks in radius 2 of loop-blocks-6:
                                if loop-blocks-7 is lapis ore:
                                  break loop-blocks-7 using player's tool
                                  loop blocks in radius 2 of loop-blocks-7:
                                    if loop-blocks-8 is lapis ore:
                                      break loop-blocks-8 using player's tool
                                      loop blocks in radius 2 of loop-blocks-8:
                                        if loop-blocks-9 is lapis ore:
                                          break loop-blocks-9 using player's tool
                                          loop blocks in radius 2 of loop-blocks-9:
                                            if loop-blocks-10 is lapis ore:
                                              break loop-blocks-10 using player's tool
on mine of any ore:
  player is sneaking:
    if event-block is redstone ore:
      cancel event
      loop blocks in radius 2 around event-block:
        if loop-blocks is redstone ore:
          loop blocks in radius 2 of loop-blocks:
            if loop-block-2 is redstone ore:
              break event-block using player's tool
              break loop-blocks-2 using player's tool
              loop blocks in radius 2 of loop-block-2:
                if loop-block-3 is redstone ore:
                  break loop-block-3 using player's tool
                  loop blocks in radius 2 of loop-block-3:
                    if loop-block-4 is redstone ore:
                      break loop-block-4 using player's tool
                      loop blocks in radius 2 of loop-block-4:
                        if loop-block-5 is redstone ore:
                          break loop-block-5 using player's tool
                          loop blocks in radius 2 of loop-blocks-5:
                            if loop-blocks-6 is redstone ore:
                              break loop-blocks-6 using player's tool
                              loop blocks in radius 2 of loop-blocks-6:
                                if loop-blocks-7 is redstone ore:
                                  break loop-blocks-7 using player's tool
                                  loop blocks in radius 2 of loop-blocks-7:
                                    if loop-blocks-8 is redstone ore:
                                      break loop-blocks-8 using player's tool
                                      loop blocks in radius 2 of loop-blocks-8:
                                        if loop-blocks-9 is redstone ore:
                                          break loop-blocks-9 using player's tool
                                          loop blocks in radius 2 of loop-blocks-9:
                                            if loop-blocks-10 is redstone ore:
                                              break loop-blocks-10 using player's tool
on mine of any ore:
  player is sneaking:
    if event-block is diamond ore:
      cancel event
      loop blocks in radius 2 around event-block:
        if loop-blocks is diamond ore:
          loop blocks in radius 2 of loop-blocks:
            if loop-block-2 is diamond ore:
              break event-block using player's tool
              break loop-blocks-2 using player's tool
              loop blocks in radius 2 of loop-block-2:
                if loop-block-3 is diamond ore:
                  break loop-block-3 using player's tool
                  loop blocks in radius 2 of loop-block-3:
                    if loop-block-4 is diamond ore:
                      break loop-block-4 using player's tool
                      loop blocks in radius 2 of loop-block-4:
                        if loop-block-5 is diamond ore:
                          break loop-block-5 using player's tool
                          loop blocks in radius 2 of loop-blocks-5:
                            if loop-blocks-6 is diamond ore:
                              break loop-blocks-6 using player's tool
                              loop blocks in radius 2 of loop-blocks-6:
                                if loop-blocks-7 is diamond ore:
                                  break loop-blocks-7 using player's tool
                                  loop blocks in radius 2 of loop-blocks-7:
                                    if loop-blocks-8 is diamond ore:
                                      break loop-blocks-8 using player's tool
                                      loop blocks in radius 2 of loop-blocks-8:
                                        if loop-blocks-9 is diamond ore:
                                          break loop-blocks-9 using player's tool
                                          loop blocks in radius 2 of loop-blocks-9:
                                            if loop-blocks-10 is diamond ore:
                                              break loop-blocks-10 using player's tool
on mine of any ore:
  player is sneaking:
    if event-block is nether quartz ore:
      cancel event
      loop blocks in radius 2 around event-block:
        if loop-blocks is nether quartz ore:
          loop blocks in radius 2 of loop-blocks:
            if loop-block-2 is nether quartz ore:
              break event-block using player's tool
              break loop-blocks-2 using player's tool
              loop blocks in radius 2 of loop-block-2:
                if loop-block-3 is nether quartz ore:
                  break loop-block-3 using player's tool
                  loop blocks in radius 2 of loop-block-3:
                    if loop-block-4 is nether quartz ore:
                      break loop-block-4 using player's tool
                      loop blocks in radius 2 of loop-block-4:
                        if loop-block-5 is nether quartz ore:
                          break loop-block-5 using player's tool
                          loop blocks in radius 2 of loop-blocks-5:
                            if loop-blocks-6 is nether quartz ore:
                              break loop-blocks-6 using player's tool
                              loop blocks in radius 2 of loop-blocks-6:
                                if loop-blocks-7 is nether quartz ore:
                                  break loop-blocks-7 using player's tool
                                  loop blocks in radius 2 of loop-blocks-7:
                                    if loop-blocks-8 is nether quartz ore:
                                      break loop-blocks-8 using player's tool
                                      loop blocks in radius 2 of loop-blocks-8:
                                        if loop-blocks-9 is nether quartz ore:
                                          break loop-blocks-9 using player's tool
                                          loop blocks in radius 2 of loop-blocks-9:
                                            if loop-block-10 is nether quartz ore:
                                              break loop-blocks-10 using player's tool
 
Status
Not open for further replies.