Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local depth, width, height = ...
- depth = tonumber(depth)
- width = tonumber(width)
- height = tonumber(height)
- height_direction_to_go = 'up'
- width_direction_to_go = 'right'
- function goHeight()
- if height > 1 then
- for h = 2, height do
- if height_direction_to_go == 'up' then
- print('up')
- turtle.digUp()
- turtle.up()
- elseif height_direction_to_go == 'down' then
- print('down')
- turtle.digDown()
- turtle.down()
- end
- end
- if height_direction_to_go == 'up' then
- height_direction_to_go = 'down'
- elseif height_direction_to_go == 'down' then
- height_direction_to_go = 'up'
- end
- end
- end
- function goWidth(moveUp)
- print('here 1')
- if width > 1 then
- print('here 2')
- for w = 2, width do
- print('here 3')
- if w == 2 and width_direction_to_go == 'right' then
- print('here 4')
- print('turn right')
- turtle.turnRight()
- elseif w == 2 and width_direction_to_go == 'left' then
- print('here 5')
- print('turn left')
- turtle.turnLeft()
- end
- print('width ' .. width_direction_to_go)
- turtle.dig()
- turtle.forward()
- if moveUp == true then
- goHeight()
- end
- end
- if width_direction_to_go == 'right' then
- print('here 6')
- print('turn left')
- width_direction_to_go = 'left'
- turtle.turnLeft()
- elseif width_direction_to_go == 'left' then
- print('here 7')
- print('turn right')
- width_direction_to_go = 'right'
- turtle.turnRight()
- end
- end
- end
- function forward()
- for d = 1, depth do
- print('forward')
- turtle.dig()
- turtle.forward()
- goHeight()
- goWidth(true)
- end
- end
- function goHome()
- if height_direction_to_go == 'down' then
- goHeight()
- end
- if width_direction_to_go == 'left' then
- goWidth(false)
- end
- turtle.turnLeft()
- turtle.turnLeft()
- for d = 1, depth do
- turtle.forward()
- end
- end
- function refuel()
- for i = 1, 16 do
- turtle.select(i)
- turtle.refuel()
- end
- end
- function drop()
- for i = 1, 16 do
- turtle.select(i)
- turtle.drop()
- end
- end
- function init()
- refuel()
- forward()
- goHome()
- drop()
- end
- init()
Add Comment
Please, Sign In to add comment