Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Drops Items without chests.
- -- By hitting chests Turtle don't take Items.
- local Glength = 30
- local NumG = tonumber(io.read())
- local Side = tonumber(io.read()) -- 0 == right ; 1 == left
- local i = 0
- local NotWishedItems = {}
- NotWishedItems[0] = "minecraft:dirt"
- NotWishedItems[1] = "minecraft:cobblestone"
- NotWishedItems[2] = "minecraft:stone"
- NotWishedItems[3] = "minecraft:obsidian"
- NotWishedItems[4] = "minecraft:sand"
- NotWishedItems[5] = "minecraft:gravel"
- NotWishedItems[6] = "minecraft:rail"
- NotWishedItems[7] = "minecraft:planks"
- NotWishedItems[8] = "minecraft:fence"
- NotWishedItems[9] = "bluepower:marble"
- NotWishedItems[10] = "minecraft:torch"
- NotWishedItems[11] = "minecraft:trapped_chest"
- NotWishedItems[12] = "minecraft:flowing_water"
- NotWishedItems[13] = "minecraft:flowing_lava"
- NotWishedItems[14] = "minecraft:chest"
- function turn()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function up()
- while turtle.detectUp() == true do
- turtle.digUp()
- sleep(1)
- end
- turtle.up()
- end
- function down()
- while turtle.detectDown() == true do
- turtle.digDown()
- sleep(1)
- end
- turtle.down()
- end
- function forward()
- while turtle.detect() == true do
- turtle.dig()
- sleep(1)
- end
- turtle.forward()
- end
- function back()
- turn()
- forward()
- turn()
- end
- function placeChest()
- local cnt = 1
- while cnt < 17 do
- data = turtle.getItemDetail(cnt)
- if (data) then
- if ((data.name == "minecraft:trapped_chest") or (data.name == "minecraft:chest")) then
- turtle.select(cnt)
- turtle.place()
- cnt = 16
- elseif (cnt == 16) then
- local a = 0
- while (a == 0) do
- print("Can't found any chest.")
- print("Please enter new ones.")
- print("After finishing, please write a number which is bigger then nil")
- a = tonumber(io.read())
- end
- placeChest()
- end
- elseif (cnt == 16) then
- local a = 0
- while (a == 0) do
- print("Can't found any chest.")
- print("Please enter new ones.")
- print("After finishing, please write a number which is bigger then nil")
- a = tonumber(io.read())
- end
- placeChest()
- end
- cnt = cnt + 1
- end
- end
- function placeLightUp()
- local cnt = 1
- while cnt < 17 do
- data = turtle.getItemDetail(cnt)
- if (data) then
- if (data.name == "minecraft:torch") then
- turtle.select(cnt)
- turtle.placeUp()
- cnt = 16
- elseif (cnt == 16) then
- local a = 0
- while (a == 0) do
- print("Can't found any torch.")
- print("Please enter new ones.")
- print("After finishing, please write a number which is bigger then nil")
- a = tonumber(io.read())
- end
- placeLightUp()
- end
- elseif (cnt == 16) then
- local a = 0
- while (a == 0) do
- print("Can't found any torch.")
- print("Please enter new ones.")
- print("After finishing, please write a number which is bigger then nil")
- a = tonumber(io.read())
- end
- placeLightUp()
- end
- cnt = cnt + 1
- end
- end
- function IsAWishedItem(_name)
- local cnt = 0
- local Nnwi = table.getn(NotWishedItems)
- while (cnt < Nnwi) do
- if (_name == NotWishedItems[cnt]) then
- return false
- end
- cnt = cnt + 1
- end
- return true
- end
- function lookingForRessources()
- local cnt = 0
- while (cnt < 6) do
- if (cnt == 0 and turtle.detectUp() == true) then
- local success, data = turtle.inspectUp()
- if (success == true and IsAWishedItem(data.name) == true) then
- up()
- lookingForRessources()
- down()
- end
- elseif (cnt == 1 and turtle.detectDown() == true) then
- local success, data = turtle.inspectDown()
- if (success == true and IsAWishedItem(data.name) == true) then
- down()
- lookingForRessources()
- up()
- end
- elseif (cnt > 1 and cnt < 6) then
- local success, data = turtle.inspect()
- if (success == true and IsAWishedItem(data.name) == true and turtle.detect()) then
- forward()
- lookingForRessources()
- back()
- end
- turtle.turnRight()
- end
- cnt = cnt + 1
- end
- end
- function dropAllFoundItems()
- local cnt = 1
- local CobDropNum = 0;
- while cnt < 17 do
- turtle.select(cnt)
- local data = turtle.getItemDetail()
- if (data) then
- if (data.name == "minecraft:cobblestone") then
- if (data.count < 3) then
- turtle.drop()
- elseif (CobDropNum == 1) then
- turtle.drop()
- else
- turtle.drop(data.count - 3)
- CobDropNum = 1
- end
- elseif (data.name == "minecraft:torch") then
- cnt = cnt
- elseif (data.name == "minecraft:trapped_chest") then
- cnt = cnt
- elseif (data.name == "minecraft:chest") then
- cnt = cnt
- else
- turtle.drop()
- end
- end
- cnt = cnt + 1
- if (cnt == 16 and CobDropNum == 0) then
- local a = 0
- while (a == 0) do
- print("There are not enough Cobblestones")
- print("Please make sure that there are at least")
- print("three Cobblestones.")
- print("After finishing, please write a number which is bigger then nil")
- a = tonumber(io.read())
- dropAllFoundItems()
- end
- end
- end
- end
- function nextGang()
- if (Side == 1) then
- turtle.turnRight()
- elseif (Side == 0) then
- turtle.turnLeft()
- end
- placeChest()
- dropAllFoundItems()
- turn()
- forward()
- forward()
- forward()
- if (Side == 1) then
- turtle.turnLeft()
- elseif (Side == 0) then
- turtle.turnRight()
- end
- end
- function placeCobblestone()
- local cnt = 0
- while (cnt < 16) do
- local data = turtle.getItemDetail(cnt+1)
- if (data) then
- if (data.name == "minecraft:cobblestone") then
- turtle.select(cnt+1)
- turtle.place()
- end
- end
- cnt = cnt + 1
- end
- end
- while i < NumG do
- local Gl = 0
- while Gl < Glength do
- forward()
- lookingForRessources() -- not exists now
- up()
- lookingForRessources() -- not exists now
- if (((Gl+1) % 10 == 0) or ((Gl+1) == Glength)) then
- turtle.turnRight()
- if (turtle.detect() == false) then
- placeCobblestone()
- end
- turtle.turnLeft()
- end
- down()
- if (((Gl+1) % 10 == 0) or ((Gl+1) == Glength)) then
- placeLightUp()
- end
- Gl = Gl + 1
- end
- turn()
- Gl = 0
- while (Gl < Glength) do
- turtle.forward()
- Gl = Gl + 1
- end
- nextGang()
- i = i + 1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement