Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- local tArgs = { ... }
- if #tArgs ~= 1 then
- print( "Usage: excavate3 <diameter>" )
- return
- end
- -- Mine in a quarry pattern until we hit something we can't dig
- local size = tonumber( tArgs[1] )
- if size < 1 then
- print( "Excavate diameter must be positive" )
- return
- end
- local depth = 0
- local unloaded = 0
- local collected = 0
- local xPos,zPos = 0,0
- local xDir,zDir = 0,1
- local goTo -- Filled in further down
- local refuel -- Filled in further down
- local function moveDown()
- for i=0,1 do
- if turtle.digDown() then
- turtle.down()
- end
- end
- end
- local function moveUp()
- for i=0,1 do
- if turtle.digUp() then
- turtle.up()
- end
- end
- end
- --]]
- --[[
- TO-DO:
- - return back to chest
- - up/down dig
- - quarry(x,y,z)
- - throw items
- - print out location and reset monitor
- --]]
- local xPos = 0
- local yPos = 0
- local zPos = 0
- local dir = 0
- local fuelLevel = 0
- -- Movement
- local function moveDown()
- print("Moving down")
- if turtle.down() then
- yPos = yPos+1
- else
- print("Reason: ",turtle.down())
- return false
- end
- print("Moved down. yPos: ",yPos)
- return true
- end
- local function moveUp()
- print("Moving up")
- if turtle.up() then
- yPos = yPos+1
- else
- print("Reason: ",turtle.up())
- return false
- end
- print("Moved up. yPos: ",yPos)
- return true
- end
- local function left()
- print("Turning left")
- if turtle.turnLeft() then
- dir = dir + 1
- if dir == 4 then
- dir = 0
- end
- print("Turned left. Dir: ",dir)
- else
- print("Reason: ",turtle.turnLeft())
- return false
- end
- return true
- end
- local function right()
- print("Turning right")
- if turtle.turnRight() then
- dir = dir - 1
- if dir == -1 then
- dir = 3
- end
- print("Turned right. Dir: ",dir)
- else
- print("Reason: ",turtle.turnRight())
- return false
- end
- return true
- end
- -- Fueling
- local function fuel()
- local hasFuel = false
- if turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLevel() < 1 then
- for i = 1, 16 do -- loop through the slots
- turtle.select(i) -- change to the slot
- if turtle.refuel(0) then -- if it's valid fuel
- hasFuel = true
- end
- if hasFuel == true then
- for j=1,turtle.getItemCount() do
- if turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLevel() < 1 then
- turtle.refuel(1)
- end
- end
- end
- end
- end
- end
- local function goBack()
- local oldXPos = xPos
- local oldYPos = yPos
- local oldZPos = zPos
- local oldXDir = xDir
- local oldZDir = zDir
- end
- local function test()
- shell.run("label","set","Zmiskol")
- term.clear()
- for i=0,1 do
- moveUp()
- end
- sleep(5)
- term.clear()
- for i=0,1 do
- moveDown()
- end
- sleep(5)
- term.clear()
- end
- test()
Add Comment
Please, Sign In to add comment