Jump to content




Attempt To Concentrate?


  • You cannot reply to this topic
3 replies to this topic

#1 hbomb79

  • Members
  • 352 posts
  • LocationOrewa, New Zealand

Posted 11 June 2014 - 06:11 AM

Hi there, programming a Rednet program and i want to check if the message if from the right PC and with the correct Protocol, although this all seems to work but when i try to print the message it gives me the error of "Attempt To Concentrate Function And String"

Here is my code, if someone could tell me how to fix and what the error are and what they mean that would be great

-- Assigning Variables
i = 1
authenticate = 2

--Opening Rednet
rednet.open"bottom"
--Call To Clear Screen
function clear()
  term.clear()
  term.setCursorPos(1,1)
end
clear()

-- Loop
while i == 1 do
  print "Waiting For Message"
  id, message, protocol = rednet.receive()

function message()
	print ("Message Received: " .. message .. " And Verified As Secure") -- This is the line of the Error!
	sleep(3)
  end

  
  --Checks If Message Is Okay
  function authority()
	if id == authenticate then
	  print "Sender ID Verified"
	  print "Checking Protocol"
		if protocol == "BulkHead" then
	 print "Protocol Matches"
		   message()
		else
		  print ("Message Recieved With Invalid Protocol:  " .. protocol .. " Message Ignored")
		  sleep(3)
		end
	else
	  print ("Message Received With Unauthentic ID:  " .. id .. " ,Message Ignored")
	  sleep(3)
	end
	end


  
authority()
clear()
end

Edited by Hbomb_79, 12 June 2014 - 06:32 AM.


#2 wieselkatze

  • Members
  • 221 posts
  • LocationGermany

Posted 11 June 2014 - 07:01 AM

Heh, I don't think it's really "concentrate".
You probably wanted to say "concatenate".
Concatenation is basically adding two strings together, or numbers with strings etc.
Your problem is in your message function.
In there you say print("blah"..message.."blah"), but message is actually the function you called. So message is not the string you wanted to concatenate, but the function.
Either rename your message variable from rednet.receive() or just change the function name.

Edited by wieselkatze, 11 June 2014 - 02:36 PM.


#3 hbomb79

  • Members
  • 352 posts
  • LocationOrewa, New Zealand

Posted 12 June 2014 - 05:27 AM

Thank you, that fixed it :)

#4 hbomb79

  • Members
  • 352 posts
  • LocationOrewa, New Zealand

Posted 12 June 2014 - 06:33 AM

Thanks, that fixed it, thanks for explaining

oops, my first thanks didnt show up...





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users