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

rednet.recieve "Attemp to call nil" error

Started by ZallCaTor, 05 November 2015 - 01:50 AM
ZallCaTor #1
Posted 05 November 2015 - 02:50 AM
So, I've got this code to recieve a message and display a message accordingly. However, the "m = rednet.recieve()" always get's an "attempt to call nil" error. I can't see what's wrong.

rednet.open("back")
m = rednet.recieve()
while true do
	if m == "GenOn" then
	print("Generator is ON") else
	print("Generator is OFF")
	end
end

The second line always recieves the error, and I can't figure out why.
Bomb Bloke #2
Posted 05 November 2015 - 03:17 AM
It's saying there's no "recieve" function in the "rednet" table, so rednet.recieve() is an "attempt to call nil".

You're looking for rednet.receive(), and you probably want to put that line inside your loop - otherwise you'll be continuously checking a single value for "m"!
ZallCaTor #3
Posted 05 November 2015 - 04:16 AM
ok, well, my code looks like this now, and I still get the same error.

rednet.open("back")
while true do
m = rednet.recieve()
	    if m == "GenOn" then
	    print("Generator is ON") else
	    print("Generator is OFF")
	    end
end
Link149 #4
Posted 05 November 2015 - 04:38 AM
ok, well, my code looks like this now, and I still get the same error.

m = rednet.recieve()

You made a typo in the function's name. It should be rednet.receive(), and not rednet.recieve().
ZallCaTor #5
Posted 05 November 2015 - 05:03 AM
Oh…. Well…. Don't I look stupid now. :P/>
Thanks.
Creator #6
Posted 05 November 2015 - 05:39 AM
Don't worry, that error happened so often to me, you can't imagine. I was there looking at my code and not getting why it didn't work.
hugeblank #7
Posted 29 November 2015 - 01:05 AM
XP Found this, while trying to solve the same problem. did the EXACT same thing.