SHOW:
|
|
- or go back to the newest paste.
| 1 | - | local count = 0 |
| 1 | + | --[[ |
| 2 | - | while turtle.getFuelLevel() < turtle.getFuelLimit() do |
| 2 | + | pastebin get Cnzxu4S5 lava_refuel.lua |
| 3 | - | turtle.forward() |
| 3 | + | --]] |
| 4 | - | turtle.placeDown() |
| 4 | + | |
| 5 | - | turtle.refuel() |
| 5 | + | if not turtle then |
| 6 | - | count = count + 1 |
| 6 | + | printError("Requires a Turtle")
|
| 7 | return | |
| 8 | - | turtle.forward() |
| 8 | + | |
| 9 | - | turtle.placeDown() |
| 9 | + | |
| 10 | - | for i = 1, count + 1 do |
| 10 | + | local tArgs = { ... }
|
| 11 | - | turtle.back() |
| 11 | + | |
| 12 | local doFull = true | |
| 13 | - | turtle.refuel() |
| 13 | + | if (#tArgs == 1) then |
| 14 | - | print("Fuel is now at", turtle.getFuelLevel().."!") |
| 14 | + | local programName = arg[0] or fs.getName(shell.getRunningProgram()) |
| 15 | print("Usage: " .. programName .. " <length>")
| |
| 16 | doFull = false | |
| 17 | end | |
| 18 | ||
| 19 | -- Inventory Functions | |
| 20 | function checkIfSlotIsItem(slot, name) | |
| 21 | local item = turtle.getItemDetail(slot) | |
| 22 | if item ~= nil then | |
| 23 | return item["name"] == name | |
| 24 | end | |
| 25 | return false | |
| 26 | end | |
| 27 | ||
| 28 | function findItem(name) | |
| 29 | for slot = 1, 16 do | |
| 30 | if checkIfSlotIsItem(slot, name) then | |
| 31 | return slot | |
| 32 | end | |
| 33 | end | |
| 34 | return -1 | |
| 35 | end | |
| 36 | ||
| 37 | function checkIfHaveItem(name) | |
| 38 | return findItem(name) ~= -1 | |
| 39 | end | |
| 40 | ||
| 41 | if not checkIfHaveItem("minecraft:bucket") then
| |
| 42 | print("Needs a bucket")
| |
| 43 | return | |
| 44 | end | |
| 45 | ||
| 46 | local start_fuel = turtle.getFuelLevel() | |
| 47 | local toCollect = math.floor((turtle.getFuelLimit() - start_fuel) / 1000) | |
| 48 | ||
| 49 | if not doFull then | |
| 50 | toCollect = tArgs[1] | |
| 51 | end | |
| 52 | ||
| 53 | for i = 1, toCollect / 2 do | |
| 54 | turtle.placeDown() | |
| 55 | turtle.refuel() | |
| 56 | turtle.dig() | |
| 57 | turtle.forward() | |
| 58 | end | |
| 59 | turtle.digDown() | |
| 60 | turtle.down() | |
| 61 | turtle.turnLeft() | |
| 62 | turtle.turnLeft() | |
| 63 | for i = 1, toCollect / 2 do | |
| 64 | turtle.placeDown() | |
| 65 | turtle.refuel() | |
| 66 | turtle.dig() | |
| 67 | turtle.forward() | |
| 68 | end | |
| 69 | turtle.up() | |
| 70 | turtle.turnLeft() | |
| 71 | turtle.turnLeft() | |
| 72 | ||
| 73 | print("Fuel level is: "..turtle.getFuelLevel())
| |
| 74 |