Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dir, depth, width = ...
- if dir == nil then
- dir = 'down'
- end
- if depth == nil then
- depth = 2
- end
- if width == nil then
- width = 2
- end
- num_moves = depth*width
- width_dir = 'right'
- height_dir = 'up'
- turn_again = false
- switch_height_dir = false
- function place()
- for i = 2, num_moves do
- print('forward')
- turtle.forward()
- if turn_again == true then
- if dir == 'down' or dir == 'up' then
- if width_dir == 'right' then
- turtle.turnRight()
- width_dir = 'left'
- elseif width_dir == 'left' then
- turtle.turnLeft()
- width_dir = 'right'
- end
- end
- turn_again = false
- end
- if i % depth == 0 then
- if dir == 'down' or dir == 'up' then
- if width_dir == 'right' then
- turtle.turnRight()
- elseif width_dir == 'left' then
- turtle.turnLeft()
- end
- turn_again = true
- end
- end
- end
- end
- function init()
- if dir == 'down' then -- start at ground level
- turtle.up()
- turtle.placeDown()
- elseif dir == 'up' then -- start from ceiling height level
- -- turtle.down()
- turtle.placeUp()
- place()
- end
- init()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement