zed_com

очки и геосканер

Jun 29th, 2016
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. com=require("component")
  2.  
  3. local arg={...}
  4. local glass=com.glasses
  5. glass.removeAll()
  6. local geo=   com.geolyzer
  7.  
  8. local size=tonumber(arg[2]) or 16
  9. local pl=tonumber(arg[1] or 3)
  10. local minpl = 2
  11. local maxpl = 5
  12.  
  13. local maxY
  14. if (tonumber(arg[3]) or 0)==0 then maxY=1 else maxY=size end
  15.  
  16. local function tocolor(pl)
  17.     local color = (pl-minpl)/maxpl
  18.     if color<0 then
  19.         return {1,1,1}
  20.     elseif color>1 then
  21.         return {1,0,1}
  22.     else
  23.         return {color,1-color,0}
  24.     end
  25. end
  26.  
  27. function create(x,y,z,p)
  28.     local a=glass.addDot3D()
  29.     a.set3DPos(x,y,z)
  30.     a.setColor(table.unpack(tocolor(p)))
  31. end
  32.  
  33. for x=-size,size do
  34.     for z=-size,size do
  35.         tile=geo.scan(x,z)
  36.         os.sleep(0)
  37.         for Y=-math.min(size,18),math.min(maxY,18) do
  38.             local y=Y+32
  39.             if tile[y]>pl then create(x+0.5,Y+0.5,z+0.5,tile[y]) end
  40.         end
  41.     end
  42. end
  43. print("найдено объектов",glass.getObjectCount())
Advertisement
Add Comment
Please, Sign In to add comment