Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- This program will build a flat layer of blocks of,
- -- the specified length and width, the floors width will be
- -- expanded to the right.
- -- Original code from: http://www.hernblog.com/ian/floor.lua
- -- Modified for turtle movement and refueling by XGamer911
- -- Place fuel in slot 16
- -- Usage: floor.lua length width.
- params = {...}
- -- The input is text so we convert the text to a number.
- floorLength = tonumber(params[1])
- floorWidth = tonumber(params[2])
- currentSlot = 1
- -- This variable is used to alternate which way we are turning.
- turnRight = true
- function gotoNextSlotIfEmpty()
- if turtle.getItemCount(currentSlot) == 0 then
- currentSlot = currentSlot + 1
- turtle.select(currentSlot)
- end
- end
- function refuel()
- fuel = turtle.getFuelLevel()
- if fuel < 5 then
- turtle.select(16)
- turtle.refuel(1)
- turtle.select(currentSlot)
- end
- end
- turtle.select(currentSlot)
- -- turtle.up()
- for width = 1, floorWidth do
- for length = 1, floorLength do
- refuel()
- turtle.placeDown()
- gotoNextSlotIfEmpty()
- if length ~= floorLength then
- turtle.forward()
- end
- end
- -- When you get to the end of a row of blocks you need to turn around and setup for the next row,
- -- but every time you turn around you need to alternate the way that you turn.
- -- If this is confusing try drawing it out on a peice of paper.
- if turnRight then
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- else
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- end
- -- Change so that we turn the other way next time.
- turnRight = not turnRight
- end
Advertisement
Add Comment
Please, Sign In to add comment