Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function up(x)
- repeat
- x=x-1
- while not turtle.up() do
- print("Failed to move UP")
- sleep(0.2)
- end
- until x==0
- end
- local function down(x)
- repeat
- x=x-1
- while not turtle.down() do
- print("Failed to move DOWN")
- sleep(0.2)
- end
- until x==0
- end
- local function forward(x)
- repeat
- x=x-1
- while not turtle.forward() do
- print("Failed to move FORWARD")
- sleep(0.2)
- end
- until x==0
- end
- local function back(x)
- repeat
- x=x-1
- while not turtle.back() do
- print("Failed to move BACK")
- sleep(0.2)
- end
- until x==0
- end
- local function left(x)
- repeat
- x=x-1
- turtle.turnLeft()
- until x==0
- end
- local function right(x)
- repeat
- x=x-1
- turtle.turnRight()
- until x==0
- end
- local function fuel()
- if turtle.getFuelLevel() < 1000 then do
- turtle.select(1)
- turtle.refuel(10)
- end
- end
- end
- local function fell()
- forward(10)
- right(1)
- turtle.select(2)
- while not turtle.compare() do
- print("Tree not grown yet")
- sleep(5.0)
- end
- turtle.dig()
- forward(1)
- while turtle.compare() do
- turtle.dig()
- turtle.digUp()
- up(1)
- end
- fuel()
- left(1)
- turtle.dig()
- forward(1)
- right(1)
- while turtle.compareDown() do
- turtle.digDown()
- down(1)
- turtle.dig()
- end
- fuel()
- end
- local function plant()
- up(1)
- turtle.select(3)
- x=2
- repeat
- x=x-1
- turtle.placeDown()
- forward(1)
- right(1)
- until x==0
- turtle.placeDown()
- forward(1)
- turtle.placeDown()
- forward(1)
- down(1)
- left(1)
- forward(10)
- left(1)
- j = turtle.getItemCount()
- turtle.suck(5-j)
- left(1)
- fuel()
- end
- local function drop()
- for i=4,16 do
- turtle.select(i)
- p = turtle.getItemCount(i)
- turtle.dropDown(p-1)
- end
- end
- local function suck()
- turtle.select(1)
- turtle.suckDown()
- end
- local function supply()
- left(1)
- up(4)
- forward(24)
- left(1)
- forward(12)
- down(1)
- drop()
- forward(1)
- suck()
- left(2)
- up(1)
- forward(13)
- right(1)
- forward(24)
- down(4)
- left(1)
- fuel()
- end
- local function program()
- y=1
- repeat
- fell()
- plant()
- supply()
- until y==2
- end
- function stopLoop()
- repeat
- local ev, key = os.pullEvent('key')
- until key == keys.backspace
- y=2
- end
- parallel.waitForAll(stopLoop, program)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement