Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local refreshSeconds = 0.1
- if not term.isColor() then
- print("Advanced computer required")
- error()
- end
- local sides = peripheral.getNames()
- local mininglasers = {}
- for _, side in pairs(sides) do
- if peripheral.getType(side) == "warpdriveMiningLaser" then
- print("Wrapping " .. side)
- table.insert(mininglasers, peripheral.wrap(side))
- end
- end
- local noExit = true
- local layerOffset = 1
- local onlyOres = false
- local silktouch = false
- local args = {...}
- if #args > 0 then
- if args[1] == "help" or args[1] == "?" then
- print("Usage: mine <layerOffset> <onlyOres> <silktouch>")
- print()
- print("Miner always mines below it, down to bedrock.")
- print("Set layerOffset to define starting level.")
- print("Power consumption will be much lower in space.")
- print("Mining only ores is faster but more expensive...")
- print("Mining laser can't go through forcefields.")
- print("Mined chests will drop their contents.")
- print()
- noExit = false
- else
- layerOffset = tonumber( args[1] ) or 1
- end
- if #args > 1 then
- if args[2] == "true" or args[2] == "1" then
- onlyOres = true
- end
- end
- if #args > 2 then
- if args[3] == "true" or args[3] == "1" then
- silktouch = true
- end
- end
- end
- if #mininglasers == 0 then
- term.setBackgroundColor(colors.red)
- term.setTextColor(colors.white)
- print("No mining laser detected")
- noExit = false
- end
- if noExit then
- for _, mininglaser in pairs(mininglasers) do
- local isEnabled = mininglaser.enable()
- if not isEnabled then
- mininglaser.offset(layerOffset)
- mininglaser.onlyOres(onlyOres)
- mininglaser.silktouch(silktouch)
- mininglaser.enable(true)
- end
- end
- os.sleep(1)
- end
- local label = os.getComputerLabel()
- if label then
- else
- label = "" .. os.getComputerID()
- end
- if noExit then
- local areActive
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.blue)
- term.clear()
- term.setBackgroundColor(colors.lime)
- term.setCursorPos(1, 1)
- term.setBackgroundColor(colors.black)
- term.setCursorPos(1, 2)
- term.write("# status active energy mined/total layer")
- repeat
- areActive = false
- for key,mininglaser in pairs(mininglasers) do
- local energyUnits = mininglaser.energyDisplayUnits()
- local status, isActive, energy, currentLayer, mined, total = mininglaser.state()
- -- local _, energyPerLayer, energyPerBlock = mininglaser.getEnergyRequired()
- term.setBackgroundColor(colors.black)
- term.setCursorPos(1, key+2)
- term.clearLine()
- term.write(tostring(key) .. " " .. status .. " " .. tostring(isActive) .. " " .. energy .. " " .. energyUnits .. " " .. mined .. "/" .. total .. " " .. currentLayer)
- -- term.setTextColor(colors.gray)
- -- term.setCursorPos(1, 9)
- -- term.write("Scanning requires " .. energyPerLayer .. " " .. energyUnits .. " per layer")
- -- term.setCursorPos(1, 10)
- -- term.write("Mining requires " .. energyPerBlock .. " " .. energyUnits .. " per block")
- if isActive then
- areActive = true
- os.sleep(refreshSeconds)
- else
- os.sleep(refreshSeconds)
- end
- end
- until not areActive
- end
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- print()
- print("Program closed")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement