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

Loop blocks within 2 locations

Discussion in 'Skript' started by kai1846456, Jul 1, 2020.

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

    kai1846456 New Member

    Joined:
    Feb 18, 2018
    Messages:
    5
    Likes Received:
    0
    Skript version: 2.4.1
    Minecraft Version: 1.16.1

    Code:
    Code (Text):
    1. loop all blocks within block at {_location-1} and block at {_location-2}:
    2.  
    The code works - however, rather than looping all blocks within the 2 locations, its only looping blocks between the 2 locations. Any solutions?
     
  2. egamer3000

    egamer3000 Member

    Joined:
    Nov 25, 2019
    Messages:
    37
    Likes Received:
    8
    Code (Text):
    1. loop all blocks between {_location-1} and {_location-2}:
    2.  
    should be it.
     
  3. kai1846456

    kai1846456 New Member

    Joined:
    Feb 18, 2018
    Messages:
    5
    Likes Received:
    0
    Does the same thing.
     
  4. egamer3000

    egamer3000 Member

    Joined:
    Nov 25, 2019
    Messages:
    37
    Likes Received:
    8
    that's strange. try debugging it with this:
    Code (Text):
    1.  
    2. set blocks between {_location-1} and {_location-2} to air
    possibly.
    for me, that's worked, so im not too sure..
     
  5. kai1846456

    kai1846456 New Member

    Joined:
    Feb 18, 2018
    Messages:
    5
    Likes Received:
    0
    That worked for me however when i use that in a loop, it does nothing.
    Code (Text):
    1. loop all blocks between {_location-1} and {_location-2}:
     
  6. egamer3000

    egamer3000 Member

    Joined:
    Nov 25, 2019
    Messages:
    37
    Likes Received:
    8
    that's really weird.. could you send your code?
     
  7. kai1846456

    kai1846456 New Member

    Joined:
    Feb 18, 2018
    Messages:
    5
    Likes Received:
    0
    Code (Text):
    1.             set {_location-1} to {_l}
    2.             set {_location-2} to {_l}
    3.             set {_location-1-complete} to false
    4.             set {_location-2-complete} to false
    5.             while {_location-1-complete} is false:
    6.                 add 1 to the x coord of {_location-1}
    7.                 if "%block at {_location-1}%" contains "bedrock":
    8.                     remove 1 from the x coord of {_location-1}
    9.                     exit loop
    10.             while {_location-1-complete} is false:
    11.                 add 1 to the z coord of {_location-1}
    12.                 if "%block at {_location-1}%" contains "bedrock":
    13.                     remove 1 from the z coord of {_location-1}
    14.                     exit loop
    15.             while {_location-2-complete} is false:
    16.                 remove 1 from the x coord of {_location-2}
    17.                 if "%block at {_location-2}%" contains "bedrock":
    18.                     add 1 to the x coord of {_location-2}
    19.                     exit loop
    20.             while {_location-2-complete} is false:
    21.                 remove 1 from the z coord of {_location-2}
    22.                 if "%block at {_location-2}%" contains "bedrock":
    23.                     add 1 to the z coord of {_location-2}
    24.                     exit loop
    25.             send "%{_location-1}%" to {_p}
    26.             send "%{_location-2}%" to {_p}
    27.             loop all blocks between {_location-1} and {_location-2}:
    28.                 set {_bk} to "%loop-block%" parsed as itemtype
    29.                 send "%location of loop-block%" to {_p}
    30.                 if {sell::%{_bk}%} is set:
    31.                     sell({_p}, loop-block)
    32.                     set loop-block to air
    33.  
    --- Double Post Merged, Jul 2, 2020, Original Post Date: Jul 2, 2020 ---
    It finds the correct coordinates i have checked this via the 2 messages sent before the loop
    However, no blocks are cleared and none of the code under the loop is executed.
     
  8. egamer3000

    egamer3000 Member

    Joined:
    Nov 25, 2019
    Messages:
    37
    Likes Received:
    8
    that is.. really weird. honestly, im not sure.. sorry :c
     
  9. kai1846456

    kai1846456 New Member

    Joined:
    Feb 18, 2018
    Messages:
    5
    Likes Received:
    0
    Ive also tried within and that didnt work but used to
     
  10. Detective Vapor

    Joined:
    Jul 2, 2020
    Messages:
    15
    Likes Received:
    0
    What is your goal?
     
  11. egamer3000

    egamer3000 Member

    Joined:
    Nov 25, 2019
    Messages:
    37
    Likes Received:
    8
    instead of creating a line from location 1 to location 2, they want it to make a block from location 1 to location 2
     
  12. Detective Vapor

    Joined:
    Jul 2, 2020
    Messages:
    15
    Likes Received:
    0
    That's a little confusing, can you explain what you are using this to do? It might give us a better idea of how to help. @kai1846456
     
  13. Juffix

    Juffix Member

    Joined:
    Apr 7, 2019
    Messages:
    19
    Likes Received:
    4
    Try
    Code (Text):
    1. loop blocks within {_location-1} and {_location-2}:
     
    • Useful Useful x 1
Thread Status:
Not open for further replies.

Share This Page

Loading...