client-bomb.lua
49 lines · 997 B
Copy & run
wget https://perlytiara.github.io/turtles.tips/raw/programs/perlytiara/BigBaemingGamers/client/client-bomb.lua
| 1 | local SLOT_COUNT = 16 |
| 2 | |
| 3 | local modem = peripheral.wrap("left") |
| 4 | modem.open(100) |
| 5 | |
| 6 | function checkFuel() |
| 7 | turtle.select(1) |
| 8 | |
| 9 | if(turtle.getFuelLevel() < 50) then |
| 10 | print("Attempting Refuel...") |
| 11 | for slot = 1, SLOT_COUNT, 1 do |
| 12 | turtle.select(slot) |
| 13 | if(turtle.refuel(1)) then |
| 14 | return true |
| 15 | end |
| 16 | end |
| 17 | |
| 18 | return false |
| 19 | else |
| 20 | return true |
| 21 | end |
| 22 | end |
| 23 | |
| 24 | function getItemIndex(itemName) |
| 25 | for slot = 1, SLOT_COUNT, 1 do |
| 26 | local item = turtle.getItemDetail(slot) |
| 27 | if(item ~= nil) then |
| 28 | if(item["name"] == itemName) then |
| 29 | return slot |
| 30 | end |
| 31 | end |
| 32 | end |
| 33 | end |
| 34 | |
| 35 | |
| 36 | print("Waiting for signal") |
| 37 | event, side, senderChannel, replyChannel, msg, distance = os.pullEvent("modem_message") |
| 38 | |
| 39 | while(true) do |
| 40 | checkFuel() |
| 41 | getItemIndex("minecraft:tnt") |
| 42 | |
| 43 | for i = 1, 2, 1 do |
| 44 | turtle.forward() |
| 45 | end |
| 46 | |
| 47 | turtle.placeDown() |
| 48 | redstone.setOutput("bottom", true) |
| 49 | end |