Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Go forward 7 spaces, wait until the saplings are
- grown, go to the left and start cutting a 4x4
- tree, both at that level and the one above,
- then go up two levels and do it again for 5
- more times, then come down, plant the 4 saplings,
- return teh 7 spaces to the chest, drop the wood
- off, pick up enough coal from the furnace in
- front to have a full stack in the last slot,
- go to the next cest and get another 4 saplings,
- and restart the program
- ]]--
- local robot = require("robot")
- local c = require("computer")
- local o = require("os")
- -- wait in seconds for the sapling to grow
- local wait = 60
- -- height to chop to /2
- local height = 6
- -- distance from chest to island
- local distance = 7
- -- total diameter of the tree (width or depth)
- local width = 6
- -- chop forward
- local function forward()
- robot.swing()
- robot.forward()
- robot.swingUp()
- end
- -- chop a line
- local function chopLine(turn)
- for v = 1, width do forward() end
- if turn then
- robot.turnRight() forward() robot.turnRight()
- else
- robot.turnLeft() forward() robot.turnLeft()
- end
- end
- -- chop down this and the next level of the tree
- local function chopLevel()
- local turnRight = true
- for w = 1, width do
- chopLine(turnRight)
- turnRight = not turnRight
- end
- robot.turnLeft()
- for w = 1, width do robot.forward() end
- robot.turnRight()
- end
- -- Where the main program starts running
- while true do
- -- move from chest to saplings and wait
- robot.select(2)
- robot.suckDown(4)
- for i = 1, distance do robot.forward() end
- robot.select(1)
- while not robot.compare(false) do o.sleep(wait) end
- -- move into position
- robot.back()
- robot.back()
- robot.turnLeft()
- robot.forward()
- robot.forward()
- robot.turnRight()
- -- chop the tree
- for i = 1, height do
- chopLevel()
- robot.up()
- robot.swingUp()
- robot.up()
- end
- -- plant the saplings
- robot.turnRight()
- robot.forward()
- robot.forward()
- robot.turnLeft()
- robot.forward()
- robot.forward()
- robot.forward()
- while robot.down() do end
- robot.up()
- robot.select(2)
- robot.placeDown()
- robot.forward()
- robot.placeDown()
- robot.turnRight()
- robot.forward()
- robot.turnRight()
- robot.placeDown()
- robot.forward()
- robot.placeDown()
- -- go back to chests
- for i = 0, distance do robot.forward() end
- robot.down()
- for i = 2, 16 do
- robot.select(i)
- robot.dropDown()
- end
- robot.turnRight()
- robot.forward()
- robot.turnRight()
- while c.maxEnergy()-c.energy() > 200 do
- os.sleep(60)
- end
- -- point where the program starts over again
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement