Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function findFuel()
- for i=1, 16 do
- turtle.select(i)
- local itemDetails = turtle.getItemDetail()
- if itemDetails ~= nil then
- if itemDetails.name == "minecraft:coal" then
- turtle.refuel()
- break
- end
- end
- end
- turtle.select(1)
- end
- counter = 0
- local function findAndPlaceTorch()
- if counter ~= 6 then
- counter = counter + 1
- return
- end
- counter = 1
- for i=1, 16 do
- turtle.select(i)
- local itemDetails = turtle.getItemDetail()
- if itemDetails ~= nil then
- if itemDetails.name == "minecraft:torch" then
- turtle.placeDown()
- break
- end
- end
- end
- turtle.select(1)
- end
- local function cleanInventory()
- local blocksToClean = {
- "minecraft:cobblestone",
- "minecraft:deepslate",
- "minecraft:cobbled_deepslate",
- "minecraft:granite",
- "minecraft:diorite",
- "minecraft:gravel",
- "minecraft:dirt",
- "indreb:raw_uranium",
- "mekanism:raw_uranium",
- "minecraft:calcite",
- "minecraft:amethyst_block",
- "minecraft:tuff",
- "minecraft:smooth_basalt"
- }
- for i=1, 16 do
- turtle.select(i)
- local itemDetails = turtle.getItemDetail()
- if itemDetails ~= nil then
- for i=1,#blocksToClean do
- if itemDetails.name == blocksToClean[i] then
- turtle.dropDown()
- break
- end
- end
- end
- end
- turtle.select(1)
- end
- -------------------------------------------------------------
- --Locales
- local useTorches = false
- local movementSync = false
- local modem = nil
- local syncHostID = -1
- local transmitChannel = 228
- local recieveChannel = 229
- --Sync channel setup
- term.clear()
- term.setCursorPos(1, 1)
- print("Is sync enabled?[y/n]")
- local input = io.stdin:read()
- if input == "y" then
- movementSync = true
- modem = peripheral.find("modem") or error("No modem found")
- if not modem.isWireless() then
- error("Modem not wireless")
- end
- modem.closeAll()
- modem.open(recieveChannel)
- end
- --Placing torches setup
- print("Do I need to place torches?[y/n]")
- input = io.stdin:read()
- if input == "y" then
- useTorches = true
- end
- local hostStart = false
- while not hostStart do
- print("Waiting for host confirmation")
- local event, side, channel, replyChannel, message = os.pullEvent("modem_message")
- if message == "start" then
- hostStart = true
- end
- end
- print("Started")
- sleep(5)
- while true do
- --Fuel logic
- while turtle.getFuelLevel() == 0 do
- print("Fuel level 0 please refil")
- findFuel()
- end
- if turtle.getFuelLevel() <= 10 then
- print("Fuel level low, please refil")
- findFuel()
- end
- --Fuel main digging and torch if specified
- turtle.dig()
- if movementSync then
- while true do
- modem.transmit(transmitChannel, transmitChannel, "completedTurn")
- print("Message sent to host")
- local event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
- if message == "continue" then
- break
- end
- end
- print("Recieved host message to continue")
- end
- local didGoForward = turtle.forward()
- while not didGoForward do
- turtle.dig()
- didGoForward = turtle.forward()
- end
- turtle.digUp()
- turtle.digDown()
- if useTorches then
- findAndPlaceTorch()
- end
- --Fuel ouput
- print("Fuel level: " .. turtle.getFuelLevel())
- --Cleaing inventory logic
- cleanInventory()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement