summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hole.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/hole.lua b/hole.lua
new file mode 100644
index 0000000..6c2501a
--- /dev/null
+++ b/hole.lua
@@ -0,0 +1,23 @@
+local function yaw_pitch(xoff,yoff,zoff)
+ local yaw = -math.deg(math.atan2(xoff,zoff))
+ local perp_dist = math.sqrt(xoff*xoff+zoff*zoff)
+ local pitch = -math.deg(math.atan2(yoff, perp_dist))
+ return yaw,pitch
+end
+
+local scanner = assert(peripheral.wrap"right")
+local laser = assert(peripheral.wrap"left")
+
+repeat
+ local targets = {}
+ local scanned = scanner.scan()
+ for _,v in ipairs(scanned) do
+ if v.name == "minecraft:cobblestone" then
+ table.insert(targets,v)
+ end
+ end
+ for _,t in ipairs(targets) do
+ local yaw,pitch = yaw_pitch(t.x,t.y,t.z)
+ laser.fire(yaw,pitch,1)
+ end
+until #targets == 0