# Solved How to count blocks between coordinates

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

Tags:
Not open for further replies.
1. ### fasteR New Member

Joined:
Dec 10, 2020
Messages:
8
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
Last edited: Dec 22, 2020
2. ### Marc Active Member

Joined:
Nov 27, 2020
Messages:
94
0
Not sure thats possible, could you tell me what is for so we can find a different solution?

#2
• Friendly x 1
3. ### fasteR New Member

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

#3
4. ### MusicManSK Active Member

Joined:
Nov 30, 2017
Messages:
232
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!"

#4
5. ### fasteR New Member

Joined:
Dec 10, 2020
Messages:
8
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

#5
6. ### Marc Active Member

Joined:
Nov 27, 2020
Messages:
94
0
What are you even trying to do lol?

#6
7. ### fasteR New Member

Joined:
Dec 10, 2020
Messages:
8
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
Last edited: Dec 24, 2020
8. ### MusicManSK Active Member

Joined:
Nov 30, 2017
Messages:
232
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.

#8
9. ### fasteR New Member

Joined:
Dec 10, 2020
Messages:
8
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
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
Last edited: Dec 24, 2020
10. ### MusicManSK Active Member

Joined:
Nov 30, 2017
Messages:
232
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.

#10
Not open for further replies.