-- This program is for OpenCCSensors 0.1.2 -- Monitor to be placed above the computer -- Sensor peripheral to be placed below the computer -- Inventory sensor card in the sensor (any level of card) -- A chest should be below the sensor, with a map in slot 1 os.loadAPI("ocs/apis/sensor") local sides = rs.getSides(); local width = 0 local height = 0 local monitor = nil local function findPeripheralSide(type) for key, side in pairs(sides) do if peripheral.isPresent(side) and peripheral.getType(side) == type then return side; end end end local function findMonitor() local side = findPeripheralSide("monitor") if side then return peripheral.wrap(side) end end local function findSensor() local side = findPeripheralSide("sensor") if side then return sensor.wrap(side) end end local function getColorIndex(x, y) return ((x-1) + (y-1) * 128) + 1 end local function drawPixel(x, y, color) monitor.setCursorPos(x, y) monitor.setBackgroundColor(color) monitor.write(" ") end local function displayMapColors(colors) for x=1, width do for y=1, height do local index = getColorIndex(x, y) local color = colors[index] drawPixel(x, y, color) end end end local function findPossibleTargets(sen) local maps = {}; for key, data in pairs(sen.getTargets()) do local details = sen.getTargetDetails(key) for slot, slotd in pairs(details.Slots) do if slotd.Name == "item.map" then table.insert(maps, { target = key, slot = slot }) end end end return maps; end while true do monitor = findMonitor(); if monitor == nil then error("no monitor attached") end width, height = monitor.getSize() local inventory = findSensor() if inventory == nil then error("no sensor attached") end local possibleMaps = findPossibleTargets(inventory) local firstMap = table.remove(possibleMaps, 1) if firstMap ~= nil then local width, height = monitor.getSize() local mapData = inventory.sensorCardCall("getMapData", firstMap.target, firstMap.slot) displayMapColors(mapData.Colors) end sleep(0.1) end