Solved How to count blocks between coordinates

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

fasteR

New Member
Dec 10, 2020
8
0
1
21
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.
 
Last edited:
Not sure thats possible, could you tell me what is for so we can find a different solution?
 
Thanks, i found the skript in the forum. Click
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:
set {_a} to x coord of {_loc2} - x coord of {_loc1}
    set {_b} to y coord of {_loc2} - y coord of {_loc1}
    set {_c} to z coord of {_loc2} - z coord of {_loc1}
    
    set {_V} to {_a} * {_b} * {_c}
    
    send "%{_V}% blocks found!"
 
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:
set {_a} to x coord of {_loc2} - x coord of {_loc1}
    set {_b} to y coord of {_loc2} - y coord of {_loc1}
    set {_c} to z coord of {_loc2} - z coord of {_loc1}
  
    set {_V} to {_a} * {_b} * {_c}
  
    send "%{_V}% blocks found!"
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:
command /test:
    trigger:
        set {_a} to x coord of {_loc2} - x coord of {_loc1}
        set {_b} to y coord of {_loc2} - y coord of {_loc1}
        set {_c} to z coord of {_loc2} - z coord of {_loc1}
 
        set {_V} to {_a} * {_b} * {_c}
 
        send "%{_V}% blocks found!"
command /loc1:
    trigger:
        set {_loc1} to target block's location
command /loc2:
    trigger:
        set {_loc2} to target block's location
 
What are you even trying to do lol?
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.
 
Last edited:
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:
command /test:
    trigger:
        set {_a} to x coord of {_loc2} - x coord of {_loc1}
        set {_b} to y coord of {_loc2} - y coord of {_loc1}
        set {_c} to z coord of {_loc2} - z coord of {_loc1}
 
        set {_V} to {_a} * {_b} * {_c}
 
        send "%{_V}% blocks found!"
command /loc1:
    trigger:
        set {_loc1} to target block's location
command /loc2:
    trigger:
        set {_loc2} to target block's location
Remove `_`s from `{_loc1}` and `{_loc2}` to make them global variables. `_` means it's local variable and those are only available in local scope.
 
Remove `_`s from `{_loc1}` and `{_loc2}` to make them global variables. `_` means it's local variable and those are only available in local scope.
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:
command /test:
    trigger:
        if {loc2} is greater than {loc1}:
            set {a} to x coord of {loc2} - x coord of {loc1}
            set {b} to y coord of {loc2} - y coord of {loc1}
            set {c} to z coord of {loc2} - z coord of {loc1}
            set {V} to {a} * {b} * {c}
        else if {loc2} is less than {loc1}:
            set {a} to x coord of {loc1} - x coord of {loc2}
            set {b} to y coord of {loc1} - y coord of {loc2}
            set {c} to z coord of {loc1} - z coord of {loc2}
            set {V} to {a} * {b} * {c}
        else if {loc2} is equal to {loc1}:
            set {V} to "0"
 
        send "%{V}% blocks found!"
command /loc1:
    trigger:
        set {loc1} to target block's location
command /loc2:
    trigger:
        set {loc2} to target block's location

Code:
command /test:
    trigger:
        set {a} to x coord of {loc2} - x coord of {loc1}
        set {b} to y coord of {loc2} - y coord of {loc1}
        set {c} to z coord of {loc2} - z coord of {loc1}
 
        set {V} to {a} * {b} * {c}
 
        send "%{V}% blocks found!"
command /loc1:
    trigger:
        set {loc1} to target block's location
command /loc2:
    trigger:
        set {loc2} to target block's location
 
Last edited:
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.
 
Status
Not open for further replies.