Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- startup = true
- function saveDirection()
- file = fs.open("direction","w")
- file.write(direction)
- file:close()
- end
- if fs.exists("distance") then
- file = fs.open("distance","r")
- distance = file.readAll()
- file:close()
- else
- term.clear()
- term.setCursorPos(1,1)
- print("How far do I go?")
- term.write(">")
- distance = read()
- term.clear()
- term.setCursorPos(1,1)
- print("Oh my god")
- sleep(1)
- file = fs.open("distance","w")
- file.write(distance)
- file:close()
- end
- if fs.exists("slot") == true then
- file = fs.open("slot","r")
- slot = file.readAll()
- file:close()
- turtle.select(tonumber(slot))
- else
- turtle.select(1)
- end
- if fs.exists("direction") == true then
- file = fs.open("direction","r")
- direction = file.readAll()
- file:close()
- else
- file = fs.open("direction","w")
- file.write(0)
- file:close()
- direction = 0
- end
- while tonumber(direction) ~= 0 do
- if tonumber(direction) > 0 then
- turtle.turnLeft()
- direction = direction - 1
- elseif tonumber(direction) < 0 then
- turtle.turnRight()
- direction = direction + 1
- end
- file = fs.open("direction","w")
- file.write(direction)
- file:close()
- end
- while tonumber(distance) > 0 do
- if startup == false then
- partner = false
- while partner == false do
- a,b = turtle.inspectDown()
- if b == "No block to inspect" then
- b = {"no","block"}
- end
- for k,v in pairs(b) do
- if v == "computercraft:CC-Turtle" then
- partner = true
- end
- sleep(.05)
- end
- end
- else
- sleep(3)
- startup = false
- end
- turtle.dig()
- sleep(.5)
- if fs.exists("placed") == false then
- turtle.forward()
- distance = distance - 1
- file = fs.open("placed","w")
- file.write("filler")
- file:close()
- end
- turtle.turnRight()
- direction = direction +1
- saveDirection()
- turtle.turnRight()
- direction = direction +1
- saveDirection()
- turtle.place()
- if turtle.getItemCount( turtle.getSelectedSlot() ) == 0 then
- turtle.select(turtle.getSelectedSlot() +1)
- slot = turtle.getSelectedSlot() +1
- file = fs.open("slot","w")
- file.write(slot)
- file:close()
- end
- fs.delete("placed")
- turtle.turnLeft()
- direction = direction -1
- saveDirection()
- turtle.turnLeft()
- direction = direction -1
- saveDirection()
- term.clear()
- term.setCursorPos(1,1)
- print(distance)
- end
- fs.delete("distance")
- fs.delete("slot")
- fs.delete("direction")
- term.clear()
- term.setCursorPos(1,1)
- print("Job done.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement