Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Mine v1.7
- -- API Loading :
- shell.run("t")
- -- Vars :
- rednet.open("right")
- local mID = 63
- local args = {}
- local facing = 0
- local depth = 0
- local fuelSlot = 16
- local trash = {
- "minecraft:dirt",
- "minecraft:stone",
- "minecraft:cobblestone",
- "minecraft:sand",
- "minecraft:gravel",
- "minecraft:grass",
- "minecraft:water",
- "minecraft:flowing_water",
- "minecraft:lava",
- "minecraft:flowing_lava",
- "chisel:granite",
- "chisel:andesite",
- "chisel:diorite",
- "chisel:limestone",
- "chisel:marble"
- }
- local initialDepth = 0
- args[1] = 0
- args = {...}
- -- Functions :
- function sendInfo(text)
- rednet.send(
- mID,
- "INFO|" .. text
- )
- end
- function sendBlockInfo(name, meta)
- depth = t.get().y + initialDepth
- rednet.send(
- mID,
- "MINED|" .. depth .. "|" .. name .. "|" .. meta
- )
- end
- function printUsage()
- print("usage: mine <initialDepth>")
- end
- function isValuable(isBlock, data)
- if isBlock then
- for i=1, #trash do
- if trash[i] == data.name then
- return false
- end
- end
- else
- return false
- end
- sendBlockInfo(data.name, data.metadata)
- return true
- end
- function checkLayer()
- for i=1, 4 do
- if isValuable(turtle.inspect()) then
- turtle.dig()
- end
- t.tR()
- end
- end
- function mine()
- while turtle.getFuelLevel() < initialDepth * 2 do
- t.refuel(fuelSlot)
- end
- sendInfo("Started mining...")
- while t.getY() + initialDepth > 6 do
- isValuable(turtle.inspectDown())
- t.down(fuelSlot)
- checkLayer()
- end
- sendInfo("Coming back up...")
- while t.getY() < 0 do
- t.up(fuelSlot)
- end
- sendInfo("Done")
- end
- -- Main :
- if #args == 1 then
- if args[1] == "help" then
- printUsage()
- elseif tonumber(args[1]) >= 10 then
- initialDepth = tonumber(args[1])
- else
- print("error: initialDepth must be a number greater or equal to 10")
- end
- else
- print("error: wrong arguments")
- printUsage()
- end
- if initialDepth >= 10 then
- mine()
- end
- rednet.close("right")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement