SHOW:
|
|
- or go back to the newest paste.
| 1 | ||
| 2 | - | -- FtP6HvzA up |
| 2 | + | -- AMQMYd2E |
| 3 | -- slots: seeds, fuel | |
| 4 | -- maybe use glass slabs and an ender chest | |
| 5 | ||
| 6 | ||
| 7 | local plotLength = 8 | |
| 8 | local plotWidth = 8 | |
| 9 | local harvestTime = 20 | |
| 10 | local growTime = 1500 | |
| 11 | ||
| 12 | local useChest = false | |
| 13 | ||
| 14 | local function wait(secs) | |
| 15 | for sec = secs, 0, -5 do | |
| 16 | term.clear() | |
| 17 | term.setCursorPos(1,1) | |
| 18 | print(sec) | |
| 19 | if turtle.getItemCount(1) == 0 then | |
| 20 | break | |
| 21 | end | |
| 22 | sleep(5) | |
| 23 | end | |
| 24 | term.clear() | |
| 25 | end | |
| 26 | ||
| 27 | local function resetPosition() | |
| 28 | repeat until not turtle.up() | |
| 29 | repeat until not turtle.forward() | |
| 30 | while turtle.detect() do turtle.turnRight() end | |
| 31 | ||
| 32 | while not rs.getInput("left") do
| |
| 33 | if not turtle.forward() then | |
| 34 | turtle.turnRight() | |
| 35 | end | |
| 36 | sleep(0.5) | |
| 37 | end | |
| 38 | end | |
| 39 | ||
| 40 | local function dropExcess() | |
| 41 | for slot = 1, 16 do | |
| 42 | if turtle.getItemCount(slot) ~= 0 then | |
| 43 | turtle.select(slot) | |
| 44 | if slot == 1 then | |
| 45 | turtle.drop(turtle.getItemCount(slot) - 1) | |
| 46 | elseif slot ~= 2 then | |
| 47 | turtle.drop() | |
| 48 | end | |
| 49 | end | |
| 50 | sleep(0) | |
| 51 | end | |
| 52 | turtle.select(1) | |
| 53 | end | |
| 54 | ||
| 55 | local function harvest() | |
| 56 | rs.setOutput("top", true)
| |
| 57 | wait(harvestTime) | |
| 58 | rs.setOutput("top", false)
| |
| 59 | ||
| 60 | if useChest then | |
| 61 | repeat until turtle.forward() | |
| 62 | turtle.turnLeft() | |
| 63 | dropExcess() | |
| 64 | turtle.turnRight() | |
| 65 | end | |
| 66 | ||
| 67 | repeat until not turtle.forward() | |
| 68 | sleep(1) | |
| 69 | turtle.down() | |
| 70 | repeat until not turtle.suckDown() | |
| 71 | turtle.up() | |
| 72 | turtle.back() | |
| 73 | turtle.turnRight() | |
| 74 | end | |
| 75 | ||
| 76 | local function plant() | |
| 77 | ||
| 78 | turtle.select(1) | |
| 79 | local curX | |
| 80 | local curY | |
| 81 | ||
| 82 | curY = 1 | |
| 83 | while curY <= plotLength do | |
| 84 | curX = 1 | |
| 85 | while curX <= plotWidth do | |
| 86 | ||
| 87 | if turtle.getItemCount(1) > 1 then | |
| 88 | turtle.placeDown() | |
| 89 | end | |
| 90 | ||
| 91 | if curX == plotWidth then | |
| 92 | if curY < plotLength then | |
| 93 | if curY % 2 == 1 then | |
| 94 | turtle.turnRight() | |
| 95 | repeat until turtle.forward() | |
| 96 | turtle.turnRight() | |
| 97 | else | |
| 98 | turtle.turnLeft() | |
| 99 | repeat until turtle.forward() | |
| 100 | turtle.turnLeft() | |
| 101 | end | |
| 102 | end | |
| 103 | else | |
| 104 | repeat until turtle.forward() | |
| 105 | end | |
| 106 | ||
| 107 | curX = curX + 1 | |
| 108 | end | |
| 109 | curY = curY + 1 | |
| 110 | end | |
| 111 | ||
| 112 | end | |
| 113 | ||
| 114 | rs.setOutput("top", false)
| |
| 115 | while turtle.getItemCount(1) ~= 0 do | |
| 116 | ||
| 117 | turtle.select(1) | |
| 118 | while turtle.getFuelLevel() < 128 do | |
| 119 | while turtle.getItemCount(2) < 2 do | |
| 120 | print("Out of Fuel")
| |
| 121 | sleep(1) | |
| 122 | end | |
| 123 | turtle.select(2) | |
| 124 | turtle.refuel(1) | |
| 125 | turtle.select(1) | |
| 126 | end | |
| 127 | ||
| 128 | resetPosition() | |
| 129 | harvest() | |
| 130 | plant() | |
| 131 | wait(growTime) | |
| 132 | ||
| 133 | ||
| 134 | end |