Advertisement
promitheus_sal

pocket_geo_scanner.lua

Nov 26th, 2022 (edited)
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.84 KB | None | 0 0
  1.  
  2. geo = peripheral.wrap("back")
  3.  
  4.  
  5. function getNameFormatted(block, amount)
  6.     local ns,id = string.match(block,"([%a%d_]+):([%a%d_]+)")
  7.     return string.format("%dx %s",amount,id)
  8. end
  9.  
  10. function draw()
  11.     term.setBackgroundColor(colors.black)
  12.     term.setTextColor(colors.white)
  13.     term.clear()
  14.     term.setCursorPos(1,1)
  15.     term.write("CHUNK ANALYZER")
  16.     local list = geo.chunkAnalyze()
  17.     if list==nil then
  18.         term.setTextColor(colors.red)
  19.         term.setCursorPos(1,3)
  20.         term.write("SCANNING ON COOLDOWN!")
  21.         return
  22.     end
  23.     local line = 3
  24.     for block,count in pairs(list) do
  25.         term.setCursorPos(1,line)
  26.         term.write(getNameFormatted(block,count))
  27.         line = line+1
  28.     end
  29. end
  30.  
  31. while true do
  32.     local _,k = os.pullEvent("char")
  33.     if k=="r" then
  34.         draw()
  35.     end
  36. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement