From 9caee3dc03204371ec99217e86c031e02e2f207e Mon Sep 17 00:00:00 2001 From: ubq323 Date: Mon, 27 Jun 2022 23:22:23 +0100 Subject: pm --- hole.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 hole.lua 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 -- cgit v1.2.3