bamboo.lua
38 lines · 779 B
Copy & run
wget https://perlytiara.github.io/turtles.tips/raw/programs/Michael-Reeves808/bamboo.lua
| 1 | local SLOT_COUNT = 16 |
| 2 | |
| 3 | function checkFuel() |
| 4 | turtle.select(1) |
| 5 | |
| 6 | if(turtle.getFuelLevel() < 50) then |
| 7 | print("Attempting Refuel...") |
| 8 | for slot = 1, SLOT_COUNT, 1 do |
| 9 | turtle.select(slot) |
| 10 | if(turtle.refuel()) then |
| 11 | return true |
| 12 | end |
| 13 | end |
| 14 | |
| 15 | return false |
| 16 | else |
| 17 | return true |
| 18 | end |
| 19 | end |
| 20 | |
| 21 | function getItemIndex(itemName) |
| 22 | for slot = 1, SLOT_COUNT, 1 do |
| 23 | local item = turtle.getItemDetail(slot) |
| 24 | if(item ~= nil) then |
| 25 | if(item["name"] == itemName) then |
| 26 | return slot |
| 27 | end |
| 28 | end |
| 29 | end |
| 30 | end |
| 31 | |
| 32 | while(1) do |
| 33 | checkFuel() |
| 34 | turtle.select(getItemIndex('minecraft:baked_potato')) |
| 35 | turtle.drop(1) |
| 36 | os.sleep(.5) |
| 37 | turtle.forward() |
| 38 | end |