Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Clear Area Program--
- home = "top"
- atX = 0
- atZ = 0
- atY = 0
- args = {...}
- --Insert Config Size Code here
- length = 2
- width = 2
- height = 1
- -- Basic movement functions to prevent sand/gravel from getting in the way
- function dig()
- while turtle.detect() do
- turtle.dig()
- sleep(.1)
- end
- end
- function digUp()
- while turtle.detect() do
- turtle.digUp()
- sleep(.1)
- end
- end
- function forward()
- while not turtle.forward() do
- turtle.dig()
- sleep(.1)
- end
- end
- function line(distance) -- Turtle mines in straight line based on length
- local x=0
- while x<distance do
- forward()
- x=x+1
- end
- end
- --End of movement functions
- function continue() -- Figures out turtle's top/bottom location and moves him to new column in loop if he is supposed to
- if home == "top" then
- turtle.turnRight()
- forward()
- turtle.turnRight()
- atX = atX +1
- elseif home == "bottom" then
- turtle.turnLeft()
- forward()
- turtle.turnLeft()
- atX = atX +1
- else
- print("Neither top nor bottom were part of gohome counted here...ERROR!")
- end
- end
- function gohome() -- On completion of layer, returns to starting position.
- print("Coming home!")
- if home == "top" then
- turtle.turnLeft()
- turtle.turnLeft()
- line(length-1)
- turtle.turnRight()
- line(width-1)
- elseif home == "bottom" then
- turtle.turnRight()
- line(width-1)
- else
- print("ERROR with HOME RETURN!")
- end
- turtle.turnRight()
- end
- function init()
- print("Clearing area...")
- forward()
- local x=1
- local y=0
- while y ~= height do
- x = 0
- while x ~= width do
- line(length-1)
- continue()
- if home == "top" then
- home = "bottom"
- elseif home == "bottom" then
- home = "top"
- end
- x=x+1
- end
- -- gohome()
- y=y+1
- if y ~= height then
- digUp()
- turtle.up()
- end
- end
- end
- init()
Advertisement
Add Comment
Please, Sign In to add comment