Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- io.write("Enter Length: ")
- length = io.read()
- io.write("Enter Width: ")
- width = io.read()
- io.write("Build off in what direction? Left or Right?: ")
- direction = io.read()
- local SLOT_COUNT = 16
- local WOOD_CHEST = 16
- local FILL_SLOT_COUNT = 4
- function countItems(itemToCount)
- local itemCount = 0
- for slot = 1, SLOT_COUNT, 1 do
- item = turtle.getItemDetail(slot)
- if(item ~= nil) then
- if(item.name == itemToCount) then
- itemCount = itemCount + turtle.getItemCount(slot)
- end
- end
- end
- return itemCount
- end
- function checkWOOD()
- if (countItems("minecraft:cobblestone") < 64) then
- turtle.select(WOOD_CHEST)
- turtle.digUp()
- turtle.placeUp()
- for slot = 1, FILL_SLOT_COUNT, 1 do
- turtle.select(slot)
- turtle.suckUp()
- end
- turtle.select(WOOD_CHEST)
- turtle.digUp()
- end
- end
- function getItemIndex(itemName)
- for slot = 1, SLOT_COUNT, 1 do
- local item = turtle.getItemDetail(slot)
- if(item ~= nil) then
- if(item["name"] == itemName) then
- return slot
- end
- end
- end
- end
- function moveForward()
- turtle.forward()
- end
- function moveBackward()
- turtle.back()
- end
- function placeBlock()
- turtle.placeDown()
- end
- function turnRight()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- end
- function turnLeft()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- end
- function turnAround()
- if direction == "Right" then turnRight()
- elseif direction == "Left" then turnLeft()
- end
- end
- repeat
- for i = 1,tonumber(length) -1 do
- checkWOOD()
- turtle.select(getItemIndex("minecraft:cobblestone"))
- placeBlock()
- moveForward()
- if i == tonumber(length) - 1 then
- placeBlock()
- turnAround()
- width = width - 1
- if i == tonumber(length) - 1 and direction == "Right"
- then direction = "Left"
- elseif i == tonumber(length) - 1 and direction == "Left"
- then direction = "Right"
- end
- end
- end
- until width == 0
Add Comment
Please, Sign In to add comment