SHOW:
|
|
- or go back to the newest paste.
| 1 | tArgs = {...}
| |
| 2 | ||
| 3 | local fuelSlot, chestSlot = 16, 15 | |
| 4 | local height = 0 | |
| 5 | ||
| 6 | function goUp(distance) | |
| 7 | if distance == nil then distance = 1 end | |
| 8 | shell.run("go", "up", distance)
| |
| 9 | end | |
| 10 | ||
| 11 | function goDown(distance) | |
| 12 | if distance == nil then distance = 1 end | |
| 13 | shell.run("go", "up", distance)
| |
| 14 | end | |
| 15 | ||
| 16 | function goForward(distance) | |
| 17 | if distance == nil then distance = 1 end | |
| 18 | shell.run("go", "forward", distance)
| |
| 19 | end | |
| 20 | ||
| 21 | function goBack(distance) | |
| 22 | if distance == nil then distance = 1 end | |
| 23 | shell.run("go", "back", distance)
| |
| 24 | end | |
| 25 | ||
| 26 | function digUp(distance) | |
| 27 | if distance == nil then distance = 1 end | |
| 28 | for i = 1, distance do | |
| 29 | while turtle.detectUp() == true do | |
| 30 | turtle.digUp() | |
| 31 | sleep(0.5) | |
| 32 | end | |
| 33 | if distance > 1 then | |
| 34 | goUp() | |
| 35 | end | |
| 36 | end | |
| 37 | end | |
| 38 | ||
| 39 | function dig(distance) | |
| 40 | if distance == nil then distance = 1 end | |
| 41 | for i = 1, distance do | |
| 42 | while turtle.detect() == true do | |
| 43 | turtle.dig() | |
| 44 | sleep(0.5) | |
| 45 | end | |
| 46 | end | |
| 47 | end | |
| 48 | ||
| 49 | function digDown(distance) | |
| 50 | if distance == nil then distance = 1 end | |
| 51 | for i = 1, distance do | |
| 52 | turtle.digDown() | |
| 53 | sleep(0.5) | |
| 54 | if distance > 1 then | |
| 55 | goDown() | |
| 56 | end | |
| 57 | end | |
| 58 | end | |
| 59 | ||
| 60 | function getFuel() | |
| 61 | return turtle.getFuelLevel() | |
| 62 | end | |
| 63 | ||
| 64 | function returnToStart() | |
| 65 | goDown(height) | |
| 66 | height = 0 | |
| 67 | goBack() | |
| 68 | end | |
| 69 | ||
| 70 | function dropLoad() | |
| 71 | shell.run("turn", "around")
| |
| 72 | for i = 1, 14 do | |
| 73 | turtle.select(i) | |
| 74 | turtle.drop() | |
| 75 | end | |
| 76 | turtle.select(1) | |
| 77 | end | |
| 78 | ||
| 79 | if tArgs[1] == "-h" then | |
| 80 | print("Usage: lumberjack <redwood>")
| |
| 81 | elseif tArgs[1] == nil then | |
| 82 | if turtle.getItemCount(chestSlot) == 0 or turtle.getItemCount(fuelSlot) == 0 then | |
| 83 | print("Please insert a chest into slot "..chestSlot.." and fuel into slot "..fuelSlot..", then run lumberjack again")
| |
| 84 | else | |
| 85 | shell.run("turn", "around")
| |
| 86 | turtle.select(chestSlot) | |
| 87 | turtle.place() | |
| 88 | turtle.select(1) | |
| 89 | shell.run("turn", "around")
| |
| 90 | dig() | |
| 91 | goForward() | |
| 92 | while turtle.detectUp() == true do | |
| 93 | digUp() | |
| 94 | goUp() | |
| 95 | height = height + 1 | |
| 96 | if getFuel() == 0 then | |
| 97 | turtle.select(fuelSlot) | |
| 98 | turtle.refuel(5) | |
| 99 | turtle.select(1) | |
| 100 | end | |
| 101 | end | |
| 102 | returnToStart() | |
| 103 | dropLoad() | |
| 104 | end | |
| 105 | elseif tArgs[1] == "redwood" then | |
| 106 | if turtle.getItemCount(chestSlot) == 0 or turtle.getItemCount(fuelSlot) == 0 then | |
| 107 | print("Please insert a chest into slot "..chestSlot.." and fuel into slot "..fuelSlot..", then run lumberjack again")
| |
| 108 | else | |
| 109 | shell.run("turn", "around")
| |
| 110 | turtle.select(chestSlot) | |
| 111 | turtle.place() | |
| 112 | turtle.select(1) | |
| 113 | shell.run("turn", "around")
| |
| 114 | dig() | |
| 115 | goForward() | |
| 116 | while turtle.detectUp() == true do | |
| 117 | shell.run("turn", "right")
| |
| 118 | dig() | |
| 119 | shell.run("turn", "left")
| |
| 120 | dig() | |
| 121 | goForward() | |
| 122 | shell.run("turn", "right")
| |
| 123 | dig() | |
| 124 | shell.run("turn", "left")
| |
| 125 | goBack() | |
| 126 | digUp() | |
| 127 | goUp() | |
| 128 | height = height + 1 | |
| 129 | if getFuel() == 0 then | |
| 130 | turtle.select(fuelSlot) | |
| 131 | turtle.refuel(5) | |
| 132 | turtle.select(1) | |
| 133 | end | |
| 134 | end | |
| 135 | if turtle.detect() == true then | |
| 136 | dig() | |
| 137 | shell.run("turn", "right")
| |
| 138 | dig() | |
| 139 | shell.run("turn", "left")
| |
| 140 | goForward() | |
| 141 | shell.run("turn", "right")
| |
| 142 | dig() | |
| 143 | shell.run("turn", "left")
| |
| 144 | goBack() | |
| 145 | end | |
| 146 | returnToStart() | |
| 147 | dropLoad() | |
| 148 | end | |
| 149 | else | |
| 150 | print("Usage: lumberjack <redwood>")
| |
| 151 | end |