Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local x,_,z = gps.locate()
- if not (x and z) then
- term.setCursorPos(1,1)
- term.clear()
- print("Set position.")
- term.setCursorPos(1,2)
- term.write("X=")
- term.setCursorBlink(true)
- x = tonumber(read())
- term.setCursorPos(1,3)
- term.write("Z=")
- z = tonumber(read())
- term.setCursorBlink(false)
- else
- x = math.floor(x)
- z = math.floor(z)
- end
- local cx,cz = x-(x%16),z-(z%16)
- local level,cur=2,string.char(26)
- while true do
- term.setCursorPos(1,1)
- term.clear()
- print(string.format([[Scan to level
- %s128 - coal
- %s 64 - iron
- %s 32 - gold
- %s 16 - diamond, redstone, lapis]],
- level==4 and cur or " ",
- level==3 and cur or " ",
- level==2 and cur or " ",
- level==1 and cur or " ")
- )
- local e,p=os.pullEvent("key")
- if p==keys.up then
- level = math.min(4,level+1)
- elseif p==keys.down then
- level = math.max(1,level-1)
- elseif p==keys.enter then
- local ref = {16,32,64,128}
- level = ref[level]
- break
- end
- sleep(.1)
- end
- term.setCursorPos(1,1)
- term.clear()
- print(string.format([[Scan from
- X %d %s %d
- Y 1 %s %d
- Z %d %s %d
- Confirm ? Y/N (or F for Yes and Fast)]],
- cx,cur,cx+16,
- cur,level,
- cz,cur,cz+16)
- )
- while true do
- local e,p = os.pullEvent("key")
- if p==keys.y or p==keys.f then
- local fastMode=(p==keys.f)
- break
- elseif p==keys.n then
- sleep(.5)
- error("Terminated",0)
- return
- end
- sleep(.2)
- end
- local wi = peripheral.find("WorldInterface")
- local ref = {
- ["minecraft:stone"]={"7",colors.gray,0},
- ["minecraft:gravel"]={"7",colors.gray,0},
- ["minecraft:dirt"]={"",colors.brown,0},
- ["minecraft:coal_ore"]={"f",colors.black,1},
- ["minecraft:iron_ore"]={"8",colors.lightGray,2},
- ["minecraft:gold_ore"]={"1",colors.yellow,3},
- ["minecraft:diamond_ore"]={"0",colors.white,4},
- ["minecraft:emerald_ore"]={"d",colors.green,4},
- ["minecraft:lapis_ore"]={"b",colors.blue,3},
- ["minecraft:redstone_ore"]={"e",colors.red,2},
- ["minecraft:lit_redstone_ore"]={"e",colors.red,2},
- ["minecraft:air"]={" ",false,0},
- ["else"]={"a",colors.purple,0},
- }
- local count = {
- ["minecraft:diamond_ore"]=0,
- ["minecraft:gold_ore"]=0,
- ["minecraft:iron_ore"]=0,
- ["minecraft:lapis_ore"]=0,
- ["minecraft:redstone_ore"]=0,
- ["minecraft:coal_ore"]=0,
- ["minecraft:emerald_ore"]=0,
- }
- local function displayCount()
- term.setCursorPos(35,7)
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.black)
- term.write("I")
- term.setCursorPos(35,8)
- term.setBackgroundColor(colors.yellow)
- term.write("G")
- term.setCursorPos(35,9)
- term.setBackgroundColor(colors.white)
- term.write("D")
- term.setCursorPos(35,10)
- term.setBackgroundColor(colors.blue)
- term.write("L")
- term.setCursorPos(35,11)
- term.setBackgroundColor(colors.red)
- term.write("R")
- term.setCursorPos(35,12)
- term.setBackgroundColor(colors.green)
- term.write("E")
- term.setCursorPos(35,6)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.write("C "..count["minecraft:coal_ore"])
- term.setCursorPos(37,7)
- term.write(count["minecraft:iron_ore"])
- term.setCursorPos(37,8)
- term.write(count["minecraft:gold_ore"])
- term.setCursorPos(37,9)
- term.write(count["minecraft:diamond_ore"])
- term.setCursorPos(37,10)
- term.write(count["minecraft:lapis_ore"])
- term.setCursorPos(37,11)
- term.write(count["minecraft:redstone_ore"])
- term.setCursorPos(37,12)
- term.write(count["minecraft:emerald_ore"])
- end
- local report = {}
- local _x,_y,_z
- local function displayPos(nX,nY,nZ,nRX,nRY)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.setCursorPos(35,2)
- term.write("X: "..nX.."("..nRX..") ")
- term.setCursorPos(35,3)
- term.write("Y: "..nY.." ")
- term.setCursorPos(35,4)
- term.write("Z: "..nZ.."("..nRY..") ")
- end
- term.setBackgroundColor(colors.black)
- term.clear()
- for _y=1,level do
- term.setBackgroundColor(colors.black)
- -- term.clear()
- local i
- for i=1,16 do
- term.setCursorPos(2,i+1)
- term.write(string.rep(string.char(127),32))
- end
- if not fastMode then sleep(.5) end
- local lay = ""
- for _z=cz,cz+15 do
- displayCount()
- for _x=cx,cx+15 do
- local rx,ry = _x%16,_z%16
- displayPos(_x,_y,_z,rx,ry)
- term.setCursorPos(1,19)
- term.clearLine()
- local o = wi.getBlockInfos(_x,_y,_z)
- term.write(o.blockName)
- local _t,_c,delay=" ",false,0
- if type(ref[o.blockName])=="table"
- and #ref[o.blockName]>=3 then
- _t = ref[o.blockName][1]
- _c = ref[o.blockName][2]
- delay = ref[o.blockName][3]*.1
- if ref[o.blockName][3]>0 then
- table.insert(report,string.format(
- "y:%d|%s|x:%d|z%d",
- _y,o.blockName:sub(11,14),_x,_z)
- )
- if o.blockName=="minecraft:lit_redstone_ore" then
- count["minecraft:redstone_ore"] = count["minecraft:redstone_ore"]+1
- else
- count[o.blockName] = count[o.blockName]+1
- end
- end
- else
- _t = ref["else"][1]
- _c = ref["else"][2]
- end
- lay = lay.._t
- if _c then
- paintutils.drawPixel((rx*2)+2,ry+2,_c)
- paintutils.drawPixel((rx*2)+3,ry+2,_c)
- if not fastMode and delay>0 then
- sleep(delay)
- end
- end
- term.setBackgroundColor(colors.black)
- end
- -- sleep(.2)
- lay = lay.."\n"
- end
- local dir = "/scans/chunk_"..cx.."_"..cz
- local filename = "level_".._y
- local fh = fs.open(dir.."/"..filename,"w")
- fh.write(lay)
- fh.close()
- sleep(.3)
- end
- os.pullEvent("key")
- term.setCursorPos(1,1)
- term.clear()
- print("Report "..#report.." lines, "..math.ceil(#report/21).." pages")
- local str,i,l = ""
- for i,l in pairs(report) do
- str = (i==1) and l or str.."\n"..l
- end
- sleep(.3)
- os.pullEvent("key")
- --textutils.pagedPrint(str)
- fh = fs.open(".temp.scan","w")
- fh.write(str)
- fh.close()
- shell.run("edit .temp.scan")
- shell.run("rm .temp.scan")
Add Comment
Please, Sign In to add comment