Guest User

Untitled

a guest
Jan 19th, 2013
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. -- This program is for OpenCCSensors 0.1.2
  2. -- Monitor to be placed above the computer
  3. -- Sensor peripheral to be placed below the computer
  4. -- Inventory sensor card in the sensor (any level of card)
  5. -- A chest should be below the sensor, with a map in slot 1
  6.  
  7. os.loadAPI("ocs/apis/sensor")
  8.  
  9. local monitor = peripheral.wrap("top")
  10. local inventory = sensor.wrap("bottom")
  11.  
  12. local width, height = monitor.getSize()
  13.  
  14. local function getColorIndex(x, y)
  15.   return ((x-1) + (y-1) * 128) + 1
  16. end
  17.  
  18. local function drawPixel(x, y, color)
  19.   monitor.setCursorPos(x, y)
  20.   monitor.setBackgroundColor(color)
  21.   monitor.write(" ")
  22. end
  23.  
  24. local function displayMapColors(colors)
  25.   for x=1, width do
  26.     for y=1, height do
  27.       local index = getColorIndex(x, y)
  28.       local color = colors[index]
  29.       drawPixel(x, y, color)
  30.     end
  31.   end
  32. end
  33.  
  34. local mapData = inventory.sensorCardCall("getMapData", "0,-1,0", 1)
  35.  
  36. displayMapColors(mapData.Colors)
Advertisement
Add Comment
Please, Sign In to add comment