Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local laser = peripheral.wrap "right"
- local yaw = tonumber(... or 0)
- local blocksRemovedPerShot = 2
- local function fmt2dp(x)
- return ("%.2f"):format(x)
- end
- local function shootBlock(depth, forward)
- -- HERE BE TRIGONOMETRY
- local firingAngle = math.atan(depth / forward)
- local distanceToTarget = depth / math.sin(firingAngle)
- for i = 0, math.floor(distanceToTarget / blocksRemovedPerShot) do
- print("DIST", fmt2dp(distanceToTarget), "ANGL", fmt2dp(math.deg(firingAngle)), "DPTH", fmt2dp(depth), "FRWD", fmt2dp(forward))
- laser.fire(yaw, math.deg(firingAngle), 5)
- end
- end
- for depth = 0, 64 do
- shootBlock(depth, 16)
- end
- for forward = 16, 0, -1 do
- shootBlock(64, forward)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement