Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Planter v1.0
- local borderSlot = 1
- local digSlot = 2
- local startFrom = "right"
- local facingForwardFromStartView = true
- local seeds = {}
- local standardColor = colors.lime
- local specialColor = colors.pink
- function cPrint(s)
- term.clear()
- term.setCursorPos(1,1)
- for i = 1, string.len(s) do
- c = string.sub(s, i, i)
- if c == "[" then
- term.setTextColor(specialColor)
- elseif c == "]" then
- term.setTextColor(standardColor)
- else
- write(c)
- end
- end
- print()
- end
- function turn()
- if facingForwardFromStartView then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- end
- function invert()
- facingForwardFromStartView = not facingForwardFromStartView
- end
- function seed()
- for i = 1, #seeds do
- if turtle.getItemCount(seeds[i]) > 0 then
- turtle.select(seeds[i])
- turtle.placeDown()
- if turtle.getItemCount(seeds[i]) < 1 then
- table.remove(seeds, i)
- end
- return true
- end
- end
- return false
- end
- -- MAIN
- term.setTextColor(standardColor)
- local atom = true
- while turtle.getItemCount(borderSlot) < 1 do
- if atom then
- cPrint("Place a border [around] your field\nwith any material. Put at least 1 piece of that material into slot [" .. borderSlot .. "].")
- atom = false
- end
- sleep(1)
- end
- cPrint("Is your turtle positioned\n[L]eft or [R]ight?")
- while true do
- local event, key = os.pullEvent("char")
- if key == 'r' then
- startFrom = "right"
- facingForwardFromStartView = true
- break
- end
- if key == 'l' then
- startFrom = "left"
- facingForwardFromStartView = false
- break
- end
- end
- cPrint("If you want to [place seeds] after\nharvesting, then just put seeds in\nand press [enter] to start.")
- read()
- for i = 2, 16 do
- if turtle.getItemCount(i) > 0 then
- table.insert(seeds, i)
- end
- end
- turtle.forward()
- turtle.digDown()
- turtle.down()
- local rows = 0
- local run1rows = 0
- local go = true
- while go do
- turtle.select(borderSlot)
- if turtle.compare() then
- turn()
- turtle.select(borderSlot)
- if turtle.compare() then
- turtle.up()
- run1rows = rows + 1
- while rows > 0 do
- turtle.back()
- rows = rows - 1
- end
- invert()
- turn()
- turn()
- turn()
- turtle.back()
- go = false
- break
- else
- turtle.select(digSlot)
- turtle.dig()
- turtle.forward()
- end
- turn()
- invert()
- rows = rows + 1
- end
- turtle.select(digSlot)
- turtle.dig()
- turtle.forward()
- end
- if #seeds < 1 then
- return
- end
- turtle.forward()
- seed()
- rows = run1rows
- while run1rows > 0 do
- turtle.select(borderSlot)
- if turtle.compareDown() then
- if run1rows > 1 then
- turn()
- turtle.forward()
- turn()
- turtle.forward()
- invert()
- run1rows = run1rows - 1
- else
- turn()
- while rows > 1 do
- turtle.back()
- rows = rows - 1
- end
- turn()
- break
- end
- end
- seed()
- turtle.forward()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement