commit 57baf1311026ba569c6ed91c0bdee147bc266c02 Author: Dominic Zimmer Date: Sat Jul 4 11:58:17 2020 +0200 Initial commit diff --git a/dominic/ceiling.lua b/dominic/ceiling.lua new file mode 100644 index 0000000..a422a5b --- /dev/null +++ b/dominic/ceiling.lua @@ -0,0 +1,19 @@ +local function ceiling() + for n=1,8 do + for step=1,15 do + turtle.placeUp() + turtle.forward() + end + turtle.turnRight() + turtle.forward() + turtle.turnRight() + for step=1,15 do + turtle.placeUp() + turtle.forward() + end + turtle.turnLeft() + turtle.forward() + turtle.turnLeft() + end +end +ceiling() diff --git a/dominic/farming.lua b/dominic/farming.lua new file mode 100644 index 0000000..006a31b --- /dev/null +++ b/dominic/farming.lua @@ -0,0 +1,107 @@ +counter = 0 +local function doCrop(parity) + if (counter % 5 == parity) then + turtle.placeDown() + end + counter = counter + 1 +end + +local function harvest() + local status, result = turtle.inspectDown() + if not status then + turtle.placeDown() + else + if result["name"] == "minecraft:potatoes" then + if result["state"]["age"] == 7 then + turtle.digDown() + turtle.placeDown() + end + end + end +end + +local function doRefuel() + for i = 1,16 do + turtle.select(i) + if turtle.refuel(1) then + turtle.select(1) + return true + end + end + turtle.select(1) + return false +end + +local function doAtChest() + -- remove items + print("Unloading Items...") + turtle.turnLeft() + for i = 2,16 do + turtle.select(i) + turtle.drop() + end + turtle.select(1) + turtle.turnRight() + turtle.turnRight() + -- refuel turtle + print("Refueling...") + while turtle.getFuelLevel() < 370 do + turtle.suckUp(1) + if (not doRefuel()) then + print("I am out of fuel. [r] to retry") + while true do + local event, key = os.pullEvent("key") + if key == keys.r then + break + end + end + end + end +end + +local function whatDo() + harvest() +end + +local function farm() + doAtChest() + whatDo() -- on start + print("Starting harvest...") + turtle.forward() + for i=1,9 do + for j=1,16 do + whatDo() + turtle.forward() + end + whatDo() + turtle.turnLeft() + turtle.back() + whatDo() + turtle.turnLeft() + for j=1,16 do + whatDo() + turtle.forward() + end + if i < 9 then + whatDo() + turtle.turnLeft() + turtle.forward() + whatDo() + turtle.turnLeft() + else + whatDo() + turtle.forward() + turtle.turnRight() + for j =1,17 do + whatDo() + turtle.forward() + end + end + end +end + +while true do + farm() + print("Waiting 30 seconds...") + sleep(30) +end diff --git a/dominic/parity.lua b/dominic/parity.lua new file mode 100644 index 0000000..3b5775e --- /dev/null +++ b/dominic/parity.lua @@ -0,0 +1,44 @@ +x = 0 +y = 0 +lookup = {4, 1, 3, 0, 2} +local function test() + local val = lookup[(y % 5) + 1] + return (x % 5) == val +end + +local function run() + for i = 1,3 do + for j = 1,6 do + turtle.forward() + x = x + 1 + if test() then + turtle.digDown() + end + end + turtle.turnRight() + turtle.forward() + y = y + 1 + if test() then + turtle.digDown() + end + turtle.turnRight() + for j = 1,6 do + turtle.forward() + x = x - 1 + if test() then + turtle.digDown() + end + if test() then + turtle.digDown() + end + end + turtle.turnLeft() + turtle.forward() + y = y + 1 + if test() then + turtle.digDown() + end + turtle.turnLeft() + end +end +run()