17 posts
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
2679 posts
Location
You will never find me, muhahahahahaha
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
1140 posts
Location
Kaunas, Lithuania
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
7083 posts
Location
Tasmania (AU)
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.