Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fuelForCoal = 80
- storageName = "storagedrawers:basicdrawers"
- maxCoalLevel = 20
- maxFuelLevel = 300
- pickupSlot = 1
- seedSlots = { 3, 4, 5 }
- harvestSlots = { 6, 7, 8, 9, 10, 11, 12 }
- coalSlot = 16
- startingFuel = 0;
- turnLeft = turtle.turnLeft
- turnRight = turtle.turnRight
- getFuel = turtle.getFuelLevel
- digDown = turtle.digDown
- inspect = turtle.inspect
- inspectDown = turtle.inspectDown
- count = turtle.getItemCount
- move = turtle.forward
- function select(x)
- turtle.select(x)
- end
- function transfer(x)
- turtle.transferTo(x)
- end
- function getCoal()
- select(coalSlot)
- local neededCoal = turtle.getItemSpace()
- turtle.suck(neededCoal)
- end
- function refuel()
- getCoal()
- local fuelLevel = getFuel()
- if fuelLevel >= maxFuelLevel then
- print("fuel is full")
- return true
- end
- local success, data = inspect();
- if not success then
- print("inspect not successful")
- return false
- end
- if data.name ~= storageName then
- print("not a drawer")
- return false
- end
- select(coalSlot)
- while fuelLevel < maxFuelLevel do
- turtle.refuel(1)
- fuelLevel = getFuel()
- end
- startingFuel = fuelLevel
- return true
- end
- function transferSeeds()
- select(1)
- local seedSlot = seedSlots[1]
- for i, v in ipairs(seedSlots) do
- select(v)
- local seedCount = count()
- if seedCount < 64 then
- seedSlot = v
- break
- end
- end
- select(1)
- transfer(seedSlot)
- select(seedSlot)
- end
- function transferHarvest()
- select(2)
- local harvestSlot = harvestSlots[1]
- for i, v in ipairs(harvestSlots) do
- select(v)
- local harvestCount = count()
- if harvestCount < 64 then
- harvestSlot = v
- break
- end
- end
- select(2)
- transfer(harvestSlot)
- end
- function plantSeed()
- for i, v in ipairs(seedSlots) do
- select(v)
- if count() > 0 then
- turtle.placeDown()
- return
- end
- end
- end
- function harvestCrop()
- local success, data = inspectDown();
- if not success then
- return
- end
- local age = data.state.age
- if age ~= 7 then
- return
- end
- select(1)
- digDown()
- transferSeeds()
- plantSeed()
- transferHarvest()
- end
- function dropOff(slots)
- for i, v in ipairs(slots) do
- select(v)
- if count() > 0 then
- turtle.drop()
- end
- end
- end
- function harvestField()
- refuel()
- turnLeft()
- for i = 1, 4 do
- for i = 1, 8 do
- harvestCrop()
- move()
- end
- turnLeft()
- harvestCrop()
- move()
- turnLeft()
- for i = 1, 8 do
- harvestCrop()
- move()
- end
- turnRight()
- harvestCrop()
- move()
- turnRight()
- end
- for i = 1, 8 do
- harvestCrop()
- move()
- end
- harvestCrop()
- turnRight()
- for i = 1, 8 do
- move()
- end
- turnRight()
- for i = 1, 6 do
- move()
- end
- turnLeft()
- dropOff(seedSlots)
- turnRight()
- move()
- turnLeft()
- dropOff(harvestSlots)
- turnRight()
- move()
- turnLeft()
- local fuelUsed = startingFuel - turtle.getFuelLevel()
- print("fuel used: " .. fuelUsed)
- end
- harvestField()
Add Comment
Please, Sign In to add comment