Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inventory = {}
- inventoryCount = {}
- for i = 1, 16 do
- inventory[i] = " "
- inventoryCount[i] = 0
- end
- function findItem(item)
- for i = 1, 16 do
- print("Test")
- if inventory[i] == item then
- print(i)
- return i
- end
- end
- return 0
- end
- function getChestDown()
- local slot = findItem("minecraft:chest")
- turtle.select(slot)
- turtle.placeDown()
- end
- function updateInventory()
- for i = 1, 16 do
- if turtle.getItemCount(i)>0 then
- inventory[i] = turtle.getItemDetail(i).name
- inventoryCount[i] = turtle.getItemCount(i)
- end
- end
- end
- function crafting(item)
- updateInventory()
- if item == "diamond_Pickaxe" then
- if (inventoryCount[findItem("minecraft:diamond")]>2) and (inventoryCount[findItem("minecraft:stick")]>1) then
- getChestDown()
- for i = 1, 16 do
- if inventory[i] ~= "minecraft:diamond" or inventory[i] ~= "minecraft:stick" then
- turtle.dropDown()
- end
- end
- updateInventory()
- turtle.select(findItem("minecraft:diamond"))
- turtle.transferTo(15)
- turtle.select(findItem("minecraft:stick"))
- turtle.transferTo(16)
- updateInventory()
- --Crafting begins
- turtle.select(15)
- turtle.transferTo(1,1)
- turtle.transferTo(2,1)
- turtle.transferTo(3,1)
- turtle.select(16)
- turtle.transferTo(6,1)
- turtle.transferTo(10,1)
- turtle.select(15)
- turtle.dropDown()
- turtle.select(16)
- turtle.dropDown()
- turtle.craft()
- --The item should be crafted, now to grab the inventory back
- for i = 1, 16 do
- turtle.select(i)
- turtle.suckDown()
- end
- updateInventory()
- turtle.digDown()
- else
- if inventoryCount[findItem("minecraft:stick")]<2 then
- crafting("stick")
- updateInventory()
- if inventoryCount[findItem("minecraft:stick")]>1 then
- crafting("diamond_Pickaxe")
- end
- end
- if inventoryCount[findItem("minecraft:diamond")]<3 then
- print("Not enough diamonds")
- end
- end
- end
- if item == "stick" then
- if (inventoryCount[findItem("minecraft:planks")]>1) then
- getChestDown()
- for i = 1, 16 do
- if inventory[i] ~= "minecraft:planks" then
- turtle.dropDown()
- end
- end
- updateInventory()
- turtle.select(findItem("minecraft:planks"))
- turtle.transferTo(16)
- updateInventory()
- --Crafting begins
- turtle.transferTo(1,1)
- turtle.transferTo(5,1)
- turtle.select(16)
- turtle.dropDown()
- turtle.craft()
- --The item should be crafted, now to grab the inventory back
- for i = 1, 16 do
- turtle.select(i)
- turtle.suckDown()
- end
- updateInventory()
- turtle.digDown()
- else
- if inventoryCount[findItem("minecraft:planks")]<2 then
- crafting("planks")
- updateInventory()
- if inventoryCount[findItem("minecraft:planks")]>1 then
- crafting("stick")
- end
- end
- end
- end
- if item == "planks" then
- if (inventoryCount[findItem("minecraft:log")]>0) then
- getChestDown()
- for i = 1, 16 do
- if inventory[i] ~= "minecraft:log" then
- turtle.dropDown()
- end
- end
- updateInventory()
- turtle.select(findItem("minecraft:log"))
- turtle.transferTo(16)
- updateInventory()
- --Crafting begins
- turtle.select(16)
- turtle.transferTo(1,1)
- turtle.select(16)
- turtle.dropDown()
- turtle.craft()
- --The item should be crafted, now to grab the inventory back
- for i = 1, 16 do
- turtle.select(i)
- turtle.suckDown()
- end
- updateInventory()
- turtle.digDown()
- else
- print("Not enough logs")
- end
- end
- if item == "chest" then
- if (inventoryCount[findItem("minecraft:planks")]>7) then
- getChestDown()
- for i = 1, 16 do
- if inventory[i] ~= "planks" then
- turtle.dropDown()
- end
- end
- updateInventory()
- turtle.select(findItem("minecraft:planks"))
- turtle.transferTo(16)
- updateInventory()
- --Crafting begins
- turtle.select(16)
- turtle.transferTo(1,1)
- turtle.transferTo(2,1)
- turtle.transferTo(3,1)
- turtle.transferTo(5,1)
- turtle.transferTo(7,1)
- turtle.transferTo(9,1)
- turtle.transferTo(10,1)
- turtle.transferTo(11,1)
- turtle.select(16)
- turtle.dropDown()
- turtle.craft()
- --The item should be crafted, now to grab the inventory back
- for i = 1, 16 do
- turtle.select(i)
- turtle.suckDown()
- end
- updateInventory()
- turtle.digDown()
- else
- if inventoryCount[findItem("minecraft:planks")]<8 then
- crafting("planks")
- updateInventory()
- if inventoryCount[findItem("minecraft:planks")]>7 then
- crafting("chest")
- else
- print("Not enough resources")
- end
- end
- end
- end
- if item == "crafting_Table" then
- if (inventoryCount[findItem("minecraft:planks")]>3) then
- getChestDown()
- for i = 1, 16 do
- if inventory[i] ~= "minecraft:planks" then
- turtle.dropDown()
- end
- end
- updateInventory()
- turtle.select(findItem("minecraft:planks"))
- turtle.transferTo(16)
- updateInventory()
- --Crafting begins
- turtle.select(16)
- turtle.transferTo(1,1)
- turtle.transferTo(2,1)
- turtle.transferTo(5,1)
- turtle.transferTo(6,1)
- turtle.select(16)
- turtle.dropDown()
- turtle.craft()
- --The item should be crafted, now to grab the inventory back
- for i = 1, 16 do
- turtle.select(i)
- turtle.suckDown()
- end
- updateInventory()
- turtle.digDown()
- else
- if inventoryCount[findItem("minecraft:planks")]<8 then
- crafting("planks")
- updateInventory()
- if inventoryCount[findItem("minecraft:planks")]>7 then
- crafting("crafting_Table")
- else
- print("Not enough resources")
- end
- end
- end
- end
- if item == "glass_pane" then
- if (inventoryCount[findItem("minecraft:glass")]>5) then
- getChestDown()
- for i = 1, 16 do
- if inventory[i] ~= "minecraft:glass" then
- turtle.dropDown()
- end
- end
- updateInventory()
- turtle.select(findItem("minecraft:glass"))
- turtle.transferTo(16)
- updateInventory()
- --Crafting begins
- turtle.select(16)
- turtle.transferTo(1,1)
- turtle.transferTo(2,1)
- turtle.transferTo(3,1)
- turtle.transferTo(5,1)
- turtle.transferTo(6,1)
- turtle.transferTo(7,1)
- turtle.select(16)
- turtle.dropDown()
- turtle.craft()
- --The item should be crafted, now to grab the inventory back
- for i = 1, 16 do
- turtle.select(i)
- turtle.suckDown()
- end
- updateInventory()
- turtle.digDown()
- else
- print("Not enough glass")
- end
- end
- if item == "ComputerCraft:CC-Computer" then
- if (inventoryCount[findItem("minecraft:stone")]>6) and (inventoryCount[findItem("minecraft:glass_pane")]>0) and(inventoryCount[findItem("minecraft:redstone")]>0) then
- getChestDown()
- for i = 1, 16 do
- if inventory[i] ~= "minecraft:glass_pane" or inventory[i] ~= "minecraft:stone" or inventory[i] ~= "minecraft:redstone" then
- turtle.dropDown()
- end
- end
- updateInventory()
- turtle.select(findItem("minecraft:glass_pane"))
- turtle.transferTo(14)
- turtle.select(findItem("minecraft:stone"))
- turtle.transferTo(15)
- turtle.select(findItem("minecraft:redstone"))
- turtle.transferTo(16)
- updateInventory()
- --Crafting begins
- turtle.select(15)
- turtle.transferTo(1,1)
- turtle.transferTo(2,1)
- turtle.transferTo(3,1)
- turtle.transferTo(5,1)
- turtle.transferTo(7,1)
- turtle.transferTo(9,1)
- turtle.transferTo(11,1)
- turtle.dropDown()
- turtle.select(14)
- turtle.transferTo(10,1)
- turtle.dropDown()
- turtle.select(16)
- turtle.transferTo(6,1)
- turtle.dropDown()
- turtle.craft()
- --The item should be crafted, now to grab the inventory back
- for i = 1, 16 do
- turtle.select(i)
- turtle.suckDown()
- end
- updateInventory()
- turtle.digDown()
- else
- if inventoryCount[findItem("minecraft:stone")]<7 then
- print("Not enough stone")
- end
- if inventoryCount[findItem("minecraft:glass_pane")]<1 then
- crafting("glass_pane")
- updateInventory()
- if inventoryCount[findItem("minecraft:glass_pane")]>0 then
- crafting("ComputerCraft:CC-Computer")
- else
- print("Not enough resources")
- end
- end
- if inventoryCount[findItem("minecraft:redstone")]<1 then
- print("Not enough redstone")
- end
- end
- end
- if item == "ComputerCraft:CC-Turtle" then
- if (inventoryCount[findItem("minecraft:iron")]>6) and (inventoryCount[findItem("minecraft:chest")]>0) and(inventoryCount[findItem("ComputerCraft:CC-Computer")]>0) then
- getChestDown()
- for i = 1, 16 do
- if inventory[i] ~= "minecraft:chest" or inventory[i] ~= "minecraft:stone" or inventory[i] ~= "ComputerCraft:CC-Computer" then
- turtle.dropDown()
- end
- end
- updateInventory()
- turtle.select(findItem("minecraft:chest"))
- turtle.transferTo(14)
- turtle.select(findItem("minecraft:iron"))
- turtle.transferTo(15)
- turtle.select(findItem("ComputerCraft:CC-Computer"))
- turtle.transferTo(16)
- updateInventory()
- --Crafting begins
- turtle.select(15)
- turtle.transferTo(1,1)
- turtle.transferTo(2,1)
- turtle.transferTo(3,1)
- turtle.transferTo(5,1)
- turtle.transferTo(7,1)
- turtle.transferTo(9,1)
- turtle.transferTo(11,1)
- turtle.dropDown()
- turtle.select(14)
- turtle.transferTo(10,1)
- turtle.dropDown()
- turtle.select(16)
- turtle.transferTo(6,1)
- turtle.dropDown()
- turtle.craft()
- --The item should be crafted, now to grab the inventory back
- for i = 1, 16 do
- turtle.select(i)
- turtle.suckDown()
- end
- updateInventory()
- turtle.digDown()
- else
- if inventoryCount[findItem("minecraft:chest")]<1 then
- crafting("chest")
- updateInventory()
- if inventoryCount[findItem("minecraft:chest")]>0 then
- crafting("ComputerCraft:CC-Turtle")
- else
- print("Not enough resources")
- end
- end
- if inventoryCount[findItem("ComputerCraft:CC-Computer")]<1 then
- crafting("ComputerCraft:CC-Computer")
- updateInventory()
- if inventoryCount[findItem("ComputerCraft:CC-Computer")]>0 then
- crafting("ComputerCraft:CC-Turtle")
- else
- print("Not enough resources")
- end
- end
- if inventoryCount[findItem("minecraft:iron")]<7 then
- print("Not enough resironources")
- end
- end
- end
- if item == "ComputerCraft:CC-Turtle:1" then
- if (inventoryCount[findItem("minecraft:diamond_Pickaxe")]>0) and(inventoryCount[findItem("ComputerCraft:CC-Turtle")]>0) then
- getChestDown()
- for i = 1, 16 do
- if inventory[i] ~= "minecraft:diamond_Pickaxe" or inventory[i] ~= "ComputerCraft:CC-Turtle" then
- turtle.dropDown()
- end
- end
- updateInventory()
- turtle.select(findItem("minecraft:diamond_Pickaxe"))
- turtle.transferTo(15)
- turtle.select(findItem("ComputerCraft:CC-Turtle"))
- turtle.transferTo(16)
- updateInventory()
- --Crafting begins
- turtle.select(15)
- turtle.transferTo(7,1)
- turtle.dropDown()
- turtle.select(16)
- turtle.transferTo(6,1)
- turtle.dropDown()
- turtle.craft()
- --The item should be crafted, now to grab the inventory back
- for i = 1, 16 do
- turtle.select(i)
- turtle.suckDown()
- end
- updateInventory()
- turtle.digDown()
- else
- if inventoryCount[findItem("minecraft:diamond_Pickaxe")]<1 then
- crafting("diamond_Pickaxe")
- updateInventory()
- if inventoryCount[findItem("minecraft:diamond_Pickaxe")]>0 then
- crafting("ComputerCraft:CC-Turtle:1")
- else
- print("Not enough resources")
- end
- end
- if inventoryCount[findItem("ComputerCraft:CC-Turtle")]<1 then
- crafting("ComputerCraft:CC-Turtle")
- updateInventory()
- if inventoryCount[findItem("ComputerCraft:CC-Turtle")]>0 then
- crafting("ComputerCraft:CC-Turtle:1")
- else
- print("Not enough resources")
- end
- end
- end
- end
- if item == "CraftyMiningTurtle" then --Change me to proper id
- if (inventoryCount[findItem("cminecraft:rafting_Table")]>0) and(inventoryCount[findItem("ComputerCraft:CC-Turtle:1")]>0) then
- getChestDown()
- for i = 1, 16 do
- if inventory[i] ~= "minecraft:crafting_Table" or inventory[i] ~= "ComputerCraft:CC-Turtle:1" then
- turtle.dropDown()
- end
- end
- updateInventory()
- turtle.select(findItem("minecraft:crafting_Table"))
- turtle.transferTo(15)
- turtle.select(findItem("ComputerCraft:CC-Turtle:1"))
- turtle.transferTo(16)
- updateInventory()
- --Crafting begins
- turtle.select(15)
- turtle.transferTo(5,1)
- turtle.dropDown()
- turtle.select(16)
- turtle.transferTo(6,1)
- turtle.dropDown()
- turtle.craft()
- --The item should be crafted, now to grab the inventory back
- for i = 1, 16 do
- turtle.select(i)
- turtle.suckDown()
- end
- updateInventory()
- turtle.digDown()
- else
- if inventoryCount[findItem("minecraft:crafting_Table")]<1 then
- crafting("crafting_Table")
- updateInventory()
- if inventoryCount[findItem("minecraft:crafting_Table")]>0 then
- crafting("CraftyMiningTurtle")
- else
- print("Not enough resources")
- end
- end
- if inventoryCount[findItem("ComputerCraft:CC-Turtle:1")]<1 then
- crafting("ComputerCraft:CC-Turtle:1")
- updateInventory()
- if inventoryCount[findItem("ComputerCraft:CC-Turtle:1")]>0 then
- crafting("CraftyMiningTurtle")
- else
- print("Not enough resources")
- end
- end
- end
- end
- if item == "minecraft:paper" then
- if (inventoryCount[findItem("minecraft:reeds")]>2) then
- getChestDown()
- for i = 1, 16 do
- if inventory[i] ~= "minecraft:reeds" then
- turtle.dropDown()
- end
- end
- updateInventory()
- turtle.select(findItem("minecraft:reeds"))
- turtle.transferTo(16)
- updateInventory()
- --Crafting begins
- turtle.select(16)
- turtle.transferTo(1,1)
- turtle.transferTo(2,1)
- turtle.transferTo(3,1)
- turtle.dropDown()
- turtle.craft()
- --The item should be crafted, now to grab the inventory back
- for i = 1, 16 do
- turtle.select(i)
- turtle.suckDown()
- end
- updateInventory()
- turtle.digDown()
- else
- print("Not enough resources")
- end
- end
- if item == "computercraft:disk" then
- if (inventoryCount[findItem("minecraft:paper")]>0) and (inventoryCount[findItem("minecraft:restone")]>0) then
- getChestDown()
- for i = 1, 16 do
- if inventory[i] ~= "minecraft:paper" or inventory[i] ~= "minecraft:redstone" then
- turtle.dropDown()
- end
- end
- updateInventory()
- turtle.select(findItem("minecraft:redstone"))
- turtle.transferTo(15)
- turtle.select(findItem("minecraft:paper"))
- turtle.transferTo(16)
- updateInventory()
- --Crafting begins
- turtle.select(15)
- turtle.transferTo(2,1)
- turtle.dropDown()
- turtle.select(16)
- turtle.transferTo(6,1)
- turtle.dropDown()
- turtle.craft()
- --The item should be crafted, now to grab the inventory back
- for i = 1, 16 do
- turtle.select(i)
- turtle.suckDown()
- end
- updateInventory()
- turtle.digDown()
- else
- if inventoryCount[findItem("minecraft:restone")]<1 then
- print("Not enough restone")
- end
- if inventoryCount[findItem("minecraft:paper")]<1 then
- crafting("minecraft:paper")
- updateInventory()
- if inventoryCount[findItem("minecraft:paper")]>0 then
- crafting("computercraft:disk")
- else
- print("Not enough resources")
- end
- end
- end
- end
- if item == "ComputerCraft:CC-Peripheral" then
- if (inventoryCount[findItem("minecraft:stone")]>6) and(inventoryCount[findItem("minecraft:redstone")]>1) then
- getChestDown()
- for i = 1, 16 do
- if inventory[i] ~= "minecraft:stone" or inventory[i] ~= "minecraft:redstone" then
- turtle.dropDown()
- end
- end
- updateInventory()
- turtle.select(findItem("minecraft:stone"))
- turtle.transferTo(15)
- turtle.select(findItem("minecraft:redstone"))
- turtle.transferTo(16)
- updateInventory()
- --Crafting begins
- turtle.select(15)
- turtle.transferTo(1,1)
- turtle.transferTo(2,1)
- turtle.transferTo(3,1)
- turtle.transferTo(5,1)
- turtle.transferTo(7,1)
- turtle.transferTo(9,1)
- turtle.transferTo(11,1)
- turtle.dropDown()
- turtle.select(16)
- turtle.transferTo(10,1)
- turtle.transferTo(6,1)
- turtle.dropDown()
- turtle.craft()
- --The item should be crafted, now to grab the inventory back
- for i = 1, 16 do
- turtle.select(i)
- turtle.suckDown()
- end
- updateInventory()
- turtle.digDown()
- else
- if inventoryCount[findItem("minecraft:stone")]<7 then
- print("Not enough stone")
- end
- if inventoryCount[findItem("minecraft:redstone")]<2 then
- print("Not enough redstone")
- end
- end
- end
- end
- function reproduce()
- local turtleSlot = findItem("CraftyMiningTurtle") --Please change me to the real thing
- local driveSlot = findItem("ComputerCraft:CC-Peripheral")
- local diskSlot = findItem("ComputerCraft:CC-Peripheral")
- local coalSlot = findItem("coal")
- if (turtleSlot>0) and (driveSlot>0) and (diskSlot>0) and(coalSlot>0) then
- turtle.select(driveSlot)
- turtle.place()
- turtle.select(diskSlot)
- turtle.drop()
- fs.copy("startup","disk\startup")
- turtle.up()
- turtle.select(turtleSlot)
- turtle.place()
- peripheral.call("front","turnOn")
- turtle.select(coalSlot)
- for i = 1, 5 do
- turtle.drop()
- end
- sleep(2)
- turtle.down()
- turtle.suck()
- turtle.dig()
- end
- end
- if(disk.isPresent("down"))then
- fs.copy("disk\startup","startup")
- end
- while 1==1 do
- crafting("diamond_Pickaxe")
- sleep(1)
- end
- --To Do
- --Mine for fuel, turn trees into fuel
- --Mine for replication resources
- --Build structures to help facilitate the program
- --Have an information storage location
- --Item storage location
- --Refuel location for turtles to return to
- --Keep track of turtle population
- --Build city?
- --Scale of structures?
- --Strip mining or mine everything?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement