Advertisement
SirSheepe

Untitled

May 6th, 2023 (edited)
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.13 KB | None | 0 0
  1. table.includes=function(a,b)for c=1,#a do if a[c]==b then return true end end;return false end;local d={}d.__index=d;function d.new(e)local self=setmetatable({},d)self.inventory=e;self.facing=0;return self end;function d:movePX()if self.facing==0 then turtle.turnLeft()turtle.forward()self.facing=self.facing-1 elseif self.facing==1 then turtle.back()elseif self.facing==2 then turtle.turnRight()turtle.forward()self.facing=self.facing+1 elseif self.facing==3 then turtle.forward()end end;function d:moveNX()if self.facing==0 then turtle.turnRight()turtle.forward()self.facing=self.facing+1 elseif self.facing==1 then turtle.forward()elseif self.facing==2 then turtle.turnLeft()turtle.forward()self.facing=self.facing-1 elseif self.facing==3 then turtle.back()end end;function d:movePY()turtle.up()end;function d:moveNY()turtle.down()end;function d:movePZ()if self.facing==0 then turtle.forward()elseif self.facing==1 then turtle.turnLeft()turtle.forward()self.facing=self.facing-1 elseif self.facing==2 then turtle.back()elseif self.facing==3 then turtle.turnRight()turtle.forward()self.facing=self.facing+1 end end;function d:moveNZ()if self.facing==0 then turtle.back()elseif self.facing==1 then turtle.turnRight()turtle.forward()self.facing=self.facing+1 elseif self.facing==2 then turtle.forward()elseif self.facing==3 then turtle.turn()turtle.forward()self.facing=self.facing-1 end end;function d:Rotate(f)if f==self.facing then return end;local g=f-self.facing;if g==1 or g==-3 then turtle.turnRight()elseif g==2 or g==-2 then turtle.turnRight()turtle.turnRight()elseif g==3 or g==-1 then turtle.turnLeft()end;self.facing=f end;function d:DigForward(h)for c=1,h or 1 do turtle.dig()if self.facing==0 then self:movePZ()elseif self.facing==1 then self:moveNX()elseif self.facing==2 then self:moveNZ()else self:movePX()end;self.inventory:Refuel()end;if h>1 then for c=1,16 do turtle.select(c)local b=turtle.getItemDetail()if b~=nil then if table.includes({"minecraft:cobblestone","minecraft:cobbled_deepslate","minecraft:gravel","minecraft:tuff","minecraft:calcite","minecraft:dirt","minecraft:granite","minecraft:dripstone_block","minecraft:moss_block","minecraft:chest","minecraft:mossy_cobblestone","create:veridium","create:ochrum","create:limestone","create:crimsite","create:asurine"},b.name)then turtle.dropUp()end end end end end;function d:DigDown(h)for c=1,h or 1 do turtle.digDown()self:moveNY()self.inventory:Refuel()end end;local i={}i.__index=i;function i.new(j)local self=setmetatable({},i)self.targetOres=j;self.storageIndex={}self.minimumFuel=0;self.currentFuel=turtle.getFuelLevel()self.allowedStorages={"functionalstorage:acacia_1","functionalstorage:birch_1","functionalstorage:crimson_1","functionalstorage:dark_oak_1","functionalstorage:framed_1","functionalstorage:jungle_1","functionalstorage:oak_1","functionalstorage:spruce_1","functionalstorage:warped_1"}return self end;function i:Load()local k=nil;for c=1,16 do turtle.select(c)if turtle.getItemDetail()==nil then k=c;break end end;if not k then error("Turtle inventory cannot be full, ensure a slot is empty and try again")end;local l={}for c=1,#self.targetOres do local b=self.targetOres[c][2]if not table.includes(l,b)then table.insert(l,b)end end;for c=1,16 do turtle.select(c)local b=turtle.getItemDetail()if b~=nil then if not table.includes(self.allowedStorages,b.name)then turtle.dropUp()else turtle.placeUp()turtle.suckUp(1)local m=turtle.getItemDetail()turtle.dropUp(1)turtle.digUp()if m==nil then self.storageIndex[l[1]]=c;table.remove(l,1)else if not table.includes(l,m.name)and m.name~="minecraft:coal_block"then error("Redundant storage identified, please remove and try again.")end;if m.name=="minecraft:coal_block"then self.storageIndex["fuel"]=c;turtle.placeUp()turtle.suckUp(64)self.minimumFuel=turtle.getItemDetail().count;turtle.dropUp(64)turtle.digUp()else if self.storageIndex[m.name]~=nil then error("Duplicate storage provided, remove the duplicate and try again.")end;self.storageIndex[m.name]=c;for n=1,#l do if l[n]==m.name then table.remove(l,n)break end end end end end end end;if#l~=0 then error("Sufficient storage has not been provided, please add more storage drawers and try again.")end;k=nil;for c=1,16 do turtle.select(c)if turtle.getItemDetail()==nil then k=c;break end end;self.firstEmpty=k;self:Refuel()end;function i:Refuel()local g=turtle.getFuelLimit()-turtle.getFuelLevel()if turtle.getFuelLevel()<1600 then local o=math.min(math.floor(g/800),self.minimumFuel)turtle.select(self.storageIndex["fuel"])turtle.digUp()turtle.placeUp()turtle.suckUp(64)self.minimumFuel=turtle.getItemDetail().count;turtle.dropUp(64-math.min(o,64))turtle.refuel()turtle.digUp()end end;local p=i.new({})p:Load()local q=d.new(p)local r=16;local s=16;while select(2,turtle.inspectDown()).name~="minecraft:bedrock"do for c=1,r/2 do q:DigForward(s-1)q:Rotate(3)q:DigForward(1)q:Rotate(2)q:DigForward(s-1)if c~=r/2 then q:Rotate(3)q:DigForward(1)q:Rotate(0)end end;q:Rotate(0)if select(2,turtle.inspectDown()).name=="minecraft:bedrock"then break end;q:DigDown(1)for c=1,r/2 do q:DigForward(s-1)q:Rotate(1)q:DigForward(1)q:Rotate(2)q:DigForward(s-1)if c~=r/2 then q:Rotate(1)q:DigForward(1)q:Rotate(0)end end;q:DigDown(1)q:Rotate(0)end;print("Finished!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement