This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
SmashLols's profile picture

Multiple monitors on network

Started by SmashLols, 29 May 2015 - 07:02 PM
SmashLols #1
Posted 29 May 2015 - 09:02 PM
I need help i am making a basic warning system for monitors but its not working for multiple monitors.
heres the code:

local m = peripheral.find("monitor")
m.setBackgroundColor(colors.red)
m.setTextColor(colors.white)
m.clear()
m.write("[Warning!]")
Modify the code to your desire to help me.

Thanks
Creator #2
Posted 29 May 2015 - 09:37 PM
Peripheral find will return the address. Now you need to wrap it with the given address.
Edited on 29 May 2015 - 07:38 PM
MKlegoman357 #3
Posted 29 May 2015 - 10:28 PM
No, peripheral.find will return the wrapped peripheral. It returns all the peripherals it can find so you can just put them to a table:


local monitors = { peripheral.find("monitor") } --# find all monitors and put them into a table

for i = 1, #monitors do --# for every monitor do the code below
  monitors[i].clear()
  ...
end
Bomb Bloke #4
Posted 30 May 2015 - 02:08 AM
The example script I posted alongside skyTerm demonstrates how to easily treat multiple displays as one. You just tweak the "displays" table to hold all those you wish to use. Eg:

local displays = {term.current(), peripheral.wrap("top"), peripheral.wrap("bottom")}  -- Merge current display with monitors to the top and bottom.

local displays = {peripheral.find("monitor")}  -- Merge all monitors.

local displays = {term.current(), peripheral.find("monitor")}  -- Merge current display with all monitors.