summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2022-06-27 23:22:23 +0100
committerubq323 <ubq323@ubq323.website>2022-06-27 23:22:23 +0100
commit9caee3dc03204371ec99217e86c031e02e2f207e (patch)
treee044efecf1dc16f4dffc6fb59b1b3c599e5123ee
parentaad419329b046a12882a117f6ccf2a138a9dc8f2 (diff)
pm
-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