Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- slots 1-8 Sand
- -- slots 9-12 cobblestone
- -- slot 13 empty
- -- slot 14 cobblestone
- -- slot 15 sand
- -- 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
- --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 Control", 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 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)
- 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 main()
- --PROGRAM START
- term.clear()
- term.setCursorPos(1,1)
- while true do
- drawHeader()
- drawMainMenu()
- if fuel < 5 then
- turtle.select(16)
- turtle.refuel(1)
- turtle.select(1)
- end
- 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==8 then
- term.clear()
- term.setCursorPos(1,1)
- break
- end
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment