SHOW:
|
|
- or go back to the newest paste.
| 1 | rednet.open("right")
| |
| 2 | local func | |
| 3 | local tArgs = {...}
| |
| 4 | ||
| 5 | function cleanup() | |
| 6 | for i = 1,12 do | |
| 7 | turtle.select(i) | |
| 8 | turtle.dropDown() | |
| 9 | end | |
| 10 | end | |
| 11 | ||
| 12 | function place() | |
| 13 | turtle.select(16) | |
| 14 | turtle.place() | |
| 15 | turtle.down() | |
| 16 | turtle.select(15) | |
| 17 | turtle.place() | |
| 18 | turtle.select(14) | |
| 19 | turtle.placeDown() | |
| 20 | end | |
| 21 | ||
| 22 | - | function placePower() |
| 22 | + | function placePower() |
| 23 | turtle.select(1) | |
| 24 | turtle.place() | |
| 25 | turtle.down() | |
| 26 | turtle.select(2) | |
| 27 | turtle.place() | |
| 28 | turtle.attack() | |
| 29 | end | |
| 30 | ||
| 31 | - | function removePower() |
| 31 | + | function removePower() |
| 32 | turtle.select(2) | |
| 33 | turtle.dig() | |
| 34 | turtle.up() | |
| 35 | turtle.select(1) | |
| 36 | turtle.dig() | |
| 37 | end | |
| 38 | ||
| 39 | function remove() | |
| 40 | turtle.select(14) | |
| 41 | turtle.digDown() | |
| 42 | turtle.select(15) | |
| 43 | turtle.dig() | |
| 44 | turtle.up() | |
| 45 | turtle.select(16) | |
| 46 | turtle.dig() | |
| 47 | end | |
| 48 | ||
| 49 | function fuel() | |
| 50 | turtle.select(13) | |
| 51 | turtle.placeUp() | |
| 52 | turtle.select(1) | |
| 53 | turtle.suckUp() | |
| 54 | turtle.dropUp(turtle.getItemCount(1) - 4) | |
| 55 | turtle.refuel() | |
| 56 | turtle.select(13) | |
| 57 | turtle.digUp() | |
| 58 | end | |
| 59 | ||
| 60 | function fuelBoss(powerStation) | |
| 61 | turtle.select(13) | |
| 62 | turtle.placeUp() | |
| 63 | turtle.select(1) | |
| 64 | turtle.suckUp() | |
| 65 | turtle.dropUp(4(table.getn(powerStation) + table.getn(powerStation[2]) - (powerStation[2] ~= nil and 1 or 0))) | |
| 66 | turtle.select(13) | |
| 67 | turtle.digUp() | |
| 68 | turtle.up() | |
| 69 | - | for x,y in pairs(powerStation) do |
| 69 | + | for x,y in pairs(powerStation) do |
| 70 | - | if (type(y) not "table") and (y not nil) then |
| 70 | + | if (type(y) not "table") and (y not nil) then |
| 71 | - | turtle.turnLeft() |
| 71 | + | turtle.turnLeft() |
| 72 | turtle.drop(4) | |
| 73 | turtle.turnRight() | |
| 74 | - | else |
| 74 | + | else |
| 75 | for w,z in pairs(y) | |
| 76 | - | turtle.forward() |
| 76 | + | turtle.forward() |
| 77 | - | turtle.turnRight() |
| 77 | + | turtle.turnRight() |
| 78 | - | turtle.forward(w+1) |
| 78 | + | turtle.forward(z+1) |
| 79 | - | turtle.turnRight() |
| 79 | + | |
| 80 | - | turtle.drop(4) |
| 80 | + | |
| 81 | - | turtle.turnRight() |
| 81 | + | |
| 82 | - | turtle.forward(w+1) |
| 82 | + | turtle.forward(z+1) |
| 83 | - | turtle.turnRight() |
| 83 | + | |
| 84 | - | end |
| 84 | + | end |
| 85 | end | |
| 86 | end | |
| 87 | end | |
| 88 | ||
| 89 | function checkFuel() | |
| 90 | if turtle.getFuelLevel() < 600 then | |
| 91 | fuel() | |
| 92 | end | |
| 93 | end | |
| 94 | ||
| 95 | - | function checkStationFuel(id) |
| 95 | + | function checkStationFuel(id) |
| 96 | - | if turtle.getFuelLevel() < 600 then |
| 96 | + | if turtle.getFuelLevel() < 600 then |
| 97 | - | rednet.send("true", id)
|
| 97 | + | rednet.send("true", id)
|
| 98 | - | else |
| 98 | + | else |
| 99 | - | rednet.send("false", id)
|
| 99 | + | rednet.send("false", id)
|
| 100 | - | end |
| 100 | + | |
| 101 | end | |
| 102 | ||
| 103 | function eatFuel() | |
| 104 | - | turtle.select(3) |
| 104 | + | turtle.select(3) |
| 105 | turtle.refuel() | |
| 106 | turtle.select(1) | |
| 107 | - | end |
| 107 | + | |
| 108 | ||
| 109 | function cycle() | |
| 110 | place() | |
| 111 | sleep(25) | |
| 112 | while turtle.getItemCount(1) > 0 do | |
| 113 | cleanup() | |
| 114 | sleep(2) | |
| 115 | end | |
| 116 | remove() | |
| 117 | checkFuel() | |
| 118 | turtle.forward() | |
| 119 | end | |
| 120 | ||
| 121 | function checkIn(fromID) | |
| 122 | rednet.send(fromID, tArgs[1]) | |
| 123 | end | |
| 124 | ||
| 125 | function chunkLoad() | |
| 126 | turtle.select(16) | |
| 127 | turtle.digUp() | |
| 128 | checkFuel() | |
| 129 | turtle.select(16) | |
| 130 | turtle.forward() | |
| 131 | turtle.placeUp() | |
| 132 | end | |
| 133 | ||
| 134 | while true do | |
| 135 | local id,msg,dist = rednet.receive() | |
| 136 | func = loadstring(msg) | |
| 137 | setfenv(func, getfenv()) | |
| 138 | func(id) | |
| 139 | rednet.send(id,"Done") | |
| 140 | end |