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

Attempt To Concentrate?

Started by hbomb79, 11 June 2014 - 05:11 AM
hbomb79 #1
Posted 11 June 2014 - 07: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 on 12 June 2014 - 05:32 AM
wieselkatze #2
Posted 11 June 2014 - 08: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 on 11 June 2014 - 01:36 PM
hbomb79 #3
Posted 12 June 2014 - 06:27 AM
Thank you, that fixed it :)/>
hbomb79 #4
Posted 12 June 2014 - 07:33 AM
Thanks, that fixed it, thanks for explaining

oops, my first thanks didnt show up…