Advertisement
TwoThe

OC Geolyzer

Jan 27th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.66 KB | None | 0 0
  1. local component = require("component")
  2. local geo = component.geolyzer
  3. local gpu = component.gpu
  4.  
  5. local denseChars = {" ", "-", "░", "▓", "█"}
  6.  
  7. local toChar = function(d)
  8.   return denseChars[math.max(1, math.min(5, 1+math.floor(d*2.0)))] or "?"
  9. end
  10.  
  11. local scan = function(times)
  12.   local result = geo.scan(0,0)
  13.   for i=2,times do
  14.     local blocks = geo.scan(0,0)
  15.     for k,v in ipairs(blocks) do
  16.       result[k] = result[k] + v
  17.     end
  18.   end
  19.   for i=1,#result do
  20.     result[i] = result[i] / times
  21.   end
  22.   return result
  23. end
  24.  
  25. local printResult = function(result)
  26.   for x=1,50 do
  27.     gpu.set(x, 1, toChar(result[x]))
  28.   end
  29. end
  30.  
  31. printResult(scan(4))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement