NetGroup, put simply, is a nice, simple API that allows you to use multiple peripherals and multiple peripheral types over wired cables with ease. You can mass-print, project across many monitors, and turn on or turn off many computers with a couple commands.
Usage / Tutorial
-- Get a group object
-- Arguments are the modem side and the peripheral filter (e.g. "monitor", "printer", "computer")
group = netgroup.wrap('back', 'printer')
-- Use the object like a normal peripheral
group.newPage()
group.setPageTitle('This is a page title!')
group.write('Some text!')
group.endPage()
-- Set the groups filter to another object
group.filter('monitor')
-- Can use the same function to get the current filter
print(group.filter()) --> monitor
-- Dynamic arguments based on monitor/peripheral name
-- Functions receive the monitor and peripheral name
group.setCursorPos(function(mon) -- centered text
local w,h = mon.getSize()
return w/2, h/2
end)
group.setBackgroundColor(colors.black)
group.setTextColor(function() return 2^math.random(14) end) -- random text color
group.clear()
group.write(function(mon, name) return name end) -- prints the monitor name for each monitor
-- Results from functions are stored in tables
local sizes = group.getSize()
local size = sizes.monitor_0
print(size[1]..'x'..size[2]) --> (the size of monitor_0)
Screenshots
Spoiler
Spoiler
(there's a connection error in this image that I fixed prior to testing the script, just ignore it :P/>/> )
Spoiler
Spoiler
Spoiler
Spoiler
Spoiler
Code for "peripheral-abuse" program:
Spoiler
os.loadAPI('netgroup')
local group = netgroup.wrap('back','monitor')
group.setBackgroundColor(colors.black)
group.setTextColor(function() return 2^math.random(14) end)
group.setCursorPos(1,1)
group.setTextScale(2)
group.clear()
group.write(function(mon, name) local w,h = mon.getSize() return w..'x'..h end)
group.filter('printer')
group.newPage()
group.setPageTitle('It works!')
group.write('Like a boss.')
group.endPage()
group.filter('computer')
group.turnOn()
Download: pastebin get rfMuKz2t netgroup