Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local t = turtle
- print("Enter length:")
- local length = tonumber(read())
- print("Enter width:")
- local width = tonumber(read())
- local area = width * length
- local fuelLevel = t.getFuelLevel()
- print("\nCurrent fuel level: ", fuelLevel)
- print("It requires: ", area, " fuel")
- if fuelLevel < area then
- print("\nWARNING! Not enough fuel!")
- end
- print("\nIt requires ~ ", area, " seeds. To continue enter 1..")
- local answer = tonumber(read())
- if answer ~= 1 then
- return
- end
- function smartTurn(number)
- if number % 2 == 0 then
- t.turnLeft()
- else
- t.turnRight()
- end
- end
- function turnToNewIteration(numberForSmartTurn, width)
- if numberForSmartTurn == width then
- return
- end
- smartTurn(numberForSmartTurn)
- t.forward()
- smartTurn(numberForSmartTurn)
- end
- t.up()
- t.forward()
- local currentSlot = 1
- function checkSlots()
- local itemCount = t.getItemCount(currentSlot)
- if itemCount == 0 then
- if currentSlot == 16 then
- print("Please, add resources, and press 1..")
- local answer = tonumber(read())
- if answer ~= 1 then
- error("No resources")
- else
- currentSlot = 1
- checkSlots()
- end
- else
- currentSlot = currentSlot + 1
- checkSlots()
- end
- else
- t.select(currentSlot)
- end
- end
- for i = 1, width do
- for j = 1, length do
- t.digDown()
- if t.placeDown() == false then
- checkSlots()
- t.placeDown()
- end
- if j ~= length then
- t.forward()
- end
- end
- turnToNewIteration(i, width)
- end
- if width % 2 == 0 then
- t.turnRight()
- for i = 1, width - 1 do
- t.forward()
- end
- else
- t.turnRight()
- t.turnRight()
- for i = 1, length - 1 do
- t.forward()
- end
- t.turnRight()
- for i = 1, width - 1 do
- t.forward()
- end
- end
- t.turnRight()
- t.back()
- t.down()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement