Advertisement
amr2003

Moar peripherals terminal glasses image drawer

Jun 1st, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.02 KB | None | 0 0
  1. local data = { ... }
  2.  
  3. local tg = data[2]
  4.  
  5. local g = peripheral.wrap(tg)
  6.  
  7. g.clear()
  8.  
  9. g.sync()
  10.  
  11. local cols = {
  12.     ["0"] = 0x1,
  13.     ["1"] = 0x2,
  14.     ["2"] = 0x4,
  15.     ["3"] = 0x8,
  16.     ["4"] = 0x10,
  17.     ["5"] = 0x20,
  18.     ["6"] = 0x40,
  19.     ["7"] = 0x80,
  20.     ["8"] = 0x100,
  21.     ["9"] = 0x200,
  22.     ["a"] = 0x400,
  23.     ["b"] = 0x800,
  24.     ["c"] = 0x1000,
  25.     ["d"] = 0x2000,
  26.     ["e"] = 0x4000,
  27.     ["f"] = 0x8000,
  28. }
  29.  
  30. if fs.exists(data[1]) == true then
  31.     local file = fs.open(data[1], "r")
  32.    
  33.     local nchars = " "
  34.    
  35.     local schar = { }
  36.    
  37.     local line = 1
  38.    
  39.     while nchars ~= nil do
  40.         nchars = file.readLine()
  41.        
  42.         schar = { }
  43.        
  44.         for i = 1, #nchars do
  45.             table.insert(schar[i], string.sub(nchars, i, i))
  46.         end
  47.        
  48.         for i = 1,#schar do
  49.             if schar[i] ~= " " then
  50.                 g.addBox(i, line, 1, 1, cols[schar[i]], 0.2)
  51.             end
  52.         end
  53.         line = line + 1
  54.      end
  55.     g.sync()
  56.  end
  57.  
  58.  f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement