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

Rednet Help

Started by Pyrotech_Warrior, 20 June 2013 - 11:21 AM
Pyrotech_Warrior #1
Posted 20 June 2013 - 01:21 PM
Hello! I come here today as a simple noob with rednet.
I have 2 adv computers, 2 Wireless modems, and an ADV monitor. I want to place one computer in my house and have the other+monitor on a billboard. The intent is to send messages from my house to the monitor via rednet. I have been attempting to get this myself for about 3 days now but I just cant get it. Is there anyway I can get a script from somebody and see what I need to do? Or just guiding me on the right path would be a big help, thank you.
Lyqyd #2
Posted 20 June 2013 - 02:10 PM
Split into new topic.
bjornir90 #3
Posted 20 June 2013 - 02:12 PM
Have looked at the wiki of the mod ? You will gind everything you need and more :)/>
http://computercraft.info/wiki/Category:APIs
TheOddByte #4
Posted 20 June 2013 - 02:12 PM
Do you mean that you want to send from your computer to a computer that displays the text on the monitor?
ElvishJerricco #5
Posted 20 June 2013 - 02:30 PM
The built in rednet API is pretty simple to use. Obviously, it's not so secure but that doesn't seem to be what you're worrying about.

I agree you should look at the wiki and figure as much out as you can, but here's a crash course on rednet.

rednet.open(side) -- you must open the peripheral before you can use rednet.

rednet.send(id, msg) -- this will send a message to to the computer with the id <id>.

local id, msg, distance = rednet.receive() -- this will wait for a rednet message
                                           -- the receiving computer must be waiting on this
                                           -- in order to receive the sent message.

rednet.broadcast(msg) -- this sends a message to any computer that's listening via rednet.receive()
Beans #6
Posted 20 June 2013 - 05:39 PM
Here is a simple send, receive, and disply to monitor code.
ps. in order to get a computers id just enter id on the prompt screen and it will display.

— sending program

rednet.open("right") --- this tells the sending computer to send the message through the modem on the side listed
rednet.send(115,"write your message here") --- this tells the sending computer to send computer 115 the message between the quotes
rednet.close("right") --- this deactivates the modem on the side listed

— receiving program

m = peripheral.wrap("top")  --- tells the computer that anytime you specify m it will do that action on the monitor to the side listed
rednet.open("right") --- this tells the receiving computer to receive rednet messages through the modem on the listed side.

while true do --- an endless loop so the computer is always listning for a message
  event, id, message, distance = os.pullEvent("rednet_message") --- tells the receiver to wait for a message and split it into its 3 parts

  if id == 114 then --- tells the reciever to check what computer the rednet message was sent from (in this case computer id 114)
	m.setCursorPos(1,1) --- sets the cursor position to the 1st palce on the 1st line of the monitor
	m.write(message) --- writes out the rednet message
  end

  sleep(0.5) --- waits 1/2 a second then runs the program again looking for a message.
end

Hope this helps!