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

Question about a program error

Started by Akirha, 01 June 2014 - 01:35 AM
Akirha #1
Posted 01 June 2014 - 03:35 AM
Hi, I'm new to Lua and computer craft but I have been programming for a long time. I recently had a major loss of vision because of diabetes and I just recently had surgery to reverse it. (Currently having someone proof read this). I'm using a magnifier right now to program computers and turtles in minecraft. I felt like explaining this because my question is a rather simple one but I have the most problems with it because of my vision.

Question: I'm getting an this error(bios:339: [string"rTable"]:9: ')' expected) whenever I run this code.



local id = nil
local packet = {["id"] = 1, ["name"] = "Bob", ["msg"] = "hi there"}
local msg = nil
while true do
  id, msg = rednet.receive(10)

  if id ~= nil and msg ~= nil then
	packet = textutils.unserialize(msg)
	print("id: "...packet.id)
	print("name: "...packet.name)
	print("msg: "....packet.msg)
	break
  end
end

I'm thinking it's a syntax error, but I wouldn't be here unless I was stumped. I apologize if this question is to trivial for the forum or answered somewhere else. If there is an answer to the problem in a post or in a tutorial please link, I would be more than happy to read it, I just have problems navigating around. Thank you :)
Ajt86 #2
Posted 01 June 2014 - 07:07 AM
When you typed in

print("id: "...packet.id)	 -- 3 dots
print("name: "...packet.name)	 -- 3 dots
print("msg: "....packet.msg)	 -- 4 dots
instead of "…" you need to use ".." (only two dots) to concatenate string, like this:

print("id: "..packet.id)
print("name: "..packet.name)
print("msg: "..packet.msg)
Edited on 01 June 2014 - 05:08 AM
Akirha #3
Posted 01 June 2014 - 07:18 AM
And now I'll never forget that two dots concatenate. Thank you so much.