Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local trt_name = "chunki"
- local updateCh = 42
- local height = 64
- local stopAt = 16
- local chunkSize = 16
- local w, h = term.getSize()
- -- Modem functions
- local modem = nil
- local modAvl = false
- function wrapModem( side )
- if peripheral.getType(side) == "modem" then
- modem = peripheral.wrap(side)
- modAvl = true
- term.write("Found Modem")
- end
- end
- function sendUpdate(update)
- if modAvl then
- modem.transmit(updateCh, updateCh+1, update)
- end
- end
- term.clear()
- term.setCursorPos(w-11, 1)
- if peripheral.getType("left") ~= nil then
- wrapModem("left")
- else if peripheral.getType("right") ~= nil then
- wrapModem("right")
- end
- end
- term.setCursorPos(1,1)
- --
- term.write("ChunkMiner")
- term.setCursorPos(1,2)
- function percentage(input, max)
- return input/max*100
- end
- function printBar(perc)
- local tens = perc/10
- term.write("|")
- for i=0,10 do
- if i < tens then
- term.write("#")
- else
- term.write(" ")
- end
- end
- term.write("| ")
- end
- function progress( name, cursorPos, input, max, sendUpd )
- term.setCursorPos(1,cursorPos)
- term.clearLine()
- term.write(name)
- printBar(percentage(input, max))
- if sendUpd then
- local update = {
- name = trt_name,
- progress = percentage(input, max),
- fuel = percentage(turtle.getFuelLevel(), turtle.getFuelLimit())
- }
- sendUpdate(update)
- end
- end
- --inv functions
- function invFull()
- if turtle.getItemCount(9) > 0 then
- turtle.select(1)
- return true
- end
- turtle.select(1)
- return false
- end
- function emptyInv()
- for i=1,16 do
- turtle.select(i)
- turtle.drop(turtle.getItemCount(i))
- end
- turtle.select(1)
- end
- --mining functions
- function digForward()
- while turtle.forward() == false do
- turtle.dig()
- turtle.attack()
- end
- end
- function line()
- for i=1,chunkSize-1 do
- progress("Line ", 2, i, chunkSize-1)
- digForward()
- end
- end
- function slice()
- for i=1,chunkSize/2 do
- progress("Slice ", 3, i, chunkSize/2)
- line()
- turtle.turnRight()
- digForward()
- turtle.turnRight()
- line()
- if i ~= chunkSize/2 then
- turtle.turnLeft()
- digForward()
- turtle.turnLeft()
- end
- end
- end
- function down(height)
- for i=1,height-stopAt do
- progress("Heigth", 4, i, height-stopAt, true)
- slice()
- turtle.digDown()
- turtle.down()
- turtle.turnRight()
- line()
- if invFull() then
- local success, data = turtle.inspect()
- if success then
- while data.name ~= "minecraft:chest" do
- success, data = turtle.inspect()
- turtle.up()
- end
- end
- turtle.down()
- emptyInv()
- while turtle.detectDown() == false do
- turtle.down()
- end
- turtle.turnRight()
- else
- turtle.turnRight()
- end
- end
- end
- digForward()
- down(height)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement