This repository was archived by the owner on Jun 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauto_include.ms
More file actions
37 lines (35 loc) · 1.29 KB
/
auto_include.ms
File metadata and controls
37 lines (35 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#===============================================================================
#
# Sample external MethodScript include
#
#===============================================================================
/**
* Returns the distance between two blocks, or any other 3d points, for that matter.
* @param array @arr1 The first point, expects an array of x, y, z
* @param array @arr2 The second point, expects an array of x, y, z
*/
proc(_3d_distance, @arr1, @arr2,
return(
floor(
sqrt(
((@arr2[0] - @arr1[0]) ** 2)
+ ((@arr2[1] - @arr1[1]) ** 2)
+ ((@arr2[2] - @arr1[2]) ** 2)
)
)
)
)
/**
* Given two blocks, iterates through all the blocks inside the cuboid, and calls the
* user defined function on them. The used defined procedure should accept 3 parameters,
* the x, y, and z coordinates of the block.
*/
proc(_iterate_cuboid, @b1, @b2, @proc_name,
for(assign(@x, min(@b1[0], @b2[0])), @x <= max(@b1[0], @b2[0]), @x++,
for(assign(@y, min(@b1[1], @b2[1])), @y <= max(@b1[1], @b2[1]), @y++,
for(assign(@z, min(@b1[2], @b2[2])), @z <= max(@b1[2], @b2[2]), @z++,
call_proc(@proc_name, @x, @y, @z)
)
)
)
)