Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function refuel()
- if turtle.getFuelLevel() == 0 then
- turtle.select(1)
- turtle.refuel(1)
- if turtle.getFuelLevel() == 0 then
- error("Out of fuel.")
- end
- end
- end
- function selectFirstFullSlot()
- for i = 2, 16 do
- if turtle.getItemCount(i) > 0 then
- turtle.select(i)
- return
- end
- end
- end
- function placeFirstAvailableBlock()
- selectFirstFullSlot()
- refuel()
- turtle.placeDown()
- end
- -- Program that builds a platform of size w by h
- -- and then returns to the starting position.
- print("Enter width and height:")
- local w = 10
- local h = 10
- -- Read the width and height.
- w = tonumber(io.read())
- h = tonumber(io.read())
- -- Build the platform.
- for i = 1, w do
- for j = 1, h do
- placeFirstAvailableBlock()
- turtle.forward()
- end
- for j = 1, h do
- turtle.back()
- end
- if i < w then
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- end
- end
- -- Return to the starting position.
- turtle.turnLeft()
- for i = 1, w do
- turtle.forward()
- end
- turtle.turnLeft()
Advertisement
Add Comment
Please, Sign In to add comment