 
                
                8 posts
                
             
            
                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.
 
         
        
        
            
            
                
                     
                
                7083 posts
                
                    
                        Location
                        Tasmania (AU)
                    
                
             
            
                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"!
                
             
         
        
        
            
            
                
                     
                
                8 posts
                
             
            
                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
 
         
        
        
            
            
                
                     
                
                47 posts
                
                    
                        Location
                        Quebec, Canada
                    
                
             
            
                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().
 
         
        
        
            
            
                
                     
                
                8 posts
                
             
            
                Posted 05 November 2015 - 05:03 AM
                Oh…. Well…. Don't I look stupid now. :P/>
Thanks.
                
             
         
        
        
            
            
                
                     
                
                2679 posts
                
                    
                        Location
                        You will never find me, muhahahahahaha
                    
                
             
            
                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.
                
             
         
        
        
            
            
                
                     
                
                149 posts
                
                    
                        Location
                        A grocery store near you!
                    
                
             
            
                Posted 29 November 2015 - 01:05 AM
                XP Found this, while trying to solve the same problem. did the EXACT same thing.