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

Displaying text on a monitor with rednet

Started by Blueblood, 14 March 2014 - 09:29 PM
Blueblood #1
Posted 14 March 2014 - 10:29 PM
Ok, Basicly I have set up a system that allows me to control certain features of my base using a menu, the menu calls a function with the ID of the selected option, which is then put through a series of "If" statements until the values become true, that code is posted below:

local function RednetSend()
if MenuSel == 1 then
rednet.broadcast("WHarvest")
end
if MenuSel == 2 then
rednet.broadcast("SHarvest")
end
if MenuSel == 3 then
rednet.broadcast("MFarm")
end
if MenuSel == 4 then
rednet.broadcast("")
end
end

I'm using rednet.broadcast() instead of rednet.send() as its only a temporary system, once its fully set up ill switch it too rednet.send().

I want to set it up so that when I activate one of the system it displays it on several monitors throughout my base. I know almost nothing about monitors and I could use some help!

The reason I want to send it too several monitors is because I plan to have several secure control rooms to control all the tasks that my turtles are doing and send error reports from them to the monitors so I can fix the problem quickly and reduce the turtles down time.
TheOddByte #2
Posted 15 March 2014 - 09:10 AM
Uhmm, It would be good if you showed us the full code, Or is this the full code? .-.
If you're looking for writing the same stuff on multiple computers you could use this http://pastebin.com/n5MNSudp
it's a program that wraps all monitors attached with wired modems and basically writes what's on the terminal( computer screen ).
So once you've run that, You could do this on the receiver computer


local _id = 9001 -- < Your id of the computer that sends
local message = "Waiting for message to be changed.."

while true do
    term.clear()
    term.setCursorPos( 1, 1 )
    term.write( message )
    local id, msg = rednet.receive()
    if id == _id then
        message = msg
    end
end
But let me explain on how to use monitors
First you wrap it like this

local mon = peripheral.wrap("right")
or like this

local mon = peripheral.wrap("monitor_0")
Note that 'right' &amp; 'monitor_0' are just examples, right is a side where you have a monitor, monitor_0 is the name of the monitor.

Ok, So once you've wrapped it lets try writing 'Hello World!' to it

mon.write("Hello World!")
( Yeah it is as simple as that :P/> )

Now if you have multiple monitors attached you can do this to wrap them and write to them

local monitors = {} -- Create a table for the monitors

--# Get all monitors attached
for _, name in ipairs( peripheral.getNames() ) do
    if peripheral.getType( name ) == "monitor" then
        local m = {}
        m.name = name
        table.insert( monitors, m )
    end
end

--# Wrap them
for i = 1, #monitors do
    monitors[i].name = peripheral.wrap( monitors[i].name )
end

--# And finally write to them
for i = 1, #monitors do
    monitors[i].name.write("Hello World!")
end