Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --placeholders
- turned = false
- size = "10x10"
- --rowdone
- rdone = false
- cdone = false
- --turtles actual position R,C
- tapos = {1,1}
- --Visual Layout
- function rsetV()
- vlayout = {
- {"####### [1-12]W [13-16]S #######"},
- {"[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]"},
- {"[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]"},
- {"[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]"},
- {"[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]"},
- {"[ ]","[ ]","[ ]","[ ]","[X]","[X]","[ ]","[ ]","[ ]","[ ]"},
- {"[ ]","[ ]","[ ]","[ ]","[X]","[X]","[ ]","[ ]","[ ]","[ ]"},
- {"[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]"},
- {"[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]"},
- {"[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]"},
- {"[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]"},
- {"##############################"}
- }
- end
- --turtlepositionRow turtlepositionColumn
- function drawMap(tposR, tposC)
- term.clear()
- term.setCursorPos(1,2)
- rsetV()
- vlayout[tposR+1][tposC] = "[@]"
- for k,v in pairs(vlayout) do
- for s,j in pairs(vlayout[k]) do
- write(j)
- end
- write("\n")
- end
- end
- function fHome()
- while true do
- if turtle.detectUp() then
- if turned then
- turtle.turnRight()
- end
- break
- else
- turned = true
- while turtle.back() do end
- turtle.turnLeft()
- end
- end
- drawMap(1,1)
- return true
- end
- function eInv()
- for i = 1, 16 do
- turtle.select(i)
- local inn = turtle.getItemCount()
- if inn > 8 then
- turtle.dropUp(inn-5)
- end
- end
- end
- function checkPlant()
- --pickup remaining items
- turtle.suckDown()
- local stat, insp = turtle.inspectDown()
- if stat then
- if insp.state.age == 7 then
- return true
- end
- return false
- end
- end
- function harvest()
- if checkPlant() == true then
- turtle.select(1)
- turtle.digDown()
- turtle.suckDown()
- for i = 13,16 do
- turtle.select(i)
- turtle.placeDown()
- end
- end
- end
- function garden()
- for i = 1, 10 do
- tapos[1] = i
- if i == 1 or i == 3 or i == 5 or i == 7 or i == 9 then
- repeat
- if turtle.forward() then
- drawMap(tapos[1],tapos[2])
- tapos[2] = tapos[2]+1
- --Insert plant check
- harvest()
- end
- if tapos[2] == 10 then
- rdone = true
- end
- until rdone == true
- rdone = false
- end
- if i == 2 or i == 4 or i == 6 or i == 8 or i == 10 then
- repeat
- if turtle.back() then
- drawMap(tapos[1],tapos[2])
- tapos[2] = tapos[2]-1
- --Insert plant check
- harvest()
- end
- if tapos[2] == 1 then
- rdone = true
- end
- until rdone == true
- rdone = false
- end
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- end
- turtle.turnRight()
- for i = 1,9 do
- turtle.back()
- end
- turtle.turnLeft()
- end
- fHome()
- while true do
- eInv()
- garden()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement