Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --TODO: better shape, put in chest, get fuel from chest
- os.run({},"settingsSetter.lua")
- local token = settings.get("discord.token")
- local ownerId = settings.get("discord.owner")
- local channel = settings.get("discord.channel")
- local exiting = false;
- local itemBlacklist = {"minecraft:cobbled_deepslate","minecraft:cobblestone","minecraft:tuff","minecraft:netherrack","minecraft:granite","minecraft:gravel","minecraft:andesite","minecraft:diorite","forbidden_arcanus:darkstone","twigs:pebble","minecraft:flint","twigs:rhyolite","create:orchrum"}
- local dropBlacklisted = true;
- if os.getComputerLabel() == nil then
- os.setComputerLabel("unnamed Mining Turtle")
- end
- function notifyOwner(message)
- message = "<@"..ownerId.."> "..os.getComputerLabel()..": "..message
- local headers={
- ["Content-Type"]="application/json",
- ["User-Agent"]="ComputerCraft Turtle",
- ["Authorization"]="Bot "..token
- }
- local response,error,errorResponse = http.post("https://discord.com/api/channels/"..channel.."/messages","{\"content\":\""..message.."\"}",headers)
- if(response == nil) then
- write(error.."\n")
- errorResponse.readAll();
- errorResponse.close();
- end
- end
- function refuel()
- turtle.select(1)
- local level = turtle.getFuelLevel()
- local ok, error = turtle.refuel()
- if turtle.getFuelLevel() < 150 then
- notifyOwner("Not enough fuel")
- exiting = true;
- end
- end
- function refuelInternally()
- turtle.select(2) -- see assumption
- --turtle.dig()
- local placed = turtle.place()
- local ateNonCombustable = false
- local isFull = false
- while not isFull and not ateNonCombustable do
- turtle.suck()
- ateNonCombustable = not turtle.refuel() -- returns false if not combustable
- turtle.drop()
- if(turtle.getFuelLimit() - turtle.getFuelLevel() < 1000) then -- fuellevl gained from one lava bucket
- isFull = true
- end
- end
- --turtle.dig()
- automataDigCollected()
- if ateNonCombustable then
- notifyOwner("Ate Non Combustable")
- exiting = true;
- end
- end
- function mineForward()
- turtle.dig()
- moveForward()
- turtle.digUp()
- turtle.digDown()
- end
- function moveForward()
- local moved = turtle.forward()
- while not moved do
- turtle.dig()
- moved = turtle.forward()
- end
- end
- function mineChunk(x,y)
- local swapback = false;
- turtle.digUp()
- turtle.digDown()
- for j=1, x-1 do
- for i=1, y-1 do
- mineForward()
- end
- if swapback then
- turtle.turnRight()
- mineForward()
- turtle.turnRight()
- else
- turtle.turnLeft()
- mineForward()
- turtle.turnLeft()
- end
- swapback = not swapback
- end
- for i=1, y-1 do
- mineForward()
- end
- turtle.turnRight()
- turtle.turnRight()
- --placeTorch()
- end
- function mineChunkTwoDeep(x,y)
- mineChunk(x,y)
- mineChunk(x,y)
- end
- function placeTorch()
- turtle.select(2)
- local success = true;
- if turtle.getItemDetail().name == "minecraft:torch" then
- success = turtle.placeDown()
- turtle.select(1)
- else
- sucess = false;
- end
- if (not success) then
- notifyOwner("Could not place torch")
- exiting = true;
- end
- end
- function mineShaftSection()
- mineForward()
- turtle.turnLeft()
- for i=1, 7 do
- mineForward()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1, 7 do
- moveForward()
- end
- for i=1, 8 do
- mineForward()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1, 8 do
- moveForward()
- end
- turtle.turnRight()
- mineForward()
- mineForward()
- end
- function mineMineshaft()
- for i=1, 5 do
- mineShaftSection()
- end
- end
- function walkUntilStorage()
- while not peripheral.isPresent("front") and not exiting do
- local result = turtle.forward()
- if result == false then
- notifyOwner("Ran out of fuel while walking to storage (or path is blocked)")
- exiting = true
- end
- end
- end
- function walkUpUntilStorage()
- while not peripheral.isPresent("top") and not exiting do
- local result = turtle.up()
- if result == false then
- notifyOwner("Ran out of fuel while walking to storage (or path is blocked)")
- exiting = true
- end
- end
- end
- function depositInventory()
- for i=2, 16 do
- turtle.select(i)
- if not exiting and turtle.getItemDetail() ~= nil then
- --if turtle.getItemDetail().name == "minecraft:cobbled_deepslate" then
- -- turtle.dropDown()
- --else
- local success = turtle.drop()
- if not success then
- notifyOwner("Storage is full")
- exiting = true
- end
- --end
- end
- end
- turtle.select(2)
- end
- function array_has_value(array, value)
- for index, arr_val in ipairs(array) do
- if arr_val == value then
- return true
- end
- end
- return false
- end
- function depositInventoryUp()
- for i=2, 16 do
- turtle.select(i)
- if not exiting and turtle.getItemDetail() ~= nil then
- --if turtle.getItemDetail().name == "minecraft:cobbled_deepslate" then
- -- turtle.dropDown()
- --else
- -- if depositInventoryUp and array_has_value(itemBlacklist, turtle.getItemDetail().name) then
- -- turtle.dropDown()
- -- else
- local success = turtle.dropUp()
- if not success then
- notifyOwner("Storage is full")
- exiting = true
- end
- end
- end
- end
- function walkUntilFrontOfMine()
- while turtle.inspect() == false and not exiting do
- local result = turtle.forward()
- if result == false then
- notifyOwner("Ran out of fuel while walking to front of mine")
- exiting = true
- end
- end
- end
- function walkDownUntilFrontOfMine()
- while turtle.inspectDown() == false and not exiting do
- local result = turtle.down()
- if result == false then
- notifyOwner("Ran out of fuel while walking to front of mine")
- exiting = true
- end
- end
- end
- function depositItems()
- local sum = 0;
- for i=1, 16 do
- turtle.select(i)
- if turtle.getItemDetail() ~= nil then
- sum=sum+1;
- end
- end
- if sum > 13 then
- turtle.turnLeft()
- turtle.turnLeft()
- walkUntilStorage()
- if not exiting then
- depositInventory()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- if not exiting then
- walkUntilFrontOfMine()
- end
- end
- end
- function depositItemsVertically()
- local sum = 0;
- for i=1, 16 do
- turtle.select(i)
- if turtle.getItemDetail() ~= nil then
- sum=sum+1;
- end
- end
- if sum > 13 then
- walkUpUntilStorage()
- if not exiting then
- depositInventoryUp()
- end
- if not exiting then
- walkDownpUntilFrontOfMine()
- end
- end
- end
- function depositItemsInternally()
- local sum = 0;
- for i=1, 16 do
- turtle.select(i)
- if turtle.getItemDetail() ~= nil then
- sum=sum+1;
- end
- end
- turtle.select(1)
- if sum > 13 then
- turtle.select(2)
- turtle.place()
- depositInventory()
- turtle.select(2)
- automataDigCollected()
- turtle.select(1)
- end
- end
- function mineSnaked(length)
- mineForward()
- mineForward()
- mineForward()
- turtle.turnLeft()
- for i=1, length do
- mineForward()
- end
- turtle.turnRight()
- mineForward()
- mineForward()
- mineForward()
- turtle.turnRight()
- for i=1, length do
- mineForward()
- end
- turtle.turnLeft()
- end
- local automata
- function automataDig()
- while automata.getOperationCooldown("dig") > 0 do
- sleep(0.1)
- end
- automata.digBlock()
- end
- function automataCollect()
- while automata.getOperationCooldown("suck") > 0 do
- sleep(0.1)
- end
- local result = automata.collectItems()
- while result ~= nil do
- while automata.getOperationCooldown("suck") > 0 do
- sleep(0.1)
- end
- result = automata.collectItems()
- end
- end
- function automataDigCollected()
- automataDig()
- automataCollect()
- end
- function automataDigForward()
- automataDigCollected()
- turtle.forward()
- end
- function automataStripMine(length)
- for i=1,length do
- automataDigForward()
- end
- end
- local count = 0;
- --walkUntilFrontOfMine()
- automata = peripheral.wrap("right")
- while not exiting do
- --mineShaftSection()
- --placeTorch()
- --mineChunk(3,3)
- automataStripMine(5)
- depositItemsInternally()
- if turtle.getFuelLevel() < 1000 then
- refuelInternally()
- end
- count = count + 1;
- if count > 1000 then
- exiting = false
- notifyOwner("Stopped due to limit reach")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment