Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Floor v1.00")
- write("How many meters to go?: ")
- z = read()
- z = tonumber(z)
- if z ~= nil and z > 0 then
- write("How many blocks wide? (default=2): ")
- x = read()
- x = tonumber(x)
- if x == nil or x < 1 then
- print("Nothing given, using default.")
- x = 2
- end
- slot = 1
- slotMax = 16
- itemsStored = 0
- turtle.select(slot);
- for s = 1,16 do
- itemsStored = itemsStored + turtle.getItemCount(s)
- end
- work = x*z + x + z
- if work > itemsStored then
- stacks = math.floor(x*z / 64) + 1
- if stacks > slotMax then
- print("Please think smaller, more than 16 stacks are not possible.")
- else
- print("Not enough items in slots. Need at least " .. stacks .. " stacks")
- end
- return
- end
- if work > turtle.getFuelLevel() then
- print("Too less fuel. Please refuel.")
- return
- end
- print("Building floor " .. z .. "x" .. x)
- turtle.forward()
- turtle.up()
- goRight = true
- goForward = true
- for lx = 1, x do
- for lz = 1, z do
- while not turtle.placeDown() do
- slot = slot + 1
- turtle.select(slot)
- end
- if lz < z then
- turtle.forward()
- end
- end
- if lx < x then
- if goRight then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- turtle.forward()
- if goRight then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- goRight = not goRight
- goForward = not goForward
- end
- end
- -- come home
- if goForward then
- for l=1, z do
- turtle.back()
- end
- turtle.turnLeft()
- for l=2, x do
- turtle.forward()
- end
- turtle.turnRight()
- else
- turtle.turnRight()
- for l=2, x do
- turtle.forward()
- end
- turtle.turnRight()
- turtle.back()
- end
- turtle.down()
- end
- print("Done building floor.")
Add Comment
Please, Sign In to add comment