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.

Solved How to count blocks between coordinates

Discussion in 'Skript' started by fasteR, Dec 22, 2020.

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

    fasteR New Member

    Joined:
    Dec 10, 2020
    Messages:
    8
    Likes Received:
    0
    Hi,
    I want to count blocks in a region that between two coordinates. I am tried to find it in Google but I couldn't.
     
    #1 fasteR, Dec 22, 2020
    Last edited: Dec 22, 2020
  2. Marc

    Marc Active Member

    Joined:
    Nov 27, 2020
    Messages:
    94
    Likes Received:
    0
    Not sure thats possible, could you tell me what is for so we can find a different solution?
     
    • Friendly Friendly x 1
  3. fasteR

    fasteR New Member

    Joined:
    Dec 10, 2020
    Messages:
    8
    Likes Received:
    0
    Thanks, i found the skript in the forum. Click
     
  4. MusicManSK

    MusicManSK Active Member

    Joined:
    Nov 30, 2017
    Messages:
    232
    Likes Received:
    11
    This is such a waste of performance. You can just calculate sides of box and then calculate volume of that box. You don't have to loop through each block in box.

    Code (Text):
    1. set {_a} to x coord of {_loc2} - x coord of {_loc1}
    2.     set {_b} to y coord of {_loc2} - y coord of {_loc1}
    3.     set {_c} to z coord of {_loc2} - z coord of {_loc1}
    4.    
    5.     set {_V} to {_a} * {_b} * {_c}
    6.    
    7.     send "%{_V}% blocks found!"
     
  5. fasteR

    fasteR New Member

    Joined:
    Dec 10, 2020
    Messages:
    8
    Likes Received:
    0
    It is not working. I am not a master skripter so i dont know where is the problem. It is just finding 0 blocks.
    Code (Text):
    1. command /test:
    2.     trigger:
    3.         set {_a} to x coord of {_loc2} - x coord of {_loc1}
    4.         set {_b} to y coord of {_loc2} - y coord of {_loc1}
    5.         set {_c} to z coord of {_loc2} - z coord of {_loc1}
    6.  
    7.         set {_V} to {_a} * {_b} * {_c}
    8.  
    9.         send "%{_V}% blocks found!"
    10. command /loc1:
    11.     trigger:
    12.         set {_loc1} to target block's location
    13. command /loc2:
    14.     trigger:
    15.         set {_loc2} to target block's location
     
  6. Marc

    Marc Active Member

    Joined:
    Nov 27, 2020
    Messages:
    94
    Likes Received:
    0
    What are you even trying to do lol?
     
  7. fasteR

    fasteR New Member

    Joined:
    Dec 10, 2020
    Messages:
    8
    Likes Received:
    0
    When players use my skript it will count the blocks from the area that player's located and then it will set a block (selected block by player) to area and then remove blocks from inventory. I made it.
     
    #7 fasteR, Dec 23, 2020
    Last edited: Dec 24, 2020
  8. MusicManSK

    MusicManSK Active Member

    Joined:
    Nov 30, 2017
    Messages:
    232
    Likes Received:
    11
    Remove `_`s from `{_loc1}` and `{_loc2}` to make them global variables. `_` means it's local variable and those are only available in local scope.
     
  9. fasteR

    fasteR New Member

    Joined:
    Dec 10, 2020
    Messages:
    8
    Likes Received:
    0
    Okay, I'll try when i'm avaliable. So you mean when i remove '_'s from variables, they can be used from another skripts? Or in one skript but other commands

    EDIT
    Still not working your code.
    I am tried to execute these skripts:
    Code (Text):
    1. command /test:
    2.     trigger:
    3.         if {loc2} is greater than {loc1}:
    4.             set {a} to x coord of {loc2} - x coord of {loc1}
    5.             set {b} to y coord of {loc2} - y coord of {loc1}
    6.             set {c} to z coord of {loc2} - z coord of {loc1}
    7.             set {V} to {a} * {b} * {c}
    8.         else if {loc2} is less than {loc1}:
    9.             set {a} to x coord of {loc1} - x coord of {loc2}
    10.             set {b} to y coord of {loc1} - y coord of {loc2}
    11.             set {c} to z coord of {loc1} - z coord of {loc2}
    12.             set {V} to {a} * {b} * {c}
    13.         else if {loc2} is equal to {loc1}:
    14.             set {V} to "0"
    15.  
    16.         send "%{V}% blocks found!"
    17. command /loc1:
    18.     trigger:
    19.         set {loc1} to target block's location
    20. command /loc2:
    21.     trigger:
    22.         set {loc2} to target block's location
    Code (Text):
    1. command /test:
    2.     trigger:
    3.         set {a} to x coord of {loc2} - x coord of {loc1}
    4.         set {b} to y coord of {loc2} - y coord of {loc1}
    5.         set {c} to z coord of {loc2} - z coord of {loc1}
    6.  
    7.         set {V} to {a} * {b} * {c}
    8.  
    9.         send "%{V}% blocks found!"
    10. command /loc1:
    11.     trigger:
    12.         set {loc1} to target block's location
    13. command /loc2:
    14.     trigger:
    15.         set {loc2} to target block's location
     
    #9 fasteR, Dec 24, 2020
    Last edited: Dec 24, 2020
  10. MusicManSK

    MusicManSK Active Member

    Joined:
    Nov 30, 2017
    Messages:
    232
    Likes Received:
    11
    I don't know what's wrong. The idea is correct. Maybe instead of `target block's location` you should use `player's location`. Since `target block` is block you are looking at and if that block is not available it might went wrong.
     
Thread Status:
Not open for further replies.

Share This Page

Loading...