Advertisement
Doob

geocamera

Jun 28th, 2017
220
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local component = require('component')
  2. local sides = require('sides')
  3. local geolyzer = component.geolyzer
  4. local gpu = component.gpu
  5. local px = require('unicode').char(0x2580)
  6. local side, size, min_hardness, max_hardness = 0, 8, 0, 50
  7. local scan = {}
  8. local colors = {
  9.   0XFFF,
  10.   0X1FFF,
  11.   0X2FFF,
  12.   0X3FFF,
  13.   0X4FFF,
  14.   0X5FFF,
  15.   0X6FFF,
  16.   0X7FFF,
  17.   0X8FFF,
  18.   0X9FFF,
  19.   0XAFFF,
  20.   0XBFFF,
  21.   0XCFFF,
  22.   0XDFFF,
  23.   0XEFFF,
  24.   0XFFFF,
  25.   0XFFF0,
  26.   0XFFE0,
  27.   0XFFD0,
  28.   0XFFC0,
  29.   0XFFB0,
  30.   0XFFA0,
  31.   0XFF90,
  32.   0XFF80,
  33.   0XFF70,
  34.   0XFF60,
  35.   0XFF50,
  36.   0XFF40,
  37.   0XFF30,
  38.   0XFF20,
  39.   0XFF10,
  40.   0XFF00,
  41.   0XFFF00,
  42.   0X1FFF00,
  43.   0X2FFF00,
  44.   0X3FFF00,
  45.   0X4FFF00,
  46.   0X5FFF00,
  47.   0X6FFF00,
  48.   0X7FFF00,
  49.   0X8FFF00,
  50.   0X9FFF00,
  51.   0XAFFF00,
  52.   0XBFFF00,
  53.   0XCFFF00,
  54.   0XDFFF00,
  55.   0XEFFF00,
  56.   0XFFFF00,
  57.   0XFFF000,
  58.   0XFFE000,
  59.   0XFFD000,
  60.   0XFFC000,
  61.   0XFFB000,
  62.   0XFFA000,
  63.   0XFF9000,
  64.   0XFF8000,
  65.   0XFF7000,
  66.   0XFF6000,
  67.   0XFF5000,
  68.   0XFF4000,
  69.   0XFF3000,
  70.   0XFF2000,
  71.   0XFF1000,
  72.   0XFF0000
  73. }
  74.  
  75. local tw = {{32, 1, -1}, {1, 32, 1}}
  76. local ob = {{-1, 1, 1}, {1, -1, -1}}
  77.  
  78. local function get(side)
  79.   local n, e1, e2, f, t, s, index, test = 1, 1, 1
  80.   if side == 1 then
  81.     e2, n = 2, 2
  82.   elseif side == 0 or side == 4 then
  83.     e1, e2 = 2, 2
  84.   elseif side == 3 then
  85.     e1, e2, n = 2, 2, 2
  86.   elseif side == 2 then
  87.     e1 = 2
  88.   elseif side == 5 then
  89.     e1, n = 2, 2
  90.   end
  91.   f, t, s = table.unpack(tw[n])
  92.   for z = size*ob[e1][1], size*ob[e1][2], ob[e1][3] do
  93.     for x = size*ob[e2][1], size*ob[e2][2], ob[e2][3] do
  94.       if side == 0 then
  95.         test = geolyzer.scan(x, z, -32, 1, 1, 32)
  96.       elseif side == 1 then
  97.         test = geolyzer.scan(x, z, 1, 1, 1, 32)
  98.       elseif side == 2 then
  99.         test = geolyzer.scan(x, 1, z, 1, -32, 1)
  100.       elseif side == 3 then
  101.         test = geolyzer.scan(x, 1, z, 1, 32, 1)
  102.       elseif side == 4 then
  103.         test = geolyzer.scan(1, x, z, -32, 1, 1)
  104.       elseif side == 5 then
  105.         test = geolyzer.scan(1, x, z, 32, 1, 1)
  106.       end
  107.       local a
  108.       for i = f, t, s do
  109.         if test[i] > min_hardness and test[i] < max_hardness then
  110.           if side == 1 or side == 3 or side == 5 then
  111.             index = (32-i)*2
  112.           else
  113.             index = i*2
  114.           end
  115.           table.insert(scan, colors[index])
  116.           a = true
  117.           break
  118.         end
  119.       end
  120.       if not a then
  121.         table.insert(scan, 0)
  122.       end
  123.     end
  124.   end
  125. end
  126.  
  127. local function draw()
  128.   local x, y = 1, 1
  129.   for i = 1, #scan do
  130.     gpu.setForeground(scan[i])
  131.     if i+1+size*2 <= #scan then
  132.       gpu.setBackground(scan[i+1+size*2])
  133.     end
  134.     gpu.set(x, (y+(y%2))/2, px)
  135.     if x-1 == size*2 then
  136.       x, y = 1, y+1
  137.     else
  138.       x = x+1
  139.     end
  140.   end
  141. end
  142.  
  143. local args = {...}
  144. if args[1] then
  145.   side = sides[args[1]:lower()]
  146. end
  147. if args[2] then
  148.   size = tonumber(args[2])
  149. end
  150. gpu.setResolution(size*2+1, size+1)
  151. get(side)
  152. draw()
  153. os.sleep(10)
  154. gpu.setForeground(0xffffff)
  155. gpu.setBackground(0)
Advertisement
RAW Paste Data Copied
Advertisement