Initial commit

This commit is contained in:
Dominic Zimmer 2020-07-04 11:58:17 +02:00
commit 57baf13110
3 changed files with 170 additions and 0 deletions

19
dominic/ceiling.lua Normal file
View File

@ -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()

107
dominic/farming.lua Normal file
View File

@ -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

44
dominic/parity.lua Normal file
View File

@ -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()