Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- TREE MINING SYSTEM.
- tree = 0
- branch = 0
- leaf = 0
- count = 0
- amount = 0
- -- add any blocks name that you want to be kept (this is automaticaly all the ore's that are of any value to the player.)
- keeparray = {"minecraft:coal_block","minecraft:amethyst_block","minecraft:raw_copper_block","minecraft:raw_goldblock","minecraft:raw_iron_block","minecraft:coal","minecraft:raw_iron","minecraft:raw_copper","minecraft:raw_gold","minecraft:redstone","minecraft:emerald","minecraft:lapis_lazuli","minecraft:diamond"}
- --count is how many blocks it has mined.
- print("how long will the main tunnel be?")
- local tree = read()
- tree = (tonumber(tree))
- print("how long will the side tunnel's be?")
- local branch = read()
- branch =(tonumber(branch))
- print("ready to start? y/n?")
- local reply = read()
- runs = 0
- -- this section of code allows for item checking if the item is not in the list then it gets thrown out but the turtle
- keeparray = {"minecraft:coal_block","minecraft:amethyst_block","minecraft:raw_copper_block","minecraft:raw_goldblock","minecraft:raw_iron_block","minecraft:coal","minecraft:raw_iron","minecraft:raw_copper","minecraft:raw_gold","minecraft:redstone","minecraft:emerald","minecraft:lapis_lazuli","minecraft:diamond"}
- i = 0
- z = 1
- local function contains(keeparray, val)
- for i=1,#keeparray do
- if keeparray[i] == val then
- print("true")
- return true
- end
- end
- print("false")
- print(val)
- return false
- end
- checktimes = 0
- function empty()
- z =1
- listleng = #keeparray
- while z ~= 17 do
- c = 0
- checkthrow = 1
- local data = turtle.getItemDetail(z)
- if data then
- item_name = data.name
- end
- if contains(keeparray,item_name) then
- checkthrow = 0
- item_name = nil
- end
- if checkthrow == 1
- then
- throw = turtle.getItemCount(z)
- turtle.select(z)
- turtle.drop(throw)
- turtle.select(1)
- end
- z = z + 1
- end
- end
- function check()
- print(checktimes)
- if checktimes == 100 then
- checktimes = checktimes - 100
- empty()
- end
- checktimes = checktimes + 1
- end
- function fw()
- if turtle.forward() then
- check()
- else
- turtle.dig()
- runs = runs + 1
- print("hit wall ")
- print(runs)
- print("amount of times")
- rerun()
- end
- end
- --
- function rerun()
- fw()
- end
- --
- --moves turtle back.
- function back1()
- while amount > 0 do
- turtle.back()
- amount = amount - 1
- end
- end
- --
- -- add the check for the backwards movement of the robot or it will get stuck on in the water lava situation.
- -- makes the main tunnel as long as is needed.
- function t()
- while amount < tree do
- turtle.dig()
- fw()
- turtle.digDown()
- turtle.turnLeft()
- turtle.dig()
- fw()
- turtle.digDown()
- turtle.turnRight()
- turtle.turnRight()
- fw()
- turtle.turnLeft()
- amount = amount + 1
- end
- back1()
- end
- --
- function back4()
- while len > 0 do
- turtle.back()
- len = len - 1
- end
- end
- --
- function back3()
- while len > 0 do
- turtle.back()
- len = len - 1
- end
- branch2()
- end
- --
- function branch2()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.forward()
- while branch > len do
- len = len + 3
- turtle.dig()
- fw()
- turtle.digDown()
- turtle.dig()
- fw()
- turtle.digDown()
- turtle.dig()
- fw()
- turtle.digDown()
- turtle.turnRight()
- leaf()
- turtle.turnLeft()
- turtle.turnLeft()
- leaf()
- turtle.turnRight()
- end
- back4()
- turtle.back()
- turtle.turnRight()
- end
- --
- len = 0
- function branch1()
- while branch > len do
- len = len + 3
- turtle.dig()
- fw()
- turtle.digDown()
- turtle.dig()
- fw()
- turtle.digDown()
- turtle.dig()
- fw()
- turtle.digDown()
- turtle.turnRight()
- leaf()
- turtle.turnLeft()
- turtle.turnLeft()
- leaf()
- turtle.turnRight()
- end
- back3()
- end
- --
- le = 0
- ru = 0
- -- makes the branches and called for the leaves to be made when needed.
- function b()
- leng = tree / 12
- print(leng)
- turtle.forward()
- turtle.turnRight()
- branch1()
- while le < leng do
- le = le + 1
- ru = 0
- while ru <= 12 do
- turtle.forward()
- ru = ru + 1
- end
- turtle.turnRight()
- branch1()
- end
- while le > 0 do
- ru = 12
- while ru > 0 do
- ru = ru -1
- turtle.back()
- le = le - 1
- end
- end
- end
- --
- function back2()
- while length > 0 do
- turtle.back()
- length = length - 1
- end
- end
- --
- length = 0
- -- makes the smaller branches off the second main branch.
- function leaf()
- while length ~= 6 do
- turtle.dig()
- fw()
- length = length + 1
- end
- back2()
- end
- --
- function s()
- print("working")
- t()
- b()
- end
- --
- function exit()
- print("goodbye")
- end
- --
- --Must be at the bottom.
- if reply == "y" then
- s()
- else
- exit()
- end
- --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement