Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local pos={["x"]=0,["y"]=0,["z"]=0}
- local facingDirection=nil
- local updating=false
- local inventory={}
- local inventorySave=true
- rednet.open("right")
- if fs.exists("database")==false then
- shell.run("pastebin get PdhBaBdZ database")
- end
- local success=os.loadAPI("database")
- if success==false or database==nil then
- error "The database system failed to load"
- end
- if fs.exists("databases/data")==false then
- database.createDataFile("data")
- end
- if fs.exists("databases/position")==false then
- database.createDataFile("position")
- end
- function changePos(key,change)
- if pos[key]==nil then
- pos[key]=0
- end
- pos[key]=pos[key]+change
- database.setData("position",key,pos[key])
- end
- function updatePos(key)
- database.setData("position",key,pos[key])
- end
- function getFilePos()
- if database.getData("position","x")==false then
- pos.x=0
- pos.y=0
- pos.z=0
- database.setData("position","x",0)
- database.setData("position","y",0)
- database.setData("position","z",0)
- else
- pos.x=database.getData("position","x")
- pos.y=database.getData("position","y")
- pos.z=database.getData("position","z")
- end
- bluenet.broadcast(pos.x..","..pos.y..","..pos.z,"replicator,position")
- end
- function tunnel(direction,blocks)
- local digging=true
- local fuelLevel=turtle.getFuelLevel()
- if fuelLevel<blocks then
- local coalCount=getItemCount("minecraft:coal")
- if coalCount<10 then
- selectSlotWith("minecraft:coal")
- turtle.refuel(coalCount/2)
- else
- selectSlotWith("minecraft:coal")
- turtle.refuel(coalCount)
- end
- end
- updateInventory()
- if direction=="up" then
- for i=1,blocks do
- if digging==true then
- for i=1,10 do
- turtle.digUp()
- turtle.dig()
- turtle.attackUp()
- if turtle.detectUp()==false then
- break
- end
- end
- end
- moved=turtle.up()
- if moved==true then
- changePos("y",1)
- bluenet.broadcast(pos.x..","..pos.y..","..pos.z,"replicator,position")
- else
- return false
- end
- end
- elseif direction=="down" then
- for i=1,blocks do
- if digging==true then
- for i=1,10 do
- turtle.digDown()
- turtle.dig()
- turtle.attackDown()
- if turtle.detectDown()==false then
- break
- end
- end
- end
- moved=turtle.down()
- if moved==true then
- changePos("y",-1)
- bluenet.broadcast(pos.x..","..pos.y..","..pos.z,"replicator,position")
- else
- return false
- end
- end
- elseif direction=="back" then
- local facing=string.lower(getFacing())
- for i=1,blocks do
- local moved=turtle.back()
- if moved==false then return false end
- if facing=="north" then
- changePos("z",1)
- elseif facing=="east" then
- changePos("x",-1)
- elseif facing=="south" then
- changePos("z",-1)
- elseif facing=="west" then
- changePos("x",1)
- end
- bluenet.broadcast(pos.x..","..pos.y..","..pos.z,"replicator,position")
- end
- else
- local facing=string.lower(getFacing())
- for i=1,blocks do
- if digging==true then
- turtle.dig()
- turtle.digUp()
- turtle.digDown()
- turtle.attack()
- end
- local moved=turtle.forward()
- if moved==false then return false end
- if facing=="north" then
- changePos("z",-1)
- elseif facing=="east" then
- changePos("x",1)
- elseif facing=="south" then
- changePos("z",1)
- elseif facing=="west" then
- changePos("x",-1)
- end
- bluenet.broadcast(pos.x..","..pos.y..","..pos.z,"replicator,position")
- end
- end
- return true
- end
- function move(direction,blocks,digging)
- local fuelLevel=turtle.getFuelLevel()
- if fuelLevel<blocks then
- local coalCount=getItemCount("minecraft:coal")
- if coalCount<10 then
- selectSlotWith("minecraft:coal")
- turtle.refuel(coalCount/2)
- else
- selectSlotWith("minecraft:coal")
- turtle.refuel(coalCount)
- end
- end
- updateInventory()
- if direction=="up" then
- for i=1,blocks do
- if digging==true then
- for i=1,10 do
- turtle.digUp()
- turtle.attackUp()
- if turtle.detectUp()==false then
- break
- end
- end
- end
- moved=turtle.up()
- if moved==true then
- changePos("y",1)
- bluenet.broadcast(pos.x..","..pos.y..","..pos.z,"replicator,position")
- else
- return false
- end
- end
- elseif direction=="down" then
- for i=1,blocks do
- if digging==true then
- for i=1,10 do
- turtle.digDown()
- turtle.attackDown()
- if turtle.detectDown()==false then
- break
- end
- end
- end
- moved=turtle.down()
- if moved==true then
- changePos("y",-1)
- bluenet.broadcast(pos.x..","..pos.y..","..pos.z,"replicator,position")
- else
- return false
- end
- end
- elseif direction=="back" then
- local facing=string.lower(getFacing())
- for i=1,blocks do
- local moved=turtle.back()
- if moved==false then return false end
- if facing=="north" then
- changePos("z",1)
- elseif facing=="east" then
- changePos("x",-1)
- elseif facing=="south" then
- changePos("z",-1)
- elseif facing=="west" then
- changePos("x",1)
- end
- bluenet.broadcast(pos.x..","..pos.y..","..pos.z,"replicator,position")
- end
- else
- local facing=string.lower(getFacing())
- for i=1,blocks do
- if digging==true then
- turtle.dig()
- turtle.attack()
- end
- local moved=turtle.forward()
- if moved==false then return false end
- if facing=="north" then
- changePos("z",-1)
- elseif facing=="east" then
- changePos("x",1)
- elseif facing=="south" then
- changePos("z",1)
- elseif facing=="west" then
- changePos("x",-1)
- end
- bluenet.broadcast(pos.x..","..pos.y..","..pos.z,"replicator,position")
- end
- end
- return true
- end
- function updateInventory()
- inventory={}
- for i=1,16 do
- local detail=turtle.getItemDetail(i)
- inventory[i]=detail
- end
- if updating==true then
- inventoryString=""
- for i=1,16 do
- local detail=inventory[i]
- if detail==nil then
- inventoryString=inventoryString.."nil|"
- else
- inventoryString=inventoryString..detail.name..","..detail.count..","..detail.damage.."|"
- end
- end
- bluenet.broadcast(inventoryString,"replicator,inventory")
- end
- end
- bluenet={}
- bluenet.equipModem=function(id,message,protocol)
- local modem=false
- for slot=1,16 do
- local info=turtle.getItemDetail(slot)
- if info~=nil and info.name=="ComputerCraft:CC-Peripheral" and info.damage==1 then
- turtle.select(slot)
- turtle.equipRight()
- rednet.open("right")
- modem=true
- return true
- end
- end
- if modem==false then
- return false,"No modem found in inventory"
- end
- end
- bluenet.send=function()
- if updating==true then
- --modem=bluenet.equipModem()
- --if not modem then return end
- rednet.send(id,message,protocol)
- --turtle.equipRight()
- end
- end
- bluenet.broadcast=function(message,protocol)
- if updating==true then
- --modem=bluenet.equipModem()
- --if not modem then return end
- rednet.broadcast(message,protocol)
- --turtle.equipRight()
- end
- end
- bluenet.receive=function(protocol)
- if updating==true then
- --modem=bluenet.equipModem()
- --if not modem then return end
- rednet.receive(protocol)
- --turtle.equipRight()
- end
- end
- local facingTable={
- ["north"]=1,
- ["east"]=2,
- ["south"]=3,
- ["west"]=4,
- }
- local facingTable2={
- [0]="west","north","east","south","west","north"
- }
- function turn(direction)
- if direction=="right" then
- turtle.turnRight()
- local currentFacingID=facingTable[facingDirection]
- facingDirection=facingTable2[currentFacingID+1]
- elseif direction=="left" then
- turtle.turnLeft()
- local currentFacingID=facingTable[facingDirection]
- facingDirection=facingTable2[currentFacingID-1]
- end
- end
- function setFacing(facing)
- local facing=string.lower(facing)
- local currentFacing=string.lower(getFacing())
- if facing==currentFacing then
- return
- else
- local currentFacingIndex=facingTable[currentFacing]
- local facingIndex=facingTable[facing]
- local turns=facingIndex-currentFacingIndex
- if turns<0 then
- turns=turns+4
- end
- if turns==3 then
- turn("left")
- else
- for i=1,turns do
- turn("right")
- end
- end
- end
- database.setData("position","facing",facing)
- bluenet.broadcast(facing,"replicator,facing")
- end
- function getFacing()
- return facingDirection
- end
- function initFacing()
- local heading=database.getData("position","facing")
- if heading==false then
- database.setData("position","facing","north")
- end
- facingDirection=heading
- bluenet.broadcast(heading,"replicator,facing")
- end
- function outputMessage(message,range,language)
- if talking==true and type(message)=="string" then
- if range==nil then
- speaker.speak(message)
- elseif lanugage==nil then
- speaker.speak(message,range)
- else
- speaker.speak(message,range,language)
- end
- end
- end
- function getItemCount(name)
- local count=0
- for i=1,16 do
- local detail=turtle.getItemDetail(i)
- if detail~=nil and detail.name==name then
- count=count+detail.count
- end
- end
- print(count)
- return count
- end
- function dumpItems(name,count)
- if count<0 then
- count=getItemCount(name)+count
- end
- for i=1,16 do
- local detail=turtle.getItemDetail(i)
- if detail~=nil and detail.name==name then
- turtle.select(i)
- if count>64 then
- turtle.dropDown(64)
- else
- turtle.dropDown(count)
- end
- count=count-detail.count
- if count<=0 then
- break
- end
- end
- end
- end
- function getInventoryStacks()
- local items={}
- for i=1,16 do
- local detail=turtle.getItemDetail(i)
- if detail~=nil then
- if items[detail.name]==nil then
- items[detail.name]=detail.count
- else
- items[detail.name]=items[detail.name]+detail.count
- end
- end
- end
- return items
- end
- function selectSlotWith(name)
- for i=1,16 do
- local detail=turtle.getItemDetail(i)
- if detail~=nil then
- if detail.name==name then
- turtle.select(i)
- return true
- end
- end
- end
- return false
- end
- function handleInventory()
- local items=getInventoryStacks()
- for item,count in pairs(items) do
- local maxCount=database.getData("resources",item)
- if maxCount==false then
- if inventorySave==true then
- if database.getData("recipes",item)==false then
- maxCount=0
- else
- maxCount=1024
- end
- else
- maxCount=1024
- end
- else
- maxCount=tonumber(splitString(maxCount,",",2))
- end
- if item~=nil then
- if item=="minecraft:coal" then
- if count>maxCount then
- for i=1,16 do
- local detail=turtle.getItemDetail(i)
- if detail~=nil and detail.name=="minecraft:coal" then
- turtle.select(i)
- turtle.refuel(count-maxCount)
- end
- break
- end
- --dumpItems(item,(count-maxCount))
- end
- else
- if count>maxCount then
- dumpItems(item,(count-maxCount))
- end
- end
- end
- end
- end
- function condenseInventory()
- for i=1,16 do
- local detail=turtle.getItemDetail(i)
- if detail~=nil then
- local name=detail.name
- for slot=i,16 do
- local slotDetail=turtle.getItemDetail(slot)
- if slotDetail~=nil and slotDetail.name==name then
- print(slotDetail.name)
- local freeCount=turtle.getItemSpace(slot)
- if freeCount>0 then
- if turtle.getSelectedSlot()~=i then
- turtle.select(i)
- end
- turtle.transferTo(slot,freeCount)
- if turtle.getItemCount(i)==0 then
- break
- end
- end
- end
- end
- end
- end
- end
- function findResource(name)
- itemData=database.getData("resources",name)
- local startCount=getItemCount(name)
- local layers=splitString(itemData,",",1)
- local bottom=splitString(layers,"/",1)
- local top=splitString(layers,"/",2)
- if tonumber(pos.y)<tonumber(bottom) or tonumber(pos.y)>tonumber(top) then
- pathFind(pos.x,bottom,pos.z,true)
- end
- local startRow=pos.z
- local row=1
- local collumn=1
- repeat
- if row==16 then
- if math.floor(collumn/2)==math.ceil(collumn/2) then
- turn("right")
- move("forward",1,true)
- turn("right")
- else
- turn("left")
- move("forward",1,true)
- turn("left")
- end
- collumn=collumn+1
- row=0
- end
- local wentUp=false
- repeat
- local bool,inspection=turtle.inspect()
- if bool~=false and inspection~=nil and inspection.name~=name then
- move("up",1,true)
- wentUp=true
- end
- until bool==false or inspection==nil or inspection.name==name
- while turtle.detectDown()==false and wentUp==false do
- move("down",1,false)
- end
- move("forward",1,false)
- row=row+1
- local bool,inspection=turtle.inspect()
- until inspection~=nil and inspection.name==name
- end
- function cutTree()
- bluenet.broadcast("Attempting to cut down a tree.")
- local bool,block=turtle.inspect()
- if block~=nil and block.name=="minecraft:log" then
- turtle.dig()
- move("forward",1)
- repeat
- move("up",1,true)
- local bool,block=turtle.inspectUp()
- until block==nil or block["name"]~="minecraft:log"
- repeat
- move("down",1,false)
- until turtle.detectDown()
- end
- updateInventory()
- bluenet.broadcast("Finished attempting to cut down a tree.")
- end
- local movementFails=0
- function pathFind(x,y,z,digging)
- movementFails=0
- local digging=digging
- if digging==nil then
- digging=false
- end
- repeat
- if movementFails>=2 then
- digging=true
- end
- local yDistance=(pos.y-y)*-1
- local yTravel=true
- if yDistance>0 then
- yTravel=move("up",yDistance,digging)
- elseif yDistance<0 then
- yTravel=move("down",yDistance*-1,digging)
- end
- local xDistance=(pos.x-x)*-1
- local xTravel=true
- if xDistance>0 then
- setFacing("east")
- elseif xDistance<0 then
- setFacing("west")
- xDistance=xDistance*-1
- end
- xTravel=move("forward",xDistance,digging)
- local zDistance=(pos.z-z)*-1
- local zTravel=true
- if zDistance>0 then
- setFacing("south")
- elseif zDistance<0 then
- setFacing("north")
- zDistance=zDistance*-1
- end
- zTravel=move("forward",zDistance,digging)
- movementFails=movementFails+1
- until xTravel==true and zTravel==true and yTravel==true
- sleep(0.1)
- bluenet.broadcast("Finshed pathfinding to: "..x..","..y..","..z)
- end
- function pathMine(x,y,z)
- movementFails=0
- local digging=true
- repeat
- local yDistance=(pos.y-y)*-1
- local yTravel=true
- if yDistance>0 then
- yTravel=tunnel("up",yDistance,digging)
- elseif yDistance<0 then
- yTravel=tunnel("down",yDistance*-1,digging)
- end
- local xDistance=(pos.x-x)*-1
- local xTravel=true
- if xDistance>0 then
- setFacing("east")
- elseif xDistance<0 then
- setFacing("west")
- xDistance=xDistance*-1
- end
- xTravel=tunnel("forward",xDistance,digging)
- local zDistance=(pos.z-z)*-1
- local zTravel=true
- if zDistance>0 then
- setFacing("south")
- elseif zDistance<0 then
- setFacing("north")
- zDistance=zDistance*-1
- end
- zTravel=tunnel("forward",zDistance,digging)
- movementFails=movementFails+1
- until xTravel==true and zTravel==true and yTravel==true
- sleep(0.1)
- bluenet.broadcast("Finshed pathfinding to: "..x..","..y..","..z)
- end
- local craftingSlots={1,2,3,5,6,7,9,10,11,}
- local craftSlot={1,2,3,nil,4,5,6,nil,7,8,9,nil,nil,nil,nil,nil}
- local slotsForCrafting={
- [1]=true,
- [2]=true,
- [3]=true,
- [5]=true,
- [6]=true,
- [7]=true,
- [9]=true,
- [10]=true,
- [11]=true,
- }
- function getRecipe(name,count)
- local recipeData=database.getData("recipes",name)
- if recipeData==false then
- return false,"No recipe found for the item "..name.."!"
- end
- local recipeString=splitString(recipeData,"|",1)
- local recipeType=splitString(recipeData,"|",2)
- local recipeOutcome=splitString(recipeData,"|",3)
- if recipeOutcome==false then
- recipeOutcome=1
- end
- local recipe={}
- if recipeType=="crafting" then
- for i=1,9 do
- itemName=splitString(recipeString,",",i)
- if itemName=="air" or itemName=="nil" then
- recipe[i]=nil
- else
- recipe[i]=itemName
- end
- end
- local requirements={}
- for id,item in pairs(recipe) do
- if tonumber(recipeOutcome)>1 then
- if requirements[item]==nil then
- requirements[item]=count/recipeOutcome
- else
- requirements[item]=requirements[item]+count/recipeOutcome
- end
- else
- if requirements[item]==nil then
- requirements[item]=count
- else
- requirements[item]=requirements[item]+count
- end
- end
- end
- return recipe,requirements,recipeType
- elseif recipeType=="smelting" then
- itemName=splitString(recipeString,",",1)
- if itemName=="air" or itemName=="nil" then
- recipe[1]=nil
- else
- recipe[1]=itemName
- end
- local requirements={[itemName]=count,["minecraft:coal"]=math.ceil(count/8)}
- return recipe,requirements,recipeType,recipeOutcome
- end
- end
- function equipPeripheral(peripheral,damage)
- local modem=false
- for slot=1,16 do
- local info=turtle.getItemDetail(slot)
- if info~=nil and info.name==peripheral and info.damage==damage or info~=nil and info.name==peripheral and damage==nil then
- turtle.select(slot)
- turtle.equipRight()
- if peripheral=="ComputerCraft:CC-Peripheral" and damage==1 then
- rednet.open("right")
- end
- modem=true
- return true
- end
- end
- if modem==false then
- return false,"No peripheral of that type found in inventory"
- end
- end
- function craft(name,craftingCount)
- if craftingCount==nil then
- craftingCount=1
- end
- local recipe,requirements,recipeType,recipeOutcome=getRecipe(name,craftingCount)
- if recipe==false then
- print(requirements)
- return false
- end
- for id,data in pairs(requirements) do
- print(id.."*"..data)
- end
- shortOnResources=false
- for item,count in pairs(requirements) do
- print(item.."*"..count)
- local countNeeded=count
- for slot=1,16 do
- turtle.select(slot)
- local slotItem=turtle.getItemDetail(slot)
- if slotItem~=nil then
- if slotItem.name==item then
- countNeeded=countNeeded-slotItem.count
- end
- if countNeeded<=0 then
- break
- end
- end
- end
- if countNeeded>0 then
- shortOnResources=true
- break
- end
- end
- if shortOnResources==true then
- bluenet.broadcast("Not enough resources for crafting procedure.")
- print("Not enough resources for crafting procedure.")
- return false
- else
- if recipeType=="crafting" then
- turtle.digDown()
- local chest=selectSlotWith("minecraft:chest")
- if chest==true then
- turtle.placeDown()
- end
- for slot=1,16 do
- if turtle.getItemCount(slot)>0 then
- for i=1,16 do
- if turtle.getItemCount(i)==0 and slotsForCrafting[i]==nil then
- turtle.select(slot)
- local detail=turtle.getItemDetail(slot)
- if requirements[detail.name]==nil and detail.name~="minecraft:crafting_table" then
- turtle.dropDown(turtle.getItemCount(slot))
- else
- turtle.transferTo(i,turtle.getItemCount(slot))
- end
- updateInventory()
- break
- end
- end
- end
- end
- equipPeripheral("minecraft:crafting_table")
- for slot=1,9 do
- local item=recipe[slot]
- for i=1,16 do
- local itemDetail=turtle.getItemDetail(i)
- if itemDetail~=nil and itemDetail.name==item and slotsForCrafting[i]==nil then
- print(i..":::"..craftingSlots[slot])
- if turtle.getItemCount(craftingSlots[slot])>0 then
- turtle.select(craftingSlots[slot])
- turtle.dropDown(turtle.getItemCount(craftingSlots[slot]))
- end
- turtle.select(i)
- turtle.transferTo(craftingSlots[slot],craftingCount)
- break
- end
- end
- end
- for i=1,16 do
- if slotsForCrafting[i]==nil and turtle.getItemCount(i)>0 or slotsForCrafting[i]==true and recipe[craftSlot[i]]==nil and turtle.getItemCount(i)>0 then
- turtle.select(i)
- turtle.dropDown(turtle.getItemCount(i))
- end
- end
- turtle.select(1)
- turtle.craft(craftingCount)
- for i=1,16 do
- turtle.suckDown()
- end
- turtle.digDown()
- equipPeripheral("ComputerCraft:CC-Peripheral",1)
- updateInventory()
- sleep(0.1)
- bluenet.broadcast("Finished crafting a "..name)
- elseif recipeType=="smelting" then
- local furnaceSlot=nil
- local coalSlot=nil
- for i=1,16 do
- local itemDetail=turtle.getItemDetail(i)
- if itemDetail~=nil then
- if itemDetail.name=="minecraft:furnace" then
- furnaceSlot=i
- elseif itemDetail.name=="minecraft:furnace" then
- local coalSlot=i
- end
- end
- end
- if furnaceSlot==nil then
- craft("minecraft:furnace")
- end
- local furnaceSlot=nil
- local coalSlot=nil
- for i=1,16 do
- local itemDetail=turtle.getItemDetail(i)
- if itemDetail~=nil then
- if itemDetail.name=="minecraft:furnace" then
- furnaceSlot=i
- elseif itemDetail.name=="minecraft:coal" then
- coalSlot=i
- end
- end
- end
- if furnaceSlot==nil or coalSlot==nil then
- bluenet.broadcast("Failed to smelt. Coal:"..tostring(coalSlot).." furnace:"..tostring(furnaceSlot))
- print("Failed to smelt. Coal:"..tostring(coalSlot).." furnace:"..tostring(furnaceSlot))
- return false
- end
- turtle.select(furnaceSlot)
- turtle.dig()
- turtle.place()
- turtle.digUp()
- move("up",1,true)
- turtle.dig()
- move("forwards",1,true)
- for i=1,16 do
- local itemDetail=turtle.getItemDetail(i)
- if itemDetail~=nil and itemDetail.name==recipe[1] then
- turtle.select(i)
- turtle.dropDown(craftingCount)
- break
- end
- end
- move("back",1,true)
- move("down",2,true)
- move("forwards",1,true)
- for i=1,16 do
- local itemDetail=turtle.getItemDetail(i)
- if itemDetail~=nil and itemDetail.name=="minecraft:coal" then
- turtle.select(i)
- turtle.dropUp(math.ceil(craftingCount/8))
- break
- end
- end
- sleep(10*craftingCount)
- for i=1,16 do
- turtle.suckUp()
- end
- move("back",1,true)
- move("up",1,true)
- turtle.dig()
- bluenet.broadcast("Finished smelting a "..name)
- end
- end
- end
- function splitString(sourceString,splittingChar,index)
- print(tostring(sourceString)..","..splittingChar..","..index)
- results={}
- currentWord=""
- for i=1,string.len(sourceString) do
- letter=string.sub(sourceString,i,i)
- if letter==splittingChar then
- results[#results+1]=currentWord
- currentWord=""
- else
- currentWord=currentWord..letter
- end
- end
- results[#results+1]=currentWord
- return results[index]
- end
- function gather(item,count)
- itemData=database.getData("resources",item)
- local startCount=getItemCount(item)
- local layers=splitString(itemData,",",1)
- local bottom=splitString(layers,"/",1)
- local top=splitString(layers,"/",2)
- local process=splitString(itemData,",",4)
- if item=="minecraft:log" then
- repeat
- findResource(item)
- cutTree()
- until getItemCount(item)>=count+startCount
- return true
- elseif itemData==false then
- return false,"No knowledge on that item"
- elseif process=="finding" then
- repeat
- findResource(item)
- turtle.dig()
- turtle.suck(64)
- until getItemCount(item)>=count+startCount
- elseif process=="mining" then
- local layer=math.random(bottom,top)
- pathFind(pos.x,layer,pos.z,true)
- local startRow=pos.z
- local row=1
- local length=16
- repeat
- pathMine(pos.x+length*-1,pos.y,startRow+row,true)
- row=row+1
- length=length*-1
- print(getItemCount(item)..":"..count+startCount)
- handleInventory()
- until getItemCount(item)>=count+startCount
- end
- handleInventory()
- condenseInventory()
- end
- function createTurtle()
- local startPosition={pos.x,pos.y,pos.z}
- if getItemCount("minecraft:log")<16 then
- gather("minecraft:log",16)
- end
- craft("minecraft:planks",2)
- craft("minecraft:chest")
- if getItemCount("minecraft:coal")<16 then
- gather("minecraft:coal",16)
- end
- if getItemCount("minecraft:iron_ore")<7 then
- gather("minecraft:iron_ore",7)
- end
- if getItemCount("minecraft:redstone")<1 then
- gather("minecraft:redstone",1)
- end
- if getItemCount("minecraft:sand")<6 then
- --findResource("minecraft:water","minecraft:flowing_water")
- pathFind(startPosition[1],startPosition[2],startPosition[3],true)
- move("down",1,true)
- gather("minecraft:sand",6)
- end
- if getItemCount("minecraft:cobblestone")<20 then
- gather("minecraft:cobblestone",20)
- end
- if getItemCount("minecraft:iron_ingot")<7 then
- craft("minecraft:iron_ingot",7)
- end
- if getItemCount("minecraft:glass")<6 then
- craft("minecraft:glass",6)
- end
- if getItemCount("minecraft:glass_pane")<1 then
- craft("minecraft:glass_pane",1)
- end
- craft("minecraft:planks",3)
- craft("minecraft:crafting_table")
- craft("minecraft:chest")
- craft("minecraft:stone",7)
- craft("ComputerCraft:CCComputer")
- craft("ComputerCraft:CCTurtle")
- end
- function main()
- local startPosition={pos.x,pos.y,pos.z}
- createTurtle()
- pathFind(startPosition[1],startPosition[2],startPosition[3],true)
- --[[
- pathFind(98,69,200)
- cutTree()
- pathFind(105,62,192)
- craft("minecraft:planks",12)
- craft("minecraft:crafting_table")
- craft("minecraft:chest")
- craft("minecraft:iron_ingot",9)
- craft("ComputerCraft:CCComputer")
- craft("ComputerCraft:CCTurtle")
- ]]
- --gather("minecraft:iron_ore",10)
- end
- bluenet.broadcast("Booting up")
- sleep(0.1)
- updateInventory()
- sleep(0.1)
- initFacing()
- sleep(0.1)
- getFilePos()
- sleep(0.1)
- condenseInventory()
- sleep(0.1)
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement