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

[1.2.5] Rednet Troubles

Started by wombatwarrior67, 19 November 2013 - 11:10 AM
wombatwarrior67 #1
Posted 19 November 2013 - 12:10 PM
I am on a 1.2.5 world and am making a program for a mining system. It all goes well but according to my test computer, which I run the commands

m = peripheral.wrap("left")
rednet.open("left")
msg = rednet.receive()
print(msg)
it spits out 0 and 1. Any Ideas?

PC Program:

m = peripheral.wrap("right")
rednet.open ("right")
cycles = 0
while true do
	 rednet.broadcast("mine")
	 cycles = cycles + 1
	 print ("Cycles = "..cycles)
	 sleep(10)
end
Lyqyd #2
Posted 19 November 2013 - 12:47 PM
The first value rednet.receive returns is the ID of the sending computer. Use `id, msg = rednet.receive()` instead. If you're doing that from the Lua prompt, the 0 is the value in msg, meaning that you're sending the rednet message from computer 0, and the 1 is print returning the number of lines it wrote to the screen.
wombatwarrior67 #3
Posted 19 November 2013 - 12:52 PM
Thanks Man! Works a treat!