Posted 23 March 2013 - 03:24 AM
                Hello! I wrote some "USEFUL" function, that must be added into the peripheral API.
Example (usage):
getTypes(string PeripheralType)
function getMonitors()
local monitors=getTypes("monitor")
return monitors
end
Output: {"monitor_1", "monitor_5", "left", "right", "bottom"}
                
            
function getTypes(sType)
local fancyCrap = {}
local net = {}
local ret = {}
if sType == nil or type(sType) ~= "string" then
  error("Cannot parse input.", 1)
else
  net = peripheral.getNames()
  for asdX, valX in ipairs(net) do
   for netX = 1, #net do
    if peripheral.getType(valX) == sType then
	 retval=true
    else
	 retval=false
    end
   end
   if retval then
    table.insert(ret, valX)
   end
  end
  return ret
end
end
Example (usage):
getTypes(string PeripheralType)
function getMonitors()
local monitors=getTypes("monitor")
return monitors
end
Output: {"monitor_1", "monitor_5", "left", "right", "bottom"}
 
         
                 
                 
                