TwoThe

OC Ore Scan

Sep 6th, 2014
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.29 KB | None | 0 0
  1. local component = require "component"
  2.  
  3. local holo = component.hologram
  4. local geo = component.geolyzer
  5.  
  6. if not (holo and geo) then
  7.   print("Requires hologram projector and Geolyzer.")
  8.   return
  9. end
  10.  
  11. local CENTER, ORE, OBSIDIAN = 1, 2, 3
  12. holo.setPaletteColor(CENTER, 0xFFFF00)
  13. holo.setPaletteColor(ORE, 0xa8a8a8)
  14. holo.setPaletteColor(OBSIDIAN, 0x380474)
  15.  
  16. function setPixel(x, z, y, density)
  17.   local color = OBSIDIAN
  18.   if ((x == 24) and (z == 24) and (y == 16)) then
  19.     color = CENTER
  20.   elseif (density <= 2) then
  21.     color = false
  22.   elseif (density <= 4) then
  23.     color = ORE
  24.   end
  25.  
  26.   holo.set(x, y, z, color)
  27. end
  28.  
  29. function scanCol(x, z, times)
  30.   local col, value
  31.   local result = {}
  32.   for round = 1,times do
  33.     col = geo.scan(x - 24, z - 24)
  34.     for i = 1,#col do
  35.       value = col[i]
  36.       if (value < 0) then
  37.         value = 0
  38.       elseif (value > 5) then
  39.         value = 5
  40.       end
  41.       result[i] = (result[i] or 0) + value
  42.     end
  43.   end
  44.   for i = 1,#result do
  45.     result[i] = result[i] / times
  46.   end
  47.   return result
  48. end
  49.  
  50.  
  51. function scanArea()
  52.   local col
  53.   for x = 8,40 do
  54.     for z = 8,40 do
  55.       col = scanCol(x, z, 10)
  56.       for y = 1,32 do
  57.         setPixel(x, z, y, col[y+16])
  58.       end
  59.     end
  60.   end
  61. end
  62.  
  63. holo.clear()
  64. holo.setScale(1)
  65. scanArea()
Advertisement
Add Comment
Please, Sign In to add comment