Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function rawread(x)
- while true do
- local sEvent, param = os.pullEvent("key")
- if sEvent == "key" then
- if param == x then
- break
- end
- end
- end
- end
- function keyread()
- while true do
- local sEvent, param = os.pullEvent("key")
- if sEvent == "key" then
- return(param)
- end
- break
- end
- end
- function menu(text)
- term.clear()
- term.setCursorPos(1,1)
- print(text)
- end
- function printFuel()
- local f = turtle.getFuelLevel()
- print("Current Fuel Level:" .. f)
- end
- function mine(n) -- n is u, d, f
- if n == "f" then
- turtle.dig()
- elseif n == "u" then
- turtle.digUp()
- elseif n == "d" then
- turtle.digDown()
- else
- print("Not valid mine(dir)")
- end
- end
- function forward(n)
- if n == nil then
- n = 1
- end
- if n > 0 then
- repeat
- turtle.forward()
- n = n - 1
- until n == 0
- else
- print("n too low!")
- end
- end
- function turn(dir)
- if dir == "l" then
- turtle.turnLeft()
- elseif dir == "r" then
- turtle.turnRight()
- elseif dir == "b" then
- turtle.turnLeft()
- turtle.turnLeft()
- else
- print("Not valid turn(dir)")
- end
- end
- function up(n)
- if n == nil then
- n = 1
- end
- if n > 0 then
- repeat
- turtle.up()
- n = n - 1
- until n == 0
- else
- print("n too low!")
- end
- end
- function down(n)
- if n == nil then
- n = 1
- end
- if n > 0 then
- repeat
- turtle.down()
- n = n - 1
- until n == 0
- else
- print("n too low!")
- end
- end
- function dump(n)
- if turtle.detect() == true then
- if n == nil then
- i = 1
- else
- i = n
- end
- repeat
- turtle.select(i)
- turtle.drop()
- i = i + 1
- sleep(0)
- until i == 17
- else
- print("Can't place inventory here!")
- end
- end
- function dumpUp(n)
- if turtle.detectUp() == true then
- if n == nil then
- i = 1
- else
- i = n
- end
- repeat
- turtle.select(i)
- turtle.dropUp()
- i = i + 1
- until i == 17
- else
- print("Can't place inventory here!")
- end
- end
- function endDumpUp(n)
- turtle.select(n)
- mine("u")
- turtle.select(3)
- place("u")
- if turtle.detectUp() == true then
- if n == nil then
- i = 1
- n = 1
- else
- i = n
- end
- repeat
- turtle.select(i)
- turtle.dropUp()
- i = i + 1
- until i == 17 -- inventory has 16 slots
- else
- print("Can't place inventory here!")
- rawread(keys.enter)
- end
- turtle.select(3)
- mine("u")
- end
- function chestDumpUp(n)
- turtle.select(2)
- mine("u")
- turtle.select(1)
- place("u")
- if turtle.detectUp() == true then
- if n == nil then
- i = 1
- else
- i = n
- end
- repeat
- turtle.select(i)
- turtle.dropUp()
- i = i + 1
- until i == 17 -- inventory has 16 slots
- else
- print("Can't place inventory here!")
- rawread(enter)
- end
- end
- function place(dir) -- dir is u, d, f
- if dir == "f" then
- turtle.place()
- elseif dir == "u" then
- turtle.placeUp()
- elseif dir == "d" then
- turtle.placeDown()
- else
- print("Not valid place(dir)")
- end
- end
- function chop()
- while turtle.detect() do
- mine("f")
- mine("u")
- up()
- end
- while not turtle.detectDown() do
- down()
- end
- end
Add Comment
Please, Sign In to add comment