Advertisement
C0BRA

Thermal camera

Dec 28th, 2012
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.84 KB | None | 0 0
  1. local cam = self.CreateLink("camera")
  2. local screen = self.CreateLink("screen")
  3. local button = self.CreateLink("button")
  4.  
  5. local RES = 61
  6. local FOV = 90
  7.  
  8. local picture = nil
  9. local x = 0
  10. local y = 0
  11.  
  12. function Think()
  13.     if not cam.Connected then return 1 end
  14.     if not screen.Connected then return 1 end
  15.     if not button.Connected then return 1 end
  16.    
  17.     if button.IsPressed() then
  18.         picture = cam.Query(FOV, RES, RES)
  19.         screen.Clear(Color(0, 0, 0, 0))
  20.         x = 0
  21.         y = 0
  22.         return 5
  23.     end
  24.    
  25.     if picture then
  26.         local val = picture[x][y] or 0
  27.         local col = Color(0, 0, 0, 255)
  28.        
  29.         if val > 0 then
  30.             col = Color(255, 255, 255, 255)
  31.         end
  32.        
  33.         screen.Draw(" ", x, y, Color(0,0,0,0), col)
  34.        
  35.         x = x + 1
  36.         if x > RES then
  37.             x = 0
  38.             y = y + 1
  39.         end
  40.        
  41.         if y > RES then
  42.             picture = nil
  43.         end
  44.         return 0
  45.     end
  46.    
  47.     return 0.25
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement