Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("move")
- -- Functions --
- function reset()
- move.reset()
- move.store("initialize", "false")
- end
- function dig()
- while turtle.detect() do
- turtle.dig()
- end
- while turtle.detectDown() do
- turtle.digDown()
- end
- while turtle.detectUp() do
- turtle.digUp()
- sleep(0.6)
- end
- end
- function getType(number)
- if bit.band(number,1) == 0 then
- return "even"
- end
- return "odd"
- end
- function sweepLeft()
- while tonumber(location["y"])%3 == 0 and tonumber(location["x"]) < tonumber(quarry["width"])-1 do
- move.face(3)
- dig()
- move.forward()
- location = move.pull("location")
- end
- dig()
- end
- function sweepUp()
- while tonumber(location["y"]) < tonumber(quarry["height"]) do
- if tonumber(location["x"]) > 0 then
- move.face(1)
- else
- move.face(3)
- end
- dig()
- move.up()
- location = move.pull("location")
- if tonumber(location["y"])%3 == 0 then
- dig()
- move.forward()
- location = move.pull("location")
- break
- end
- end
- end
- function sweepDown()
- while tonumber(location["y"]) > 0 do
- if tonumber(location["x"]) > 0 then
- move.face(1)
- else
- move.face(3)
- end
- dig()
- move.down()
- location = move.pull("location")
- if tonumber(location["y"])%3 == 0 then
- dig()
- move.forward()
- location = move.pull("location")
- break
- end
- end
- end
- function sweepRight()
- while tonumber(location["x"]) > 0 do
- move.face(1)
- dig()
- move.forward()
- location = move.pull("location")
- end
- dig()
- end
- function sweepForward()
- if tonumber(location["y"]) == tonumber(quarry["height"]) then
- move.face(0)
- dig()
- move.forward()
- location = move.pull("location")
- end
- end
- -- Program --
- if not fs.exists("data/initialize") then
- handle = fs.open("data/initialize", "w")
- handle.write("false")
- handle.close()
- end
- handle = fs.open("data/initialize", "r")
- local initialize = handle.readAll()
- if initialize == "true" then
- print("quarry already started")
- else
- print("Quarry initializing now...")
- reset()
- term.clear()
- term.setCursorPos(1,1)
- term.write("Welcome to tompy Mine")
- local quarry = {}
- term.setCursorPos(1,3)
- term.write("Quarry Width: ")
- quarry["width"] = read()
- term.setCursorPos(1,4)
- term.write("Quarry Height: ")
- quarry["height"] = read()
- term.setCursorPos(1,5)
- term.write("Quarry Depth: ")
- quarry["depth"] = read()
- move.store("quarry", quarry)
- move.store("initialize", true)
- local mineLocation = {x = 0, y = 0, z = 1}
- move.store("mineLocation", mineLocation)
- end
- location = move.pull("location")
- quarry = move.pull("quarry")
- mineLocation = move.pull("mineLocation")
- move.display()
- while tonumber(location["z"]) < tonumber(quarry["depth"]) + 1 do
- sweepLeft()
- sweepUp()
- sweepRight()
- sweepUp()
- sweepForward()
- end
Advertisement
Add Comment
Please, Sign In to add comment