Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Author: MrPipa
- --Place the turtle in the lower left corner in front of the wall
- --Usage: <Name of the program> <height> <width>
- local x,y = ...
- h = tonumber(x)
- l = tonumber(y)
- --Preparations
- --Input check:
- print("Your input was:\nHeight: " .. h .. "\nWidth: " .. l)
- if h < 1 then
- print("Usage: wall <height> <width>")
- return
- end
- if l < 1 then
- print("Usage: wall <height> <width>")
- return
- end
- print("Input ok!\nMaking necessary preparations...")
- --Minor fixes...
- slot = 0
- l = l - 1
- --Moving into place:
- turtle.forward()
- turtle.up()
- turtle.turnRight()
- while turtle.getItemCount() == 0 do
- if turtle.getSelectedSlot() == 16 then
- print("ERROR: Out of materials!")
- return
- end
- turtle.select(turtle.getSelectedSlot() + 1)
- end
- turtle.placeDown()
- print("Preparations complete!")
- --Building
- print("Building...")
- for i = 1,h do
- for i = 1,l do
- turtle.forward()
- while turtle.getItemCount() == 0 do
- if turtle.getSelectedSlot() == 16 then
- print("ERROR: Out of materials!")
- return
- end
- turtle.select(turtle.getSelectedSlot() + 1)
- end
- turtle.placeDown()
- end
- if i < h then
- print("Moving to next level...")
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.up()
- while turtle.getItemCount() == 0 do
- if turtle.getSelectedSlot() == 16 then
- print("ERROR: Out of materials!")
- return
- end
- turtle.select(turtle.getSelectedSlot() + 1)
- end
- turtle.placeDown()
- end
- end
- print("All done!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement