Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- slots 2-4 164 dirt (64,64,36)
- -- slots 5-8 92 cobblestone (64,28)
- -- slot 9-11 tracks
- -- slot 12-13 empty
- -- slot 14 Dirt
- -- slot 15 Cobblestone
- -- slot 16 coal
- local w,h = term.getSize()
- local selection = 0
- local internalselection = 0
- local range = 0
- local currentrange = 0
- local ypos = 1
- local fuel
- local fuelava
- local counter = 1
- local sandcounter=0
- local cobblecounter=0
- local rightnext = true
- local leftnext = true
- local rightcounter = 0
- --Some draw functions to get us started
- local function printCentered(str, ypos)
- term.setCursorPos(w/2 - #str/2, ypos)
- term.write(str)
- end
- local function printFarLeft(str, ypos)
- term.setCursorPos(1, ypos)
- term.write(str)
- end
- local function printLeft(str, ypos)
- term.setCursorPos(5, ypos)
- term.write(str)
- end
- local function printLeft2(str, ypos)
- term.setCursorPos(10, ypos)
- term.write(str)
- end
- local function printRight(str, ypos)
- term.setCursorPos(w - 15, ypos)
- term.write(str)
- end
- local function printRight2(str, ypos)
- term.setCursorPos(w - 25, ypos)
- term.write(str)
- end
- local function printFarRight(str, ypos)
- term.setCursorPos(w - #str, ypos)
- term.write(str)
- end
- function drawHeader()
- printCentered("Turtle Farm Builder", 1)
- printCentered(string.rep("-", w+1), 2)
- -- print fuel level
- fuel = turtle.getFuelLevel()
- printFarLeft("Fuel " ,3)
- print(fuel)
- -- print avilable fuel
- fuelava = turtle.getItemCount(16)
- printFarLeft("Fuel Available " ,5)
- print(fuelava)
- -- print avilable fuel
- sandcounter = turtle.getItemCount(1) + turtle.getItemCount(2) + turtle.getItemCount(3) + turtle.getItemCount(4) + turtle.getItemCount(5) + turtle.getItemCount(6) + turtle.getItemCount(7) + turtle.getItemCount(8)
- printRight("Sand left "..tostring(sandcounter),3)
- -- print avilable fuel
- cobblecounter = turtle.getItemCount(9) + turtle.getItemCount(10) + turtle.getItemCount(11) + turtle.getItemCount(12)
- printRight("Cobble left "..tostring(cobblecounter),4)
- -- Print Range
- printRight("Range Left "..tostring(range),5)
- end
- function drawMainMenu()
- printLeft2("1. Forward", 7)
- printRight("5. Up", 7)
- printLeft2("2. Backward", 8)
- printRight("6. Down", 8)
- printLeft2("3. Left", 9)
- printRight("7. Start Farm", 9)
- printLeft2("4. Right", 10)
- printRight("8. Quit", 10)
- printLeft2("Selection: ", 12)
- selection = tonumber(read())
- end
- function forward()
- term.clear()
- term.setCursorPos(1,1)
- internalselection=0
- drawHeader()
- printLeft("Forward", 7)
- printLeft("-------", 8)
- printLeft("1. Forward 1", 9)
- printRight("3. Main Menu", 9)
- printLeft("2. Forward range", 10)
- printLeft("Selection: ", 12)
- internalselection = tonumber(read())
- if internalselection==1 then
- turtle.forward()
- term.clear()
- term.setCursorPos(1,1)
- end
- if internalselection==2 then
- term.clear()
- term.setCursorPos(1,1)
- drawHeader()
- printLeft("Forward Range", 7)
- printLeft("-------------", 8)
- printLeft("How far: ", 9)
- currentrange = 0
- range = tonumber(read())
- repeat
- term.clear()
- term.setCursorPos(1,1)
- drawHeader()
- turtle.forward()
- currentrange = currentrange + 1
- until currentrange == range
- range=0
- end
- end
- function backward()
- term.clear()
- term.setCursorPos(1,1)
- internalselection=0
- drawHeader()
- printLeft("Backward", 7)
- printLeft("--------", 8)
- printLeft("1. Backward 1", 9)
- printRight("3. Main Menu", 9)
- printLeft("2. Backward range", 10)
- printLeft("Selection: ", 12)
- internalselection = tonumber(read())
- if internalselection==1 then
- turtle.back()
- term.clear()
- term.setCursorPos(1,1)
- end
- if internalselection==2 then
- term.clear()
- term.setCursorPos(1,1)
- drawHeader()
- printLeft("Backward Range", 7)
- printLeft("-------------", 8)
- printLeft("How far: ", 9)
- currentrange = 0
- range = tonumber(read())
- repeat
- term.clear()
- term.setCursorPos(1,1)
- drawHeader()
- turtle.back()
- currentrange = currentrange + 1
- until currentrange == range
- range=0
- end
- if internalselection==3 then
- term.clear()
- term.setCursorPos(1,1)
- internalselection=0
- selection=0
- main()
- end
- end
- function up()
- term.clear()
- term.setCursorPos(1,1)
- internalselection=0
- drawHeader()
- printLeft("Up", 7)
- printLeft("--", 8)
- printLeft("1. Up 1", 9)
- printRight("3. Main Menu", 9)
- printLeft("2. Up range", 10)
- printLeft("Selection: ", 12)
- internalselection = tonumber(read())
- if internalselection==1 then
- turtle.up()
- term.clear()
- term.setCursorPos(1,1)
- end
- if internalselection==2 then
- term.clear()
- term.setCursorPos(1,1)
- drawHeader()
- printLeft("Up Range", 7)
- printLeft("--------", 8)
- printLeft("How far: ", 9)
- currentrange = 0
- range = tonumber(read())
- repeat
- term.clear()
- term.setCursorPos(1,1)
- drawHeader()
- turtle.up()
- currentrange = currentrange + 1
- until currentrange == range
- range=0
- end
- if internalselection==3 then
- term.clear()
- term.setCursorPos(1,1)
- internalselection=0
- selection=0
- main()
- end
- end
- function down()
- term.clear()
- term.setCursorPos(1,1)
- internalselection=0
- drawHeader()
- printLeft("Down", 7)
- printLeft("----", 8)
- printLeft("1. Down 1", 9)
- printRight("3. Main Menu", 9)
- printLeft("2. Down range", 10)
- printLeft("Selection: ", 12)
- internalselection = tonumber(read())
- if internalselection==1 then
- turtle.down()
- term.clear()
- term.setCursorPos(1,1)
- end
- if internalselection==2 then
- term.clear()
- term.setCursorPos(1,1)
- drawHeader()
- printLeft("Down Range", 7)
- printLeft("----------", 8)
- printLeft("How far: ", 9)
- currentrange = 0
- range = tonumber(read())
- repeat
- term.clear()
- term.setCursorPos(1,1)
- drawHeader()
- turtle.down()
- currentrange = currentrange + 1
- until currentrange == range
- range=0
- end
- if internalselection==3 then
- term.clear()
- term.setCursorPos(1,1)
- internalselection=0
- selection=0
- main()
- end
- end
- function startfarm()
- term.clear()
- term.setCursorPos(1,1)
- internalselection=0
- drawHeader()
- printLeft("Starting Farm", 7)
- printLeft("---------------", 8)
- printLeft("1. Clear Area", 9)
- printRight("3. Main Menu", 9)
- printLeft("2. Build Farm", 10)
- printLeft("Selection: ", 12)
- internalselection = tonumber(read())
- if internalselection==1 then
- counter = 0
- rightnext = true
- leftnext = false
- while true do
- term.clear()
- term.setCursorPos(1,1)
- drawHeader()
- Refuel()
- turtle.select(1)
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- if turtle.detectDown() then
- turtle.digDown()
- turtle.select(1)
- turtle.placeDown()
- counter = counter + 1
- else
- turtle.select(1)
- turtle.placeDown()
- counter = counter + 1
- end
- if counter<16 then
- turtle.forward()
- end
- if rightcounter==8 then
- if counter==16 then
- turtle.turnRight()
- for i = 1, 15, 1 do
- turtle.forward()
- end
- turtle.turnRight()
- break
- end
- end
- if counter==16 then
- if rightnext==true then
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- counter = 0
- rightcounter = rightcounter+1
- rightnext = false
- leftnext = true
- elseif leftnext==true then
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- counter = 0
- rightnext = true
- leftnext = left
- end
- end
- term.clear()
- term.setCursorPos(1,1)
- end
- end
- if internalselection==2 then
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- turtle.forward()
- term.clear()
- term.setCursorPos(1,1)
- drawHeader()
- Refuel()
- --LAYING DOWN COBBLESTONE
- drawHeader()
- Refuel()
- for i = 1, 13, 1 do
- turtle.digDown()
- turtle.select(5)
- turtle.placeDown()
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.forward()
- end
- turtle.turnRight()
- for i = 1, 3, 1 do
- turtle.digDown()
- turtle.select(5)
- turtle.placeDown()
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.forward()
- end
- turtle.turnRight()
- drawHeader()
- Refuel()
- for i = 1, 10, 1 do
- turtle.digDown()
- turtle.select(5)
- turtle.placeDown()
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.forward()
- end
- turtle.turnLeft()
- for i = 1, 2, 1 do
- turtle.digDown()
- turtle.select(5)
- turtle.placeDown()
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.forward()
- end
- turtle.turnLeft()
- drawHeader()
- Refuel()
- for i = 1, 10, 1 do
- turtle.digDown()
- turtle.select(5)
- turtle.placeDown()
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.forward()
- end
- turtle.turnRight()
- for i = 1, 3, 1 do
- turtle.digDown()
- turtle.select(5)
- turtle.placeDown()
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.forward()
- end
- turtle.turnRight()
- drawHeader()
- Refuel()
- for i = 1, 10, 1 do
- turtle.digDown()
- turtle.select(5)
- turtle.placeDown()
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.forward()
- end
- turtle.turnLeft()
- for i = 1, 2, 1 do
- turtle.digDown()
- turtle.select(5)
- turtle.placeDown()
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.forward()
- end
- turtle.turnLeft()
- drawHeader()
- Refuel()
- for i = 1, 10, 1 do
- turtle.digDown()
- turtle.select(5)
- turtle.placeDown()
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.forward()
- end
- turtle.turnRight()
- for i = 1, 3, 1 do
- turtle.digDown()
- turtle.select(5)
- turtle.placeDown()
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.forward()
- end
- Refuel()
- drawHeader()
- turtle.turnRight()
- for i = 1, 13, 1 do
- turtle.digDown()
- turtle.select(5)
- turtle.placeDown()
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.forward()
- end
- turtle.turnRight()
- drawHeader()
- Refuel()
- for i = 1, 13, 1 do
- turtle.digDown()
- turtle.select(5)
- turtle.placeDown()
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.forward()
- end
- turtle.turnRight()
- --END LAYING COBBLESTONE
- --***********************************************
- --Start laying track
- turtle.up()
- drawHeader()
- Refuel()
- for i = 1, 13, 1 do
- turtle.select(9)
- turtle.placeDown()
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.forward()
- end
- turtle.turnRight()
- drawHeader()
- Refuel()
- for i = 1, 3, 1 do
- turtle.select(9)
- turtle.placeDown()
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.forward()
- end
- turtle.turnRight()
- drawHeader()
- Refuel()
- for i = 1, 10, 1 do
- turtle.select(9)
- turtle.placeDown()
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.forward()
- end
- turtle.turnLeft()
- drawHeader()
- Refuel()
- for i = 1, 2, 1 do
- turtle.select(9)
- turtle.placeDown()
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.forward()
- end
- turtle.turnLeft()
- drawHeader()
- Refuel()
- for i = 1, 10, 1 do
- turtle.select(9)
- turtle.placeDown()
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.forward()
- end
- turtle.turnRight()
- drawHeader()
- Refuel()
- for i = 1, 3, 1 do
- turtle.select(9)
- turtle.placeDown()
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.forward()
- end
- turtle.turnRight()
- drawHeader()
- Refuel()
- for i = 1, 10, 1 do
- turtle.select(9)
- turtle.placeDown()
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.forward()
- end
- turtle.turnLeft()
- drawHeader()
- Refuel()
- for i = 1, 2, 1 do
- turtle.select(9)
- turtle.placeDown()
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.forward()
- end
- turtle.turnLeft()
- drawHeader()
- Refuel()
- for i = 1, 10, 1 do
- turtle.select(9)
- turtle.placeDown()
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.forward()
- end
- turtle.turnRight()
- drawHeader()
- Refuel()
- for i = 1, 3, 1 do
- turtle.select(9)
- turtle.placeDown()
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.forward()
- end
- turtle.turnRight()
- drawHeader()
- Refuel()
- for i = 1, 13, 1 do
- turtle.select(9)
- turtle.placeDown()
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.forward()
- end
- turtle.turnRight()
- drawHeader()
- Refuel()
- for i = 1, 13, 1 do
- turtle.select(9)
- turtle.placeDown()
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.forward()
- end
- turtle.forward()
- turtle.turnRight()
- turtle.back()
- turtle.down()
- end
- if internalselection==3 then
- term.clear()
- term.setCursorPos(1,1)
- internalselection=0
- selection=0
- main()
- end
- end
- function Refuel()
- if fuel < 20 then
- turtle.select(16)
- turtle.refuel(1)
- turtle.select(1)
- end
- --Reload Dirt
- turtle.select(1)
- --if turtle.compareTo(13) then
- turtle.select(2)
- turtle.transferTo(1, 64)
- turtle.select(3)
- turtle.transferTo(2, 64)
- turtle.select(4)
- turtle.transferTo(3, 64)
- --end
- --Reload cobble
- turtle.select(5)
- --if turtle.compareTo(13) then
- turtle.select(6)
- turtle.transferTo(5, 64)
- turtle.select(7)
- turtle.transferTo(6, 64)
- turtle.select(8)
- turtle.transferTo(7, 64)
- --end
- --Reload track
- turtle.select(9)
- --if turtle.compareTo(13) then
- turtle.select(10)
- turtle.transferTo(9, 64)
- turtle.select(11)
- turtle.transferTo(10, 64)
- --end
- turtle.select(12)
- turtle.drop(64)
- turtle.select(13)
- turtle.drop(64)
- end
- function main()
- --PROGRAM START
- term.clear()
- term.setCursorPos(1,1)
- while true do
- drawHeader()
- drawMainMenu()
- Refuel()
- if selection==1 then
- forward()
- end
- if selection==2 then
- backward()
- end
- if selection==3 then
- turtle.turnLeft()
- term.clear()
- term.setCursorPos(1,1)
- end
- if selection==4 then
- turtle.turnRight()
- term.clear()
- term.setCursorPos(1,1)
- end
- if selection==5 then
- up()
- end
- if selection==6 then
- down()
- end
- if selection==7 then
- startfarm()
- end
- if selection==8 then
- term.clear()
- term.setCursorPos(1,1)
- break
- end
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment