From 7315e2a4307a0873129b6a6812a18ebd29a05ee9 Mon Sep 17 00:00:00 2001 From: Jan Date: Fri, 23 Jul 2021 14:57:27 +0000 Subject: [PATCH] Add 'dig_area.lua' --- dig_area.lua | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 dig_area.lua diff --git a/dig_area.lua b/dig_area.lua new file mode 100644 index 0000000..8858b0d --- /dev/null +++ b/dig_area.lua @@ -0,0 +1,120 @@ +local t = turtle + +print("Length: ") +local LENGTH = tonumber(read()) +print("Width: ") +local WIDTH = tonumber(read()) +print("Height: ") +local HEIGHT = tonumber(read()) + +--------------------------- + +local function detectedDig() + while t.detect() == true do + t.detect() + t.dig() + end +end + +--------------------------- +for n=1,HEIGHT do + for i=1,WIDTH do + for j=2,LENGTH do + detectedDig() ---- + t.forward() + end + + if WIDTH%2 ~= 0 then + if i+1<=WIDTH then + if i%2 == 0 then + t.turnLeft() + detectedDig() ---- + t.forward() + t.turnLeft() + elseif i%2 ~= 0 then + t.turnRight() + detectedDig() ----- + t.forward() + t.turnRight() + end + end + elseif WIDTH%2 == 0 then + if n%2 == 0 then + if i+1<=WIDTH then + if i%2 ~= 0 then + t.turnLeft() + detectedDig() ----- + t.forward() + t.turnLeft() + elseif i%2 == 0 then + t.turnRight() + detectedDig() ----- + t.forward() + t.turnRight() + end + end + elseif n%2 ~= 0 then + if i+1<=WIDTH then + if i%2 == 0 then + t.turnLeft() + detectedDig() ----- + t.forward() + t.turnLeft() + elseif i%2 ~= 0 then + t.turnRight() + detectedDig() ----- + t.forward() + t.turnRight() + end + end + end + end + end + if n