Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --goes through the turtles inventory and drops anything not included in the list.
- local function purgeInventory( list )
- local goodItem = false
- for i = 1, 16 do
- goodItem = false
- local itemTbl = turtle.getItemDetail(i)
- for j = 1, #list do
- if itemTbl then
- if itemTbl.name then
- if itemTbl.name == list[j] then
- goodItem = true
- break
- end
- end
- end
- end
- if goodItem == false then
- turtle.select(i)
- turtle.drop()
- end
- end
- turtle.select(1)
- end
- --attempts to move forward. If fails, mines the block/s in front of and above the turtle until it can
- local function mineForward(blocks)
- blocks = blocks or 1
- for i = 1, blocks do
- while not turtle.forward() do
- turtle.dig()
- end
- turtle.digUp()
- end
- end
- local function drawDisplay(rowNumber,length,depth)
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.yellow)
- term.write("Running: ")
- term.setTextColor(colors.lime)
- term.write("simpleStripMiner")
- term.setTextColor(colors.yellow)
- term.write(" !")
- term.setCursorPos(1,3)
- term.setTextColor(colors.orange)
- term.write("Current row: ")
- term.setTextColor(colors.cyan)
- term.write(rowNumber)
- term.setTextColor(colors.orange)
- term.write("/")
- term.setTextColor(colors.blue)
- term.write(length)
- local estimatedMined = (rowNumber)*depth*2 + (rowNumber)*6
- local maxBlocks = length*depth*2 + length*6
- term.setCursorPos(1,4)
- term.setTextColor(colors.orange)
- term.write("Estimated mined blocks:")
- term.setTextColor(colors.pink)
- term.write(estimatedMined)
- term.setTextColor(colors.orange)
- term.write("/")
- term.setTextColor(colors.magenta)
- term.write(maxBlocks)
- term.setTextColor(colors.orange)
- term.write("!")
- term.setCursorPos(1,5)
- term.setTextColor(colors.red)
- term.write("Fuel ")
- term.setTextColor(colors.orange)
- term.write("remaining: ")
- term.setTextColor(colors.gray)
- print(turtle.getFuelLevel())
- term.setTextColor(colors.brown)
- term.write("Blocks ")
- term.setTextColor(colors.orange)
- term.write("remaining: ")
- term.setTextColor(colors.gray)
- term.write(maxBlocks-estimatedMined)
- term.setCursorPos(1,8)
- term.setTextColor(colors.orange)
- term.write("* Hold 'ctr + t' to stop!")
- term.setTextColor(colors.red)
- term.setCursorPos(9,8)
- term.write("ctr + t")
- term.setTextColor(colors.orange)
- term.setCursorPos(13,8)
- term.write("+")
- term.setCursorPos(1,9)
- print("* Use the 'refuel' command after stopping the program to refuel the turtle!")
- term.setTextColor(colors.red)
- term.setCursorPos(12,9)
- term.write("refuel")
- term.setTextColor(colors.yellow)
- term.setCursorPos(28,9)
- term.write("after")
- term.setTextColor(colors.white)
- end
- local function run(length,depth,dir)
- local whitelist = {
- "minecraft:diamond",
- "minecraft:emerald",
- "minecraft:raw_gold",
- "minecraft:raw_iron",
- "minecraft:raw_copper",
- "minecraft:coal",
- "minecraft:lapis_lazuli",
- "minecraft:quartz",
- "minecraft:ancient_debris"
- }
- local turn1 = turtle.turnLeft
- local turn2 = turtle.turnRight
- if dir == 0 then
- dir = "right"
- else
- dir = "left"
- end
- if dir == "right" then
- turn1 = turtle.turnRight
- turn2 = turtle.turnLeft
- end
- local blocksSinceLastPurge = 0
- drawDisplay(0,length,depth)
- for x = 1, length do
- mineForward(depth)
- if x%2 ~= 0 then
- turn1()
- mineForward(3)
- turn1()
- else
- turn2()
- mineForward(3)
- turn2()
- end
- drawDisplay(x,length,depth)
- blocksSinceLastPurge = blocksSinceLastPurge + depth*2
- if blocksSinceLastPurge > 500 then
- purgeInventory(whitelist)
- blocksSinceLastPurge = 0
- end
- end
- end
- return {
- run = run
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement