Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- sourcecode : https://pastebin.com/RvykLz7g
- item_blacklist = {"minecraft:cobblestone","chisel:granite","chisel:limestone","chisel:andesite","chisel:diorite","minecraft:dirt", "minecraft:stone", "minecraft:clay_ball", "minecraft:torch", "minecraft:gravel", "minecraft:flint",}
- function sleep(s)
- local ntime = os.clock() + s
- repeat until os.clock() > ntime
- end
- local select_slot = function(id)
- local i = 1
- local data
- while i < 17 do
- turtle.select(i)
- if turtle.getItemCount() > 0 then
- data = turtle.getItemDetail()
- if data.name == id then
- return true
- end
- end
- i = i + 1
- end
- turtle.select(1)
- return false
- end
- local special_refuel = function()
- if select_slot("minecraft:coal") == true then
- if turtle.getItemCount() >= 5 then
- turtle.refuel(5)
- print("[*] Refuel 5 coal")
- else
- print("[*] Refuel " .. turtle.getItemCount() .. " coal")
- turtle.refuel()
- end
- return true
- end
- return false
- end
- local is_in_blacklist = function(name)
- local i = 1
- while i <= table.getn(item_blacklist) do
- if name == item_blacklist[i] then
- return true
- end
- i = i + 1
- end
- return false
- end
- local check_refuel = function()
- if turtle.getFuelLevel() == 0 then
- if not special_refuel() then
- print("[*] Wating for fuel")
- while not special_refuel() do
- sleep(1)
- end
- end
- end
- end
- local verif_stuff = function()
- local i = 1
- print("[*] Stuff verification")
- check_refuel()
- while i < 17 do
- turtle.select(i)
- if turtle.getItemCount() > 0 then
- data = turtle.getItemDetail()
- if is_in_blacklist(data.name) then
- print("[*] Drop " .. turtle.getItemCount() .. " " .. data.name)
- turtle.drop()
- end
- end
- i = i + 1
- end
- end
- local mine_x = function(x, total)
- local i = 0
- while i < x do
- check_refuel()
- if (total + i) % 20 == 0 then
- verif_stuff()
- end
- while turtle.forward() == false do
- turtle.dig()
- end
- i = i + 1
- end
- return total + i
- end
- local mine_y = function(x, y, bool, total)
- local i = 0
- while i < y do
- total = mine_x(x - 1, total)
- if total % 20 == 0 then
- verif_stuff()
- end
- if bool == false and not (i == y - 1) then
- --print("turnRight")
- turtle.turnRight()
- total = mine_x(1, total)
- turtle.turnRight()
- elseif not (i == y - 1) then
- --print("turnLeft")
- turtle.turnLeft()
- total = mine_x(1, total)
- turtle.turnLeft()
- end
- bool = not bool
- i = i + 1
- end
- return bool, total
- end
- local mine_z = function(x, y, z)
- local i = 0
- local gobool = false
- local retbool = false
- local total = 0
- verif_stuff()
- while i < z do
- retbool, total = mine_y(x, y, gobool, total)
- if total % 20 == 0 then
- verif_stuff()
- end
- --print("down")
- if not (i == z - 1) then
- turtle.digDown()
- turtle.down()
- turtle.turnRight()
- turtle.turnRight()
- end
- gobool = not retbool
- i = i + 1
- end
- verif_stuff()
- end
- local arg = { ... }
- if not (table.getn(arg) == 3) then
- print("[*] Please use command like this:")
- print(" program x y z")
- print(" program 10 10 5")
- else
- mine_z(tonumber(arg[1]), tonumber(arg[2]), tonumber(arg[3]))
- end
Advertisement
Add Comment
Please, Sign In to add comment